1
2 //This code shows how to move controls during runtime using the mouse
3 unit Unit1;
4
5 interface
6
7 uses
8 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
9 Dialogs, ExtCtrls, StdCtrls;
10
11 type
12 TForm1 = class(TForm)
13 Panel1: TPanel;
14 Edit1: TEdit;
15 Button1: TButton;
16 CheckBox1: TCheckBox;
17 ListBox1: TListBox;
18 RadioButton1: TRadioButton;
19 procedure Edit1MouseDown(Sender: TObject; Button: TMouseButton;
20 Shift: TShiftState; X, Y: Integer);
21 private
22 { Private declarations }
23 public
24 { Public declarations }
25 end;
26
27 var
28 Form1: TForm1;
29
30 implementation
31
32 {$R *.dfm}
33
34 procedure TForm1.Edit1MouseDown(Sender: TObject; Button: TMouseButton;
35 Shift: TShiftState; X, Y: Integer);
36
37 const
38 SC_DragMove = $F012;
39 begin
40 ReleaseCapture;
41 TwinControl(sender).Perform(WM_SysCommand, SC_DRAGMOVE, 0);
42 end;
43
44 end.
{*********************************DFM****************************************}
object Form1: TForm1
Left = 192
Top = 107
Width = 870
Height = 640
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Panel1: TPanel
Left = 432
Top = 248
Width = 185
Height = 41
Caption = 'Panel1'
TabOrder = 0
OnMouseDown = Edit1MouseDown
end
object Edit1: TEdit
Left = 216
Top = 152
Width = 121
Height = 21
TabOrder = 1
Text = 'Edit1'
OnMouseDown = Edit1MouseDown
end
object Button1: TButton
Left = 368
Top = 48
Width = 75
Height = 25
Caption = 'Button1'
TabOrder = 2
OnMouseDown = Edit1MouseDown
end
object CheckBox1: TCheckBox
Left = 248
Top = 56
Width = 97
Height = 17
Caption = 'CheckBox1'
TabOrder = 3
OnMouseDown = Edit1MouseDown
end
object ListBox1: TListBox
Left = 464
Top = 24
Width = 121
Height = 97
ItemHeight = 13
TabOrder = 4
OnMouseDown = Edit1MouseDown
end
object RadioButton1: TRadioButton
Left = 432
Top = 184
Width = 113
Height = 17
Caption = 'RadioButton1'
TabOrder = 5
OnMouseDown = Edit1MouseDown
end
end
|