2005. augusztus 21., vasárnap

How to remove a menu or submenu at runtime


Problem/Question/Abstract:

How to remove a menu or submenu at runtime

Answer:

Try these two procedures, i.e. RemoveMenu(form1.handle, 0) to remove the first menu:


procedure RemoveMenu(hwndMain: THandle; MenuIndex: Integer);
var
  h: HMenu;
begin
  h := GetMenu(hwndMain);
  if h > 0 then
    DeleteMenu(h, MenuIndex, MF_BYPOSITION);
end;

procedure RemoveSubmenu(hwndMain: THandle; MenuIndex, SubmenuIndex: Integer);
var
  h: HMenu;
begin
  h := GetMenu(hwndMain);
  if h > 0 then
    DeleteMenu(GetSubmenu(h, MenuIndex), SubmenuIndex, MF_BYPOSITION);
end;

Nincsenek megjegyzések:

Megjegyzés küldése