Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to Resize a TForm in steps Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
28-Oct-02
Category
VCL-Forms
Language
Delphi 2.x
Views
69
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius

How can I resize a form in steps, not smooth, like the Object Inspector in Delphi?

Answer:

First, declare a message handler for the WM_SIZING message in your form:

1   TForm1 = class(TForm)
2     { ... }
3   protected
4     procedure WmSizing(var Msg: TMessage); message WM_SIZING;
5     { ... }
6   end;
7   
8   //Then define the WmSizing message handler like so:
9   
10  procedure TForm1.WmSizing(var Msg: TMessage);
11  const
12    STEP = 20;
13  var
14    Side: LongInt;
15    Rect: PRect;
16  begin
17    inherited;
18    Side := Msg.WParam;
19    Rect := PRect(Msg.LParam);
20    if (WMSZ_BOTTOM and Side = WMSZ_BOTTOM) then
21      Rect^.Bottom := Rect^.Bottom - (Rect^.Bottom mod STEP);
22    if (WMSZ_BOTTOMLEFT and Side = WMSZ_BOTTOMLEFT) then
23    begin
24      Rect^.Bottom := Rect^.Bottom - (Rect^.Bottom mod STEP);
25      Rect^.Left := Rect^.Left - (Rect^.Left mod STEP);
26    end;
27    if (WMSZ_BOTTOMRIGHT and Side = WMSZ_BOTTOMRIGHT) then
28    begin
29      Rect^.Bottom := Rect^.Bottom - (Rect^.Bottom mod STEP);
30      Rect^.Right := Rect^.Right - (Rect^.Right mod STEP);
31    end;
32    if (WMSZ_LEFT and Side = WMSZ_LEFT) then
33      Rect^.Left := Rect^.Left - (Rect^.Left mod STEP);
34    if (WMSZ_RIGHT and Side = WMSZ_RIGHT) then
35      Rect^.Right := Rect^.Right - (Rect^.Right mod STEP);
36    if (WMSZ_TOP and Side = WMSZ_TOP) then
37      Rect^.Top := Rect^.Top - (Rect^.Top mod STEP);
38    if (WMSZ_TOPLEFT and Side = WMSZ_TOPLEFT) then
39    begin
40      Rect^.Top := Rect^.Top - (Rect^.Top mod STEP);
41      Rect^.Left := Rect^.Left - (Rect^.Left mod STEP);
42    end;
43    if (WMSZ_TOPRIGHT and Side = WMSZ_TOPRIGHT) then
44    begin
45      Rect^.Top := Rect^.Top - (Rect^.Top mod STEP);
46      Rect^.Right := Rect^.Right - (Rect^.Right mod STEP);
47    end;
48    Msg.Result := 1;
49  end;


You can adjust the STEP constant to meet your needs. Likewise, you can make any edge a constant size simply by assigning a valueto it.

			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC