Главная страница | назад

Article #17497: How to disable a system menu item

 Question and Answer Database

FAQ2497C.txt   How to disable a system menu item
Category   :Windows API
Platform    :All
Product    :C++Builder  ALL

How do I disable a system menu?

Throw a TCheckBox on a TForm, double click it, and put this in the event

void __fastcall TForm1::CheckBox1Click(TObject *Sender)
  // The default menu items are SC_MOVE, SC_SIZE, and SC_CLOSE
  TCheckBox * cb = dynamic_cast(Sender);
  if (cb)
    HMENU systemMenu = GetSystemMenu(Handle, FALSE);
    UINT how = cb->Checked ? MF_ENABLED : MF_GRAYED;
    EnableMenuItem(systemMenu, SC_CLOSE, MF_BYCOMMAND|how);

7/2/98 10:32:32 AM

Last Modified: 01-SEP-99