mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 09:39:54 +02:00
LCL, Win32: fixed onUpdate event triggering of TAction and submenu item of TPopupMenu, patch by Henner Drewes, issue #28069
This commit is contained in:
parent
9e69dd9798
commit
e566a58336
@ -442,15 +442,31 @@ function TWindowProcHelper.GetPopMenuItemObject: TObject;
|
|||||||
var
|
var
|
||||||
MainMenuHandle: HMENU;
|
MainMenuHandle: HMENU;
|
||||||
MenuInfo: MENUITEMINFO;
|
MenuInfo: MENUITEMINFO;
|
||||||
|
PopupMenu: TPopupMenu;
|
||||||
begin
|
begin
|
||||||
|
Result := nil;
|
||||||
MenuInfo.cbSize := MMenuItemInfoSize;
|
MenuInfo.cbSize := MMenuItemInfoSize;
|
||||||
MenuInfo.fMask := MIIM_DATA;
|
MenuInfo.fMask := MIIM_DATA;
|
||||||
|
|
||||||
|
// first we have to decide if the command is from a popup menu
|
||||||
|
// or from the window main menu
|
||||||
|
// if the 'PopupMenu' property exists, there is a big probability
|
||||||
|
// that the command is from a popup menu
|
||||||
|
|
||||||
|
PopupMenu := WindowInfo^.PopupMenu;
|
||||||
|
if Assigned(PopupMenu) then
|
||||||
|
begin
|
||||||
|
MainMenuHandle := GetMenuParent(HMENU(WParam), PopupMenu.Handle);
|
||||||
|
if (MainMenuHandle <> 0) and GetMenuItemInfo(MainMenuHandle, LOWORD(LParam), true, @MenuInfo) then
|
||||||
|
begin
|
||||||
|
Result := TObject(MenuInfo.dwItemData);
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
MainMenuHandle := GetMenuParent(HMENU(WParam), GetMenu(Window));
|
MainMenuHandle := GetMenuParent(HMENU(WParam), GetMenu(Window));
|
||||||
if GetMenuItemInfo(MainMenuHandle, LOWORD(LParam), true, @MenuInfo) then
|
if GetMenuItemInfo(MainMenuHandle, LOWORD(LParam), true, @MenuInfo) then
|
||||||
Result := TObject(MenuInfo.dwItemData)
|
Result := TObject(MenuInfo.dwItemData);
|
||||||
else
|
|
||||||
Result := nil;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TWindowProcHelper.GetMenuItemObject(ByPosition: Boolean): TObject;
|
function TWindowProcHelper.GetMenuItemObject(ByPosition: Boolean): TObject;
|
||||||
|
Loading…
Reference in New Issue
Block a user