fix WindowProc now react on menu item click from Martin

git-svn-id: trunk@3819 -
This commit is contained in:
mattias 2003-01-19 10:57:46 +00:00
parent b66832a1e7
commit 3a9320b953
2 changed files with 24 additions and 10 deletions

View File

@ -72,6 +72,18 @@ Var
then ShowWindow(PageHandle, SW_SHOW)
else ShowWindow(PageHandle, SW_HIDE);
end;
function GetMenuItemObject: TObject;
var MenuInfo: MENUITEMINFO;
MainMenuHandle: HMENU;
begin
MainMenuHandle := GetMenu(Window);
MenuInfo.cbSize:=sizeof(MENUITEMINFO);
MenuInfo.fMask:=MIIM_DATA;
GetMenuItemInfo(MainMenuHandle, Lo(WParam), false, @MenuInfo);
Result := TObject(MenuInfo.dwItemData);
end;
Begin
Assert(False, 'Trace:WindowProc - Start');
@ -134,6 +146,7 @@ Begin
Case Hi(WParam) Of
0:
Begin
if LParam=0 then OwnerObject := GetMenuItemObject;
If ((OwnerObject Is TControl) And (Not (OwnerObject Is TButton))) Then
CallEvent(OwnerObject, TControl(OwnerObject).OnClick, Nil, etNotify)
Else If OwnerObject Is TMenuItem Then
@ -517,6 +530,9 @@ end;
{
$Log$
Revision 1.23 2003/01/19 10:57:46 mattias
fix WindowProc now react on menu item click from Martin
Revision 1.22 2002/12/28 09:42:12 mattias
toolbutton patch from Martin Smat

View File

@ -228,12 +228,7 @@ Procedure TWin32Object.SetLabel(Sender: TObject; Data: Pointer);
cbsize:=sizeof(MENUITEMINFO);
fMask:=MIIM_TYPE;
fType:=MFT_STRING;
end;
GetMenuItemInfo(FMenu, integer(MenuHandle), false, @MenuInfo);
with MenuInfo do
begin
dwTypeData:=Data;
cch:=lstrlen(Data);
end;
SetMenuItemInfo(FMenu, integer(MenuHandle), false, @MenuInfo);
DrawMenuBar(((Sender as TMenuItem).Owner as TWinControl).Handle);
@ -2548,7 +2543,7 @@ var MenuInfo: MENUITEMINFO;
Style: integer;
Mask: integer;
Begin
Mask := MIIM_TYPE or MIIM_ID;
Mask := MIIM_TYPE or MIIM_ID or MIIM_DATA;
if ((Sender as TMenuItem).Count > 0) then Mask := Mask or MIIM_SUBMENU;
if (Sender as TMenuItem).Caption = '-' then Style := MFT_SEPARATOR
else Style := MFT_STRING;
@ -2557,14 +2552,14 @@ Begin
cbsize:=sizeof(MENUITEMINFO);
fMask:=Mask;
fType:=Style;
fState:=MFS_ENABLED;
{fState:=MFS_ENABLED;} {not needed}
wID:=integer(MenuHandle);
hSubmenu:=MenuHandle;
hbmpChecked:=0;
hbmpUnchecked:=0;
{hbmpChecked:=0;
hbmpUnchecked:=0;} {not needed}
dwItemData:=integer(Sender);
dwTypeData:=LPSTR((Sender as TmenuItem).Caption);
cch:=length((Sender as TMenuItem).Caption);
{cch:=length((Sender as TMenuItem).Caption);} {not needed}
end;
ParentMenuHandle := (Sender as TMenuItem).Parent.Handle;
InsertMenuItem(ParentMenuHandle, 0, false, @MenuInfo);
@ -2605,6 +2600,9 @@ End;
{
$Log$
Revision 1.43 2003/01/19 10:57:46 mattias
fix WindowProc now react on menu item click from Martin
Revision 1.42 2003/01/12 19:09:19 mattias
patch from Martin Smat for dis/enabling menuitems