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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Make a form unmovable

Status
Not open for further replies.

vincentw56

IS-IT--Management
Oct 10, 2002
47
US
What is the best way to make a form unmovable. I have an MDI app. When I call a child window, I want it to be centered (which is not a problem), but I want it to be stationary and not have the user be able to move it. Thanks.

Vincent
 
Vincent,

The easiest way I've found is to remove the Move command from the Menu. Here's a crude way to do this:

Code:
procedure TForm1.FormCreate(Sender: TObject);
var
   h : HMenu;
begin
   h := getSystemMenu( Handle, FALSE );
   DeleteMenu( h, 1, MF_BYPOSITION );
end;

Now, I call this crude because it removes the command entirely (when you really should disable the command instead of removing it) and there's nothing verifying that the second command on the form's System menu is the Move command.

However, it does prevent the form from being moved.

Parenthetically, I should mention that I ususally don't like this sort of behavior in an application, for it overrides basic functionality most users expect. Thus, I would caution you to use this sparingly.

I'm sure there's a good reason why you want to do this, but
I would ask you to think twice before distributing an application that works significantly differently than any other Windows application your user's work with.

Hope this helps...

-- Lance
 
Are you using this window to show progress? If so, you can have a non MDI-child form and use ShowModal on it.

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top