Home > Back-end >  High post, how to, after the program runs and minimum into tray icon, double-click the program again
High post, how to, after the program runs and minimum into tray icon, double-click the program again

Time:10-13

High marks,
How to run the program and the minimum into tray icon, double-click the program again, minimize the original program activated, and in the front window. Note that is the point again to run the program icon, not tray icon, is once again to run the program icon, not tray icon, thank you!

CodePudding user response:

You use Delphi a few

CodePudding user response:

D7 sample, use the TTrayIcon
http://pan.baidu.com/share/link? Shareid=3394217811 & amp; UK=1124482001

CodePudding user response:

To run the program icon is again? What you mean? Send a figure up to look at it

CodePudding user response:

Isn't that just start an instance, the program startup testing some symbol, such as a semaphore, if any, that before the start, that in some way, such as user messages sent, notice an instance before activation, and then his exit,

CodePudding user response:

CodePudding user response:

Come to it from the Internet, haven't tried, you can consult:
The unit MultInst;

Interface

USES the
Windows, Messages, SysUtils, Classes, Forms;

Implementation

Const
='{2 STR_UNIQUE be6d96e bf9 - B33E - 8740412-827 - f - 4 cde96}';
MI_ACTIVEAPP=1;//activation application
MI_GETHANDLE=2;//handle

Var
IMessageID: Integer;
OldWProc: TFNWndProc;
MutHandle: THandle;
BSMRecipients: DWORD;

The function NewWndProc (Handle: HWND; Msg: Integer; WParam, lParam: Longint) :
Longint; Stdcall;
The begin
Result:=0;
If the Msg=iMessageID then
The begin
Case wParam of
MI_ACTIVEAPP://activation application
If lParam<> 0 then
The begin
//messages are received before the activation of an instance
//why are activated in another program?
//in the same process SetForegroundWindow does not transform form mentioned before the
If IsIconic (lParam) then
OpenIcon (lParam)
The else
The SetForegroundWindow (lParam);
//to terminate this instance
Application. The Terminate;
The end;
MI_GETHANDLE://program handles
The begin
PostMessage (HWND (lParam), iMessageID, MI_ACTIVEAPP,
Application. The Handle);
The end;
The end;
End
The else
Result:=CallWindowProc (OldWProc, Handle, Msg, wParam, lParam);
The end;

Procedure InitInstance.
The begin
//replace the application message processing
OldWProc:=TFNWndProc (SetWindowLong (Application. Handle, GWL_WNDPROC,
Longint (@ NewWndProc)));

//open the mutex
MutHandle:=OpenMutex (MUTEX_ALL_ACCESS, False, STR_UNIQUE);
If MutHandle=0 then
The begin
//build a mutex
MutHandle:=CreateMutex (nil, False, STR_UNIQUE);
End
The else begin
Application. ShowMainForm:=False;
//there has been a process instance, broadcast messages instance handle
BSMRecipients:=BSM_APPLICATIONS;
BroadCastSystemMessage (BSF_IGNORECURRENTTASK or BSF_POSTMESSAGE,
@ BSMRecipients, iMessageID MI_GETHANDLE, Application. The Handle);
The end;
The end;

Initialization
//register message
IMessageID: RegisterWindowMessage=(STR_UNIQUE);
InitInstance.

Finalization
//restore message processing
If OldWProc & lt;> Nil then
SetWindowLong (Application. Handle, GWL_WNDPROC LongInt (OldWProc));

//close the mutex
If MutHandle & lt;> 0 then the CloseHandle (MutHandle);

End.

CodePudding user response:

Try the original poster do as I say, a simple example, using cooltrayicon, this control is added in the main interface, and then in the main interface of the onclose event in writing action=canone can,
XE after high version, at the time of execution onclose, direct caminisize, cahide are to be set,

CodePudding user response:

Never see clear,,, I'm sorry I have, for example, send tomorrow, already in bed, ha ha