Default
Google

How can I lock my form to a certain size and position?

Applies To: C++Builder 1 or higher
Category: Knowledge Base

I would like to always keep my form's size and position. Is it possible to prevent the user from dragging or resizing my form?
 
 1.
  Start a new project using File | New Application.
 
 2.
  Edit the OnShow event of your form:
 
void __fastcall TForm1::FormShow(TObject *Sender)
{
    HMENU menu;
    // Get the handle of the system menu
    menu = GetSystemMenu(Handle, 0);
    // Remove some items
    DeleteMenu(menu, SC_SIZE, MF_BYCOMMAND);
    DeleteMenu(menu, SC_MOVE, MF_BYCOMMAND);
}
 
When Windows determines if you can resize or move your form, it checks if the Move and Size menu items are available in the system menu of your window. So you'll have to remove these items by using DeleteMenu.

C++Builder Developer's Network
Copyright © Yoto Yotov



Acquiring image from ProHosting Banner Exchange