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 open forms automatically when the Desktop size changes 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
03-Oct-02
Category
VCL-Forms
Language
Delphi 2.x
Views
136
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius

I have created a form which is snapped to the top of the screen. When I change the 
size of the Windows Desktop, the visible form isn't resized accordingly.

Answer:

I use the following code and it works quite good, even if the desktop size is 
changed:

1   type
2     TForm1 = class(TForm)
3     private
4       procedure WMWindowPosChanging(var message: TWMWindowPosMsg);
5         message WM_WINDOWPOSCHANGING;
6   
7       { ... }
8   
9   implementation
10  
11  { ... }
12  
13  var
14    WorkAreaRect: TRect;
15    NewWorkAreaFlag: Boolean;
16  
17    { ... }
18  
19  procedure TForm1.WMWindowPosChanging(var message: TWMWindowPosMsg);
20  begin
21    if (WindowState <> wsMaximized) then
22    begin
23      if (message.WindowPos.Flags and SWP_NOMOVE) = 0 then
24      begin {form is moved}
25        if NewWorkAreaFlag then
26        begin {workarea might have changed since last call}
27          SystemParametersInfo(SPI_GETWORKAREA, 0, @WorkAreaRect, 0);
28        end;
29        {snap form to border here, something 
30  			like Message.WindowPos.X := WorkAreaRect.Left if near to left border}
31        { ... }
32      end;
33      NewWorkAreaFlag := ((message.WindowPos.Flags and (SWP_NOMOVE or SWP_NOSIZE)) <>
34        0);
35      {True if form was (probably) dropped => get workarea again}
36    end;
37  end;
38  
39  { ... }
40  
41  initialization
42    NewWorkAreaFlag := True;


			
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