I am creating a notifyIcon for my program, in the future it would be os independant but for now i am writing the win-32 part.
When i show a popupmenu after receiving a WM_RBUTTONDOWN message, i show a menu, but this menu is behind the taskbar. how to create a regular menu that would be in front of the taskbar?
The problem lies in the fmx.popupmenu, is it wrong to assume it has the same behaviour as VCL.popupmenu?
Edited code :
{$IFDEF MSWINDOWS}
Tray:=TPWTrayIcon.Create((handle));
{$ENDIF MSWINDOWS}
Tray.popupmenu:=pmTray;
constructor TPWTrayIcon.Create(pHANDLE:TFMXHandle);
Var
HIco: HICON;
p:tMenuitem;
begin
{$IFDEF MSWINDOWS}
FHandle := AllocateHWnd(HandleIconMessage);
AHandle := FmxHandleToHWND(pHandle);
try
Hico:= LoadIcon(MainInstance,'MAINICON');
tIcon.cbSize := sizeof(tIcon);//TNotifyIconData);
with tIcon do begin
Wnd := FHandle;
uID := 123;
//guidItem:=123;
uFlags := NIF_ICON or NIF_MESSAGE or NIF_GUID or NIF_TIP;
uCallbackMessage := WM_NOTIFYICON;
hIcon := HIco;
uVersion:=NOTIFYICON_VERSION_4;
end;
Shell_NotifyIcon(NIM_ADD, @tIcon);
Shell_NotifyIcon(NIM_SETVERSION, @tIcon);
except
end;
{$ENDIF MSWINDOWS}
end;
procedure TPWTrayIcon.HandleIconMessage(var Msg: TMessage);
var
tmpPoint:TPoint;
begin
if Msg.Msg = WM_NOTIFYICON then begin
case LOWORD(Msg.LParam )of
WM_RBUTTONDOWN:
if Assigned(PopUp) then begin
Cardinal(tmpPoint):=(GetMessagePos);
{EDIT: the following doesnt work in Firemonkey}
//SetForegroundWindow(Application.Handle);
//Application.ProcessMessages;
if SetForegroundWindow(AHANDLE) then
Popup.Popup(tmpPoint.X,tmpPoint.Y);
end;
end;
end;
edit: Workaround:
Use VCL.Menu. instead of Firemonkey.menus