applied menu fix from Micha Nelissen

git-svn-id: trunk@4301 -
This commit is contained in:
mattias 2003-06-24 08:32:03 +00:00
parent d98a5ac0ca
commit 6bb58b5c11

View File

@ -227,15 +227,15 @@ Procedure TWin32Object.SetLabel(Sender: TObject; Data: Pointer);
cbsize:=sizeof(MENUITEMINFO); cbsize:=sizeof(MENUITEMINFO);
{In Win32 Menu items that are created without a initial caption default to disabled, {In Win32 Menu items that are created without a initial caption default to disabled,
the next three lines are to counter that.} the next three lines are to counter that.}
fMask:=MIIM_STATE; fMask:=MIIM_STATE or MIIM_TYPE or MIIM_ID;
GetMenuItemInfo((Sender as TMenuItem).Parent.Handle, integer((Sender as TMenuItem).Handle), false, @MenuInfo); GetMenuItemInfo((Sender as TMenuItem).Parent.Handle, integer((Sender as TMenuItem).Handle) and $FFFF, false, @MenuInfo);
if (Sender as TMenuItem).Enabled then fState := fState and (not (MFS_DISABLED or MFS_GRAYED)); if (Sender as TMenuItem).Enabled then fState := fState and (not (MFS_DISABLED or MFS_GRAYED));
fMask:=MIIM_TYPE or MIIM_STATE; fMask:=MIIM_TYPE or MIIM_STATE;
fType:=Style; fType:=Style;
dwTypeData:=Data; dwTypeData:=Data;
end; end;
SetMenuItemInfo((Sender as TMenuItem).Parent.Handle, integer((Sender as TMenuItem).Handle), false, @MenuInfo); SetMenuItemInfo((Sender as TMenuItem).Parent.Handle, integer((Sender as TMenuItem).Handle) and $FFFF, false, @MenuInfo);
DrawMenuBar(((Sender as TMenuItem).Owner as TWinControl).Handle); DrawMenuBar(((Sender as TMenuItem).Owner as TWinControl).Handle);
End; End;
@ -2591,11 +2591,11 @@ Begin
cbSize:=sizeof(MENUITEMINFO); cbSize:=sizeof(MENUITEMINFO);
fMask:=MIIM_SUBMENU; fMask:=MIIM_SUBMENU;
end; end;
GetMenuItemInfo(ParentOfParent, ParentMenuHandle, false, @MenuInfo); GetMenuItemInfo(ParentOfParent, (ParentMenuHandle) and $FFFF, false, @MenuInfo);
if MenuInfo.hSubmenu=0 then // the parent menu item is not yet defined with submenu flag if MenuInfo.hSubmenu=0 then // the parent menu item is not yet defined with submenu flag
begin begin
MenuInfo.hSubmenu:=ParentMenuHandle; MenuInfo.hSubmenu:=ParentMenuHandle;
SetMenuItemInfo(ParentOfParent, ParentMenuHandle, false, MenuInfo); SetMenuItemInfo(ParentOfParent, Integer(ParentMenuHandle) and $FFFF, false, MenuInfo);
end; end;
end; end;
@ -2607,7 +2607,7 @@ Begin
fMask:=Mask; fMask:=Mask;
fType:=Style; fType:=Style;
{fState:=MFS_ENABLED;} {not needed} {fState:=MFS_ENABLED;} {not needed}
wID:=integer(MenuHandle); wID:=integer(MenuHandle) and $FFFF; {value is only 16 bit wide!}
hSubmenu:=MenuHandle; hSubmenu:=MenuHandle;
{hbmpChecked:=0; {hbmpChecked:=0;
hbmpUnchecked:=0;} {not needed} hbmpUnchecked:=0;} {not needed}
@ -2615,7 +2615,7 @@ Begin
{dwTypeData:=LPSTR((Sender as TmenuItem).Caption);} {dwTypeData:=LPSTR((Sender as TmenuItem).Caption);}
{cch:=length((Sender as TMenuItem).Caption);} {not needed} {cch:=length((Sender as TMenuItem).Caption);} {not needed}
end; end;
InsertMenuItem(ParentMenuHandle, 0, false, @MenuInfo); InsertMenuItem(ParentMenuHandle, -1, true, @MenuInfo);
if (Sender as TMenuItem).ShortCut <> 0 then if (Sender as TMenuItem).ShortCut <> 0 then
begin begin
Msg.Handle:=MenuHandle; Msg.Handle:=MenuHandle;
@ -2659,6 +2659,9 @@ End;
{ {
$Log$ $Log$
Revision 1.52 2003/06/24 08:32:03 mattias
applied menu fix from Micha Nelissen
Revision 1.51 2003/03/25 08:12:39 mattias Revision 1.51 2003/03/25 08:12:39 mattias
patch from Martin Smat for menu items and default messages patch from Martin Smat for menu items and default messages