Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I check if my application has moved 3

Status
Not open for further replies.

NeilP

Programmer
Feb 11, 2001
12
GB
Does anyone know how to prevent a user dragging a form to a new position on the screen. Is there a way of locking the cordinates without having to get rid of the title bar?

If not, is there a way of detecting if your application has been dragged and dropped to a new position?

Thanks in advance
Neil P
 
Hi NeilP,

What you do is you write the installation path to the directory and check it with "Application.ExeName;".

I hope this helps, BobbaFet

Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com

&quot;<beer brand> is like making love in a cano...
it's <f-word + ing> close to water !!!&quot;
- Monty Python's Flying Circus, 1969/70
 
Since TForm doesn't have an event handler for the form's movement, you have to manually trap the movement message yourself.

Declare a new method:
Code:
procedure FormMove(var Msg: TMessage); message WM_EXITSIZEMOVE;
(This method will execute everytime your window receives a WM_EXITSIZEMOVE message, which occurs after a resizing/moving of the form.)

Store the initial Top/Left values of your form on startup, and your FormMove method will just be:
Code:
procedure TForm1.FormMove(var msg: TMessage);
begin
        Form1.Left := initialLeftPos;
        Form1.Top := initialTopPos;
end;
This won't actually stop the form from being moved around, but as soon as the user releases the mouse button and stops dragging the form it will snap back to its original position.
 
Sorry about that guys,

Guess i was drunk or sumptin'. Totally misread your
question. BobbaFet

Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com

&quot;<beer brand> is like making love in a cano...
it's <f-word + ing> close to water !!!&quot;
- Monty Python's Flying Circus, 1969/70
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top