Creating of panel with resizing feature while run time

Posted:
November 27th, 2007, 3:15 pm
by sekar1
hi all,
i av small GUI question. i want to create one panel, the width of the panel can be reszing (increased/decreased) by the user by mouse drag and move operation while run time.(For more inforamtion, i need the one exactly in powerpoint normal layout window).
I think it is a small property setting. but i am not awaring. please do provide the steps if you are known means.

Posted:
December 1st, 2007, 3:47 am
by Kambiz
In the following code, user can change width of the panel at run-time by drag and drop.
- Code: Select all
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;
type
TForm1 = class(TForm)
Panel1: TPanel;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
PanelOrgWndProc: TWndMethod;
procedure PanelNewWndProc(var Message: TMessage);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
PanelOrgWndProc := Panel1.WindowProc;
Panel1.WindowProc := PanelNewWndProc;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
Panel1.WindowProc := PanelOrgWndProc;
end;
procedure TForm1.PanelNewWndProc(var Message: TMessage);
const
Margin = 4;
var
Pt: TPoint;
begin
PanelOrgWndProc(Message);
if Message.Msg = WM_NCHITTEST then
begin
Pt := Panel1.ScreenToClient(SmallPointToPoint(TWMNCHitTest(Message).Pos));
if (Pt.Y >= 0) and (Pt.Y < Panel1.Height) then
begin
if (Pt.X >= 0) and (Pt.X < Margin) then
Message.Result := HTLEFT
else if (Pt.X < Panel1.Width) and (Pt.X > Panel1.Width - Margin) then
Message.Result := HTRIGHT;
end;
end;
end;
end.