Mega Code Archive

 
Categories / Delphi / Forms
 

Resizable forms and size grip

Title: Resizable forms and size grip Question: How do I supply a visual cue that a form is resizable without using a status bar? Answer: When a form has a sizable border, ther is no default way to supply a visual cue but using a status bar. Luckily a window API may help us. The API in question is DrawFrameControl. How the name suggests, this API is used to draw the frame of various controls such as buttons, check boxes, menus and, yes, size grips just by supplying a display context and the proper flags. Here is a sample code on how to use this API in a regular Deplhi form with sizable border. unit TestForm; interface uses Windows, Forms; type TfrmTest = class(TForm) procedure FormResize(Sender: TObject); procedure FormPaint(Sender: TObject); private { Private declarations } public { Public declarations } end; var frmTest: TfrmTest; implementation {$R *.DFM} procedure TfrmTest.FormResize(Sender: TObject); begin Self.Repaint; end; procedure TfrmTest.FormPaint(Sender: TObject); var rectBounds: TRect; begin rectBounds := Self.ClientRect; with rectBounds do begin Left := Right - GetSystemMetrics(SM_CXVSCROLL); Top := Bottom - GetSystemMetrics(SM_CYVSCROLL); end; {Here is the magic!!} DrawFrameControl(Self.Canvas.Handle, rectBounds, DFC_SCROLL, DFCS_SCROLLSIZEGRIP); end; end.