Solved

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

Posted on 2001-08-23
7
231 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 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

14 Experts available now in Live!

Get 1:1 Help Now