有关运行时移动控件的问题,分不够还可以加 (100分)

  • 主题发起人 HeXiang Lee
  • 开始时间
H

HeXiang Lee

Unregistered / Unconfirmed
GUEST, unregistred user!
我想做一个图像处理的程序,但有一问题不知如何解决:
就像Windows 画笔一样,可以自由拖动选定框,可以放大,也可以移动。哪位大合侠能
给个实例子。多谢!

能帮我实现移动窗体上任意一种控件的另送300分,决不食言!

 
全文检索里找“画笔”
 
private
{ Private declarations }
tp:TPoint;
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
tp:=ClientToScreen(Point(X,Y));
end;

procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var
p:TPoint;
begin
if ssLeft in Shift then
begin
p:=ClientToScreen(Point(X,Y));
Image1.Left:=Image1.Left+(p.x-tp.x);
Image1.Top:=Image1.Top+(p.y-tp.y);
end;
end;

procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
p:TPoint;
begin
p:=ClientToScreen(Point(X,Y));
Image1.Left:=Image1.Left+(p.x-tp.x);
Image1.Top:=Image1.Top+(p.y-tp.y);
end;
 
To chenzheng770101:
可能你理解错了我的意思!我是霁"画笔"里的选定功能那倦的国效果.烦请再帮我想一想好吗?
 
没有人知道了吗?
不会吧!
大侠们,快快出手吧,困扰我好久了!
 
问题难度=1, 程序繁琐度=100。
不是每个人都有空写的。
 
运行时移动控件,要对WM_NCHITTEST处理,Delphi4内幕中有例子,我不多讲!
 
同意 Pearl :)
 
//试试下面的代码,可以实现你要的效果
procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer);
const
SC_DragMove = $F012; { a magic number }
begin
ReleaseCapture;
panel1.perform(WM_SysCommand, SC_DragMove, 0);
end;
 
知道自已的问题弱智,早早结束该贴!谢谢大家
 
顶部