Creating of panel with resizing feature while run time

Please discuss general Delphi programming topics here.

Creating of panel with resizing feature while run time

Postby sekar1 » November 27th, 2007, 3:15 pm

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.
sekar1
Junior Member
Junior Member
 
Posts: 25
Joined: December 21st, 2006, 5:55 am

Postby Kambiz » December 1st, 2007, 3:47 am

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.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 7 guests

cron