?
Solved

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

Posted on 2001-08-23
7
Medium Priority
?
239 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month12 days, 10 hours left to enroll

777 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