Author: Tomas Rutkauskas
I use SC_DRAGMOVE so I can drag a TPanel around a form. Now, how do I tell the form
when the panel is outside the form and the form should add some scrollbars?
Answer:
1 unit Unit1;
2
3 interface
4
5 uses
6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
7 Dialogs, ComCtrls, StdCtrls, ExtCtrls;
8
9 type
10 TPanel = class(ExtCtrls.TPanel)
11 private
12 procedure WMExitSizeMove(var message: TMessage); message WM_EXITSIZEMOVE;
13 end;
14
15 TForm1 = class(TForm)
16 StatusBar: TStatusBar;
17 Button1: TButton;
18 OpenDialog1: TOpenDialog;
19 Label1: TLabel;
20 ComboBox1: TComboBox;
21 CheckBox1: TCheckBox;
22 Panel1: TPanel;
23 procedure Panel1MouseDown(Sender: TObject; Button: TMouseButton;
24 Shift: TShiftState; X, Y: Integer);
25 private
26 { Private declarations }
27 public
28 { Public declarations }
29 end;
30
31 var
32 Form1: TForm1;
33
34 implementation
35
36 {$R *.DFM}
37
38 procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton;
39 Shift: TShiftState; X, Y: Integer);
40 const
41 SC_DRAGMOVE = $F012;
42 begin
43 Mouse.Capture := 0;
44 sendmessage(panel1.handle, WM_SYSCOMMAND, SC_DRAGMOVE, 0);
45 end;
46
47 { TPanel }
48
49 procedure TPanel.WMExitSizeMove(var message: TMessage);
50 begin
51 Left := Left + 1;
52 Left := Left - 1;
53 end;
54
55 end.
|