delphi - What is the best way to reactivate an app running in the tray? -


I have a delphi app that reduces the tray icon. When the tray icon is double clicked, the app opens a non-modal user interface form.

I have argued to find out whether it is already going on or not. If she is not walking, then it starts and sets herself in the tray.

If it is already running, then I want to give it control over my first charge and open the non-modal form, and then get out (second example). What is the best way to do this?

TIA R

Microsoft's way is not innocent, so I like the old school I am:

const WM_KNOCK_KNOCK = WM_USER + 42; {Or WM_USER + 265} or you want any number, PSDK documentation why the WM_USER range} {or register WindowMessage} {...} process TMainForm.FormCreate (Sender: TObject) consult; War window: HWND; Start window: = Searchwidder (PChar ({MainForm.} Classname), zero); {I do not remember how it actually works and it's time to check now, so the quick and dirty validity test is as follows:} (not (handles allocated and (window = handle)), 'failed, Use Fallback;); {If the window & lt; & Gt; 0 Then start the post message (window, WM_KNOCKKK, 0, 0); Halt; End; {Regular initialization} end;

Now, the first example of WM_KNOCK_KNOCK message instances is wakeup routine.


I get a little hint that when you get WM_LBUTTONUP (or maybe WM_LBUTTONDBLCLK) in your Shell_NotifyIcon wrapper (application. Restore, maybe?). As such, Chris Thornton said, there is no such state as 'the tray is at least', it is artificial. Fallback: If the representation fails, note that the code depends only on the class function classname , so it is easily FormCreate And before the app makes it.


Comments