[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2001-08-23
7
Medium Priority
?
243 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 200 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month20 days, 8 hours left to enroll

868 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