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 Snap a form to another one and move both around 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
102
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius

How do I get forms been redrawn while moving them? I need a form that snaps 
magnetically to another while moved, but there is no event! I've tried the message 
WM_WINDOWPOSCHANGING, but it's not possible to show when it fires, because the form 
is not redrawn, when moved.

Answer:

Note that MOPSChildForm is the "master" and SearchForm follows it around.
1   
2   procedure TMOPSChildForm.WMWindowPosChanging(var message: TWMWindowPosChanging);
3   var
4     Moving: Boolean;
5   begin
6     if SearchForm <> nil then
7     begin
8       with message.WindowPos^ do
9         Moving := (ComponentState * [csReading, csDestroying] = []) and (flags and
10          SWP_NOSIZE = 0)
11          and ((x <> Left) or (y <> Top));
12      inherited;
13      if Moving then
14        SearchForm.MoveWithForm(HostDockSite <> nil)
15    end;
16  end;
17  
18  procedure TMOPSSearch.MoveWithForm(Docked: Boolean);
19  const
20    DeltaX = 20; {Offset of this form from MOPSChildForm's TopLeft}
21    DeltaY = 40;
22  begin
23    if Docked then
24      with TForm(TForm(TForm(Owner).HostDockSite).Owner) do
25      begin
26        Self.Left := Left + DeltaX;
27        Self.Top := Top + DeltaY;
28      end
29    else
30      with TForm(Owner) do
31      begin
32        Self.Left := Left + DeltaX;
33        Self.Top := Top + DeltaY;
34      end;
35  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