How to tell if a TPanel is moved outside the visible part of a TForm (Views: 29)
Problem/Question/Abstract: 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: unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ComCtrls, StdCtrls, ExtCtrls; type TPanel = class(ExtCtrls.TPanel) private procedure WMExitSizeMove(var message: TMessage); message WM_EXITSIZEMOVE; end; TForm1 = class(TForm) StatusBar: TStatusBar; Button1: TButton; OpenDialog1: TOpenDialog; Label1: TLabel; ComboBox1: TComboBox; CheckBox1: TCheckBox; Panel1: TPanel; procedure Panel1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.DFM} procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); const SC_DRAGMOVE = $F012; begin Mouse.Capture := 0; sendmessage(panel1.handle, WM_SYSCOMMAND, SC_DRAGMOVE, 0); end; { TPanel } procedure TPanel.WMExitSizeMove(var message: TMessage); begin Left := Left + 1; Left := Left - 1; end; end. |