Making a Form Non-Moveable
< Continued from page 4
Here is how to keep the window from moving:
First, make the borderstyle something like bsDialog, so that the window cant be resized.
Next, add the following declaration to your form class:
Thats it. Easy as can be. The only problem with this is that you cant move the form if you want your code to. To get around this, just set up a Boolean variable called PosLocked, set it to True when you want to lock the forms position, and to false when you need to move the form (when your done, remember to set it back to true). Then to implement the proc above, just make it...
Delphi tips navigator:
» Execute the Windows Explorer Find File Dialog Box
« Select a block of code by column
Here is how to keep the window from moving:
First, make the borderstyle something like bsDialog, so that the window cant be resized.
Next, add the following declaration to your form class:
procedure PosChange(var Msg: TWmWindowPosChanging) ; message WM_WINDOWPOSCHANGING;//Implement the message handler as:procedure TForm1.PosChange(var Msg: TWmWindowPosChanging) ; begin Msg.WindowPos.x := Left; Msg.WindowPos.y := Top; Msg.Result := 0; end;
Thats it. Easy as can be. The only problem with this is that you cant move the form if you want your code to. To get around this, just set up a Boolean variable called PosLocked, set it to True when you want to lock the forms position, and to false when you need to move the form (when your done, remember to set it back to true). Then to implement the proc above, just make it...
if PosLocked thenbegin Msg.WindowPos.x := Left; Msg.WindowPos.y := Top; Msg.Result := 0; end else inherited;
Delphi tips navigator:
» Execute the Windows Explorer Find File Dialog Box
« Select a block of code by column
Source...