小
小唐
Unregistered / Unconfirmed
GUEST, unregistred user!
program Project1;<br><br>uses<br> Forms,<br> Windows,<br> Unit1 in 'Unit1.pas' {Form1};<br><br>{$R *.RES}<br><br>var<br> hMutex : Thandle;<br> WaitResult : word;<br> BroadcastList : DWORD;<br> MessageID : DWORD;<br><br>begin<br> MessageID := RegisterWindowMessage('Check For Choice Previous Inst');<br> hMutex := createMutex(nil,false,pchar('App_Choice'));<br> WaitResult := WaitForSingleObject(hMutex,10);<br> if (waitResult=WAIT_TIMEOUT) then<br> begin<br> BroadcastList :=BSM_APPLICATIONS;<br> BroadcastSystemMessage(BSF_POSTMESSAGE,@BroadcastList,MessageID,0,0);<br> end<br> else<br> begin<br> Application.Title := 'Choice Organics Purchase & Sales System';<br> Application.Initialize;<br> Application.CreateForm(TForm1, Form1);<br> Application.Run;<br> ReleaseMutex(hMutex);<br> end;<br> CloseHandle(hMutex);<br>end.<br>{<br><br> Application.Initialize;<br> Application.CreateForm(TForm1, Form1);<br> Application.Run;<br>end.}<br><br>///////////////////////////////////////////////////////////////<br>///////////////////////////////////////////////////////////////<br><br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;<br><br>type<br> TForm1 = class(TForm)<br> procedure FormCreate(Sender: TObject);<br> private<br> { Private declarations }<br>// MessageID : DWORD;<br> procedure OnAppMessage(var Msg : TMsg ; Var Handled : Boolean);<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.DFM}<br><br>procedure TForm1.OnAppMessage(var Msg : TMsg ; Var Handled : Boolean);<br>begin<br>if Msg.Message =MessageID then<br> begin<br> show;<br> WindowState := wsMaximized;<br> BringToFront;<br> SetFocus;<br> Handled := true;<br> end;<br>end;<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br> Application.OnMessage:= OnAppMessage;<br>end;<br><br><br>end.<br><br>程序能够运行,但是达不到我要的效果,我想达到像winamp那样的效果:<br>当程序被最小化时,再次双击桌面上的图标时,就会将最小化的程序激活并恢复成原样。