Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>To handle the windows messages on a FMX form you can override the <code>WndProc</code> of the Form using the <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms633584%28v=vs.85%29.aspx" rel="nofollow"><code>GetWindowLong</code></a> and <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms633591%28v=vs.85%29.aspx" rel="nofollow"><code>SetWindowLong</code></a> functions.</p> <p>Try this sample</p> <pre><code>uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls, Winapi.Messages, Winapi.Windows, Winapi.ShellAPI, FMX.Platform.Win; const WM_ICONTRAY = WM_USER + 1; type TForm14 = class(TForm) Button1: TButton; procedure FormCreate(Sender: TObject); procedure Button1Click(Sender: TObject); private OrgWndProc: Pointer; NewWndProc: Pointer; TrayIconData: TNotifyIconData; procedure _WndProc(var Message: TMessage); public { Public declarations } end; var Form14: TForm14; implementation {$R *.fmx} procedure TForm14.Button1Click(Sender: TObject); begin Shell_NotifyIcon(NIM_ADD, @TrayIconData); end; procedure TForm14._WndProc(var Message: TMessage); begin if Message.MSG=WM_ICONTRAY then begin case Message.LParam of WM_LBUTTONDOWN: ShowMessage('LBUTTON'); WM_RBUTTONDOWN: ShowMessage('RBUTTON'); else Message.Result:=CallWindowProc(OrgWndProc, FmxHandleToHWND(Self.Handle), Message.MSG, Message.WParam, Message.LParam); end; end else Message.Result:=CallWindowProc(OrgWndProc, FmxHandleToHWND(Self.Handle), Message.MSG, Message.WParam, Message.LParam); end; procedure TForm14.FormCreate(Sender: TObject); var LInstance : Pointer; begin //get the current WndProc OrgWndProc:= Pointer(GetWindowLong(FmxHandleToHWND(Self.Handle), GWL_WNDPROC)); //Convert the class method to a Pointer LInstance:=MakeObjectInstance(_WndProc); //set the new WndProc NewWndProc:= Pointer(SetWindowLong(FmxHandleToHWND(Self.Handle), GWL_WNDPROC, IntPtr(LInstance))); with TrayIconData do begin cbSize := SizeOf; Wnd := FmxHandleToHWND(self.Handle); uID := 0; uFlags := NIF_MESSAGE + NIF_ICON + NIF_TIP; uCallbackMessage := WM_ICONTRAY; hIcon := GetClassLong(FmxHandleToHWND(self.Handle), GCL_HICONSM); StrPCopy(szTip, 'testapp'); end; end; end. </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload