Solved

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

Posted on 2001-08-23
7
232 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi 10 Seattle Dataset Actions 5 79
Sending Gmail through Delphi 3 91
Making delphi communicate with a c# service 16 89
can't find the executable in Simulator 1 80
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

911 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now