?? chain_server_main.pas
字號:
unit Chain_Server_Main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls,shellapi, StdCtrls, Menus;
const
ICON_ID = 1; // 圖標(biāo)在本應(yīng)用程序中的編號
CM_nTaskIcoMsg = WM_USER + 78; //托盤圖標(biāo)返回消息
MM_SHOW = WM_USER + 199; //托盤圖標(biāo)返回消息
type
Tfrm_Chain_Server_Main = class(TForm)
Panel1: TPanel;
Label1: TLabel;
Timer1: TTimer;
MainMenu1: TMainMenu;
status1: TMenuItem;
PopupMenu1: TPopupMenu;
Show1: TMenuItem;
N1: TMenuItem;
About1: TMenuItem;
N2: TMenuItem;
Close1: TMenuItem;
procedure FormCreate(Sender: TObject);
procedure status1Click(Sender: TObject);
procedure N1Click(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure Show1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Close1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Panel1Click(Sender: TObject);
procedure About1Click(Sender: TObject);
private
{Private declarations }
FpNotify : PNotifyIconDataA;
Index:Integer;
procedure OnMinimize(Sender: TObject); //定義托盤圖標(biāo)結(jié)構(gòu)
procedure TaskIcoMsgDo(var Msg : TMessage); Message CM_nTaskIcoMsg;
procedure MMSHOW(var Msg : TMessage); Message MM_SHOW;
procedure WMHotKey(var message:TMessage);message WM_HotKey;
public
{ Public declarations }
end;
var
frm_Chain_Server_Main: Tfrm_Chain_Server_Main;
IconData: TNotifyIconData;
tags:boolean;
implementation
{$R *.dfm}
Const Tips='[連鎖管理。。。 服務(wù)器]';
procedure Tfrm_Chain_Server_Main.OnMinimize(Sender: TObject);
begin
if IsWindowEnabled(Handle) then
begin
Hide;
end;
end;
procedure Tfrm_Chain_Server_Main.TaskIcoMsgDo(var Msg: TMessage);
Var P:TPoint;
begin
if not IsWindowEnabled(Handle) then
Exit;
if Msg.LParam = WM_LBUTTONDBLCLK then //雙擊圖標(biāo),顯示(隱藏)窗口
frm_Chain_Server_Main.Visible:=not frm_Chain_Server_Main.Visible;
if Msg.LParam = WM_RBUTTONUP then
begin //右鍵單擊,顯示菜單
GetCursorPos(P);
PopupMenu1.Popup(P.x, P.y);
end;
end;
procedure Tfrm_Chain_Server_Main.MMSHOW(var Msg: TMessage);
begin
Show1Click(Show1);
end;
procedure Tfrm_Chain_Server_Main.WMHotKey(var message: TMessage);
begin
Show1.Click;
end;
//******************************************************************************
procedure Tfrm_Chain_Server_Main.FormCreate(Sender: TObject);
begin
Index:=0;
Application.Title:=Tips;
Caption:=Application.Title;
Application.Icon.Handle:=LoadIcon(HInstance,'NEXT');
Icon.Assign(Application.Icon);
New(FpNotify);
with FpNotify^ do
begin
Wnd := Handle;
uID := 0;
uFlags := NIF_ICON + NIF_MESSAGE + NIF_TIP;
hIcon := Application.Icon.Handle;
uCallbackMessage := CM_nTaskIcoMsg;
StrPCopy(szTip,Tips);
end;
Shell_NotifyIcon(NIM_ADD, FpNotify);
//注冊任務(wù)欄圖標(biāo)。
Application.OnMinimize:=OnMinimize;
Application.ShowMainForm:=False;
RegisterHotKey(Handle,0,MOD_ALT or MOD_CONTROL,$41);
//注冊熱鍵。ALT_CTROL_BACKSPACE
end;
procedure Tfrm_Chain_Server_Main.status1Click(Sender: TObject);
begin
//status := not status;
//if status then status1.Caption := 'Enable'
//else status1.Caption := 'Disable';
end;
procedure Tfrm_Chain_Server_Main.N1Click(Sender: TObject);
begin
//UnInstallIcon;
// self.WindowState:=wsNormal;
//ShowWindow(Application.handle, SW_SHOWNORMAL);
end;
procedure Tfrm_Chain_Server_Main.FormDestroy(Sender: TObject);
begin
UnregisterHotKey(handle,0);
//釋放熱鍵。ALT_CTROL_BACKSPACE
Shell_NotifyIcon(NIM_DELETE, FpNotify);
//釋放任務(wù)欄圖標(biāo)。
end;
procedure Tfrm_Chain_Server_Main.N2Click(Sender: TObject);
begin
Close;
system.Halt;
end;
procedure Tfrm_Chain_Server_Main.Show1Click(Sender: TObject);
begin
frm_Chain_Server_Main.Visible:=not frm_Chain_Server_Main.Visible;
end;
procedure Tfrm_Chain_Server_Main.Timer1Timer(Sender: TObject);
begin
if Index=0 then
begin
Application.Icon.Handle:=LoadIcon(HInstance,'NEXT');
Index:=1;
end else
begin
Application.Icon.Handle := LoadIcon(HInstance,'MAINICON');
Index:=0;
end;
Icon.Assign(Application.Icon);
with FpNotify^ do
begin
Wnd := Handle;
uID := 0;
uFlags := NIF_ICON + NIF_MESSAGE + NIF_TIP;
hIcon := Application.Icon.Handle;
//hIcon := Application.Icon.Handle;
uCallbackMessage := CM_nTaskIcoMsg;
StrPCopy(szTip,Tips);
end;
Shell_NotifyIcon(NIM_MODIFY, FpNotify);
end;
procedure Tfrm_Chain_Server_Main.Close1Click(Sender: TObject);
begin
Close;
end;
procedure Tfrm_Chain_Server_Main.FormShow(Sender: TObject);
begin
Application.Restore;
end;
procedure Tfrm_Chain_Server_Main.Panel1Click(Sender: TObject);
begin
frm_Chain_Server_Main.Visible:=not frm_Chain_Server_Main.Visible;
end;
procedure Tfrm_Chain_Server_Main.About1Click(Sender: TObject);
begin
Application.MessageBox('[連鎖管理系統(tǒng)]由四川蓋達(dá)爾研制!'+#13#10+'服務(wù)器模塊,請勿關(guān)閉!','[連鎖管理系統(tǒng)]',mb_ok);
end;
end.
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -