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 limit MDI child form movement to the client area of the MDI parent form 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
21-Oct-02
Category
Others
Language
Delphi 2.x
Views
173
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius

Is it possible to limit the MDI client form movement, so that the form cannot be 
moved outside the client area of the MDI form?

Answer:

Yes, you can handle the WM_WINDOWPOSCHANGING message in the child forms and modify 
the message parameters if needs be to keep the child fully visible. Of course this 
is a breach of the standard Windows behaviour.

1   private {in form declaration}
2   
3   procedure WMWINDOWPOSCHANGING(var msg: TWMWINDOWPOSCHANGING);
4     message WM_WINDOWPOSCHANGING;
5   
6   procedure TForm1.WMWINDOWPOSCHANGING(var msg: TWMWINDOWPOSCHANGING);
7   var
8     r: TRect;
9   begin
10    with msg.Windowpos^ do
11    begin
12      if (flags and SWP_NOMOVE) = 0 then
13      begin
14        r := GetClientrect(Application.Mainform.handle, r);
15        if x < 0 then
16          x := 0;
17        if y < 0 then
18          y := 0;
19        if (x + cx) > r.right then
20          x := r.right - cx;
21        if (y + cy) > r.bottom then
22          y := r.bottom - cy;
23      end;
24      inherited;
25    end;
26  end;


			
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