How to Disable the Move System Menu Item?

Posted by Andreas Rejbrand on Stack Overflow See other posts from Stack Overflow or by Andreas Rejbrand
Published on 2010-04-08T18:15:26Z Indexed on 2010/04/08 19:33 UTC
Read the original article Hit count: 347

Filed under:
|
|

In Microsoft Windows, this works:

 mnu := GetSystemMenu(h, false);
 EnableMenuItem(mnu, SC_CLOSE, MF_BYCOMMAND or MF_GRAYED);

But this does not work:

 mnu := GetSystemMenu(h, false);
 EnableMenuItem(mnu, SC_MOVE, MF_BYCOMMAND or MF_GRAYED);

Hence I know how to disable the "Close" system menu item of a window, but not the "Move" item. How do I do that?

Update

Of course one alternative to using the very nice function EnableMenuItem, is to use SetMenuItemInfo:

  FillChar(info, sizeOf(info), 0);
  with info do
  begin
    cbSize := sizeOf(info);
    fMask := MIIM_STATE;
    fState := MFS_GRAYED;
  end;
  SetMenuItemInfo(mnu, SC_MOVE, false, info);

But this again works perfectly for SC_CLOSE, but not at all for SC_MOVE!

© Stack Overflow or respective owner

Related posts about winapi

Related posts about win32