Title: Create a Sizeable Dialog (and also contains SizeGrip)
Question: How to create a sizeable dialog with sizegrip without using 3rd party component
Answer:
As I know, Delphi would not easy to create a sizable dialog like "File Open Dialog".
I just like to show you how to create a Sizeable Dialog with SizeGrip in Delphi.
I'm not print the sizegrip on the TForm.Canvas because don't want repaint the form everytime when user resizing the dialog.
ps. I'm using D6 and not sure D7 would have this feature already.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, ComCtrls;
type
TForm1 = class(TForm)
PaintBox1: TPaintBox;
procedure FormCreate(Sender: TObject);
procedure PaintBox1Paint(Sender: TObject);
private
protected
procedure CreateParams(var Params: TCreateParams); override;
procedure CreateWnd; override;
public
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
Params.Style := WS_CAPTION or WS_SIZEBOX or WS_SYSMENU;
Params.ExStyle := WS_EX_DLGMODALFRAME or WS_EX_WINDOWEDGE;
end;
procedure TForm1.CreateWnd;
begin
inherited CreateWnd;
SendMessage(Self.Handle, WM_SETICON, 1, 0);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
PaintBox1.Align := alRight;
PaintBox1.Width := 16;
end;
procedure TForm1.PaintBox1Paint(Sender: TObject);
begin
With PaintBox1 do
DrawFrameControl(Canvas.Handle,
Rect(Width - 15, Height - 15, Width, Height),
DFC_SCROLL,
DFCS_SCROLLSIZEGRIP );
end;
end.