comptebidon81
asked on
Following a TForm on screen
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
sundayboys:
everything works fine except the left property of the form is never updated!
Any idea?
GunDamn
everything works fine except the left property of the form is never updated!
Any idea?
GunDamn
ASKER
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
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
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.
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:
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
begin
Form1.Left := Form1.Left + 16;
end;
Still works.
What are you using to get the Left value of the form?
Regards,
Richard Quadling.
ASKER
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
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
ASKER
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
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
ASKER
Thaks again!
Or, in the onMouseMove event for one form, position the second form (just like your first suggestion).
Regards,
Richard Quadling.