Solved

Following a TForm on screen

Posted on 2001-08-17
8
245 Views
Last Modified: 2010-04-06
I need a way to follow a TForm object (Main window) on the screen so that another TForm object (Secondary Window) can follow the first one... I see two ways to do this:

1- I could try to find an event that is called everytime the Main window moves and move my secondary window according to that,

or

2- Set my second window as a child of the Main window. To do this, I would have to find a way to keep this window over every other controls at anytime.

How can I do any of  this?

GunDamn
0
Comment
Question by:comptebidon81
  • 5
  • 2
8 Comments
 
LVL 40

Expert Comment

by:RQuadling
Comment Utility
You could try docking them? (Does that work outside the form? Try NOT using the docking manager)

Or, in the onMouseMove event for one form, position the second form (just like your first suggestion).

Regards,

Richard Quadling.
0
 
LVL 1

Accepted Solution

by:
sundayboys earned 150 total points
Comment Utility
Main window moves Message:WM_WINDOWPOSCHANGED
0
 

Author Comment

by:comptebidon81
Comment Utility
sundayboys:
everything works fine except the left property of the form is never updated!
Any idea?

GunDamn
0
 

Author Comment

by:comptebidon81
Comment Utility
Richard Quadling:
I dont have any "spot" where I could dock the form, it has to be over the other controls. And the OnMouseMove is not called on the form for the title bar.

Has I said, I tried the WM_WINDOWPOSCHANGED. It works but I still can't find the way to get the left property at runtime. It keeps giving me the left value I gave to my window in design.

What's going on?
GunDamn
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 40

Expert Comment

by:RQuadling
Comment Utility
If the one form is over the other and you want to keep it that way, it sounds like you should be using MDI.

Is the one form acting as a container for the other? If so, then this is the behaviour for MDI.

I created a little form with a label and a timer.

The timer is set to an interval of 10 milliseconds.

The timer event is ...

procedure TForm1.Timer1Timer(Sender: TObject);
begin
Label1.Caption := IntToStr(Form1.Left);
end;

When I move the form with the mouse, the label changes fine.

Added a button.

procedure TForm1.Button1Click(Sender: TObject);
begin
     Form1.Left := Form1.Left + 16;
end;

Still works.

What are you using to get the Left value of the form?

Regards,

Richard Quadling.
0
 

Author Comment

by:comptebidon81
Comment Utility
I simply do MyForm.Left
Is there any property that could cause this behaviour?

To be more precise, I "recreated" a combobox using an edit box and a ListBox. My second form only contain this ListBox. So I Don't see why I would have to use MDI forms. It would work fine if only I could get the top and left properties of my main form.
GunDamn
0
 

Author Comment

by:comptebidon81
Comment Utility
Grrrrr....

I just realize my error.
I added a inherited at the beginning of the message....

Well! It works now! your answer was brief, but still, it works now!
thanks, Gundamn
0
 

Author Comment

by:comptebidon81
Comment Utility
Thaks again!
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 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

11 Experts available now in Live!

Get 1:1 Help Now