类似于PHOTOSHOP里面的画直线或者其他什么的操作,
比如当选定了一项画方框功能后,就能用鼠标在画布上画出一个方框我想先设置一个鼠标的钩子,然后拦截鼠标的消息来进行这样的操作不知道大家有没有好的方法了?
比如当选定了一项画方框功能后,就能用鼠标在画布上画出一个方框我想先设置一个鼠标的钩子,然后拦截鼠标的消息来进行这样的操作不知道大家有没有好的方法了?
解决方案 »
- 为什么连成功后Timer1控件就不在循环了
- Vista下CopyFileEx进度条问题
- 请问怎么从URL中分解出正确的文件, 如从http://www.sina.com.cn 分解出实际的URL应该是http://www.sina.com.cn/index.htm
- 为什么键盘事件不响应?
- 报表问题!有如下结构表,不知道怎么实现要求的报表,将字段作为记录值输出
- 无故散分
- 汉字编码问题?基础问题!学国计算机的 可能就我 不知道!
- 用installshell express做安装程序的时候怎样做到像这种结果,看里面吧:
- 请问在delphi代码编辑中怎样快速移动光标到先前的位置(是否有快捷键)
- 打印的问题**急!!**
- stringgrid隔行显示不同颜色的问题,怎么把字都盖住了?
- 提问:用分布式数据库可以实现吗,(类似于网络游戏的形式)(在线等的
var
a:TREct;
b:TREct;
dra:integer;
procedure TPICW.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if (shift=[ssShift,ssleft]) then
begin
dra:=1;
a.Left:=x;
a.Top:=y;
end;
end;procedure TPICW.Image1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
dra:=0;
end
procedure TPICW.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if dra=1 then
begin
a.Right:=x;
a.Bottom:=y;
image1.Picture.Bitmap.Canvas.Pen.Mode:=pmnotXor;
image1.Picture.Bitmap.Canvas.Rectangle(b);//这里是方型框
image1.Picture.Bitmap.Canvas.Rectangle(a);
b:=a;
end;
end
按住Shift键开始画框。
Shift: TShiftState; X, Y: Integer);
var
i: Integer;
begin
selRect := TShape.Create(nil);
selRect.Parent := Panel1;
selRect.Left := X;
selRect.Top := Y;
selRect.Width := 0;
selRect.Height := 0;
selRect.Pen.Style := psDash;
selRect.Brush.Style := bsClear;
selRect.Pen.Color := clBlack; SelCurrentX := X;
SelCurrentY := Y;
SelIsDown := true;
Screen.Cursor := crCross;
end;procedure TForm1.Panel1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if (SelIsDown) then
begin
selRect.Width := X - SelCurrentX;
selRect.Height := Y - SelCurrentY;
end;
end;procedure TForm1.Panel1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
ScanSelected(selRect);
FreeAndNil(selRect);
SelIsDown := false;
Screen.Cursor := crDefault;
end;
用IMAGE的事件也可以,但觉得对于不同的操作判断起来太麻烦
C:\Program Files\Borland\Delphi6\Demos\Doc\Graphex
看一下就明白了