Solved

How do I detect if a Form or Windows has moved position ?

Posted on 2001-08-23
7
234 Views
Last Modified: 2010-08-05
I have two forms, a menu and a mainform which displays multiple forms within it.

If I move the Mainform, I want the Menu Form to move as well.

How Do I detect if the MainForm has moved, which event would I use ?

Hopefully this one's easy,

Thanks in advance.

pjelias
0
Comment
Question by:pjelias
  • 3
  • 3
7 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6421020
0
 
LVL 4

Expert Comment

by:jeurk
ID: 6425301
Hi,
I suggest you use
      procedure WMWINDOWPOSCHANGING
            (Var Msg: TWMWINDOWPOSCHANGING);
             message WM_WINDOWPOSCHANGING;

that is even more precise...
John.
0
 

Author Comment

by:pjelias
ID: 6427267
John,

when / how do you use the above procedure ?

Could you provide some sample code ?

Thanks
0
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 

Author Comment

by:pjelias
ID: 6427315
John,

I want to be able to detect if a window/form has been moved via dragging the window with a mouse.

Therefore where/how would I use the procedure ?

The help is on WM_WINDOWPOSCHANGING is not very useful.

ps. I am using Delphi 6.
0
 
LVL 4

Accepted Solution

by:
jeurk earned 50 total points
ID: 6428127
Maybe it's not what you want to do becasue maybe you don't have access to the form you want to snoop...
But if what you want to do is make your menu form follow the movement of your main form, the you just do it like that:
in your main form, add
  private
      procedure WMWINDOWPOSCHANGING
            (Var Msg: TWMWINDOWPOSCHANGING);
             message WM_WINDOWPOSCHANGING;

and implement it like that:
procedure TForm3.WMWINDOWPOSCHANGING(var Msg: TWMWINDOWPOSCHANGING);
begin
  if Assigned(MenuForm) then MenuForm.SetBounds(Left+Width,Top,Width,Height);
end;

You can use the values you want in setbounds, I mean choose them ;)
You don't need to touch to the menu form...

this is also working with     procedure MoveForm(var Message: TMessage); message WM_MOVE;

The difference I think is that WMWINDOWPOSCHANGING gets the event before the form is moving...

by itself, Meikl's answer was correct, but a sample would have helped...
Let me know if this works and if this is what you wanted...

john.
0
 

Author Comment

by:pjelias
ID: 6430306
Perfect,

the WM_MOVE was used as it is used after Window has Moved,WMWINDOWPOSCHANGING works before WIndows has moved, implemented in code and all works well.

Thanks
0
 
LVL 4

Expert Comment

by:jeurk
ID: 6430891
Great,
See you in another thread.
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question