program Pontifex;uses
Forms,
Windows,
ShellAPI,
Messages,
Sysutils,
exSystem,
Pontifex_TLB in 'Pontifex_TLB.pas',
Server_CORBA in '..\2.program\0.服务器\Server_CORBA.pas' {CORBAServer_WeiHai: TCorbaDataModule} {CORBAServer_WeiHai: CoClass},
Server_System in '..\2.program\0.服务器\Server_System.pas',
Server in '..\2.program\0.服务器\Server.pas' {Form_Server};{$R *.TLB} {CORBA}{$R *.res}{$R Server.res}var AboutStr: string;
var NID: TNotifyIconData;
WndClass: array[0..50] of char;procedure Panic(szMessage: PChar);
begin
if szMessage<>nil then MessageBox(0, szMessage, PChar(VG_AppName), MB_OK);
Halt(0);
end;procedure HandleCommand(Wnd: hWnd; Cmd: Word);
begin
case Cmd of
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//主窗口********************************************************************
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ord('C'): if not Form_Server.Visible then Form_Server.ShowModal;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//关于**********************************************************************
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ord('A'): MessageBox(0, PChar(AboutStr), PChar('关于...'), MB_OK);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//退出系统******************************************************************
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ord('E'): begin
ServerOver;
if Form_Server.Visible then Form_Server.Close;
PostMessage(Wnd, WM_CLOSE, 0, 0);
end;
end;
end;function DummyWindowProc(Wnd: hWnd; Msg, wParam: Word; lParam: LongInt): LongInt; stdcall;
var TrayHandle: THandle;
DC: hDC;
pm: HMenu;
pt: TPoint;
begin
DummyWindowProc := 0;
StrPCopy(@WndClass[0], 'Quark');
TrayHandle := FindWindow(@WndClass[0], nil);
case Msg of
WM_CREATE: begin//Program initialisation - just set up a tray icon
NID.cbSize := SizeOf(NID);
NID.Wnd := Wnd;
NID.uID := 1;
NID.uFlags := nif_Message or nif_Icon or nif_Tip;
NID.uCallBackMessage := WM_User;
NID.hIcon := LoadIcon(hInstance, 'TRAYICON');
Lstrcpy(NID.szTip,'Pontifex for Windows');
Shell_NotifyIcon(nim_Add, @NID);
end;
WM_DESTROY: begin
Shell_NotifyIcon(nim_Delete, @NID);
PostQuitMessage(0);
ShowWindow(TrayHandle, SW_RESTORE);
end;
WM_COMMAND: begin//Command notification
HandleCommand(Wnd, LoWord(wParam));
Exit;
end;
WM_USER: case lParam of
//双击鼠标左键************************************************
WM_LBUTTONDBLCLK: if not Form_Server.Visible then Form_Server.ShowModal;
//单击鼠标右键************************************************
WM_RBUTTONDOWN: begin
GetCursorPos(pt);
pm := CreatePopupMenu;
AppendMenu(pm, 0, Ord('C'), '客户端状态');
AppendMenu(pm, MF_SEPARATOR, 0, nil);
AppendMenu(pm, 0, Ord('A'), '关于Pontifex...');
AppendMenu(pm, 0, Ord('E'), '退出');
SetForegroundWindow(Wnd);
DC := GetDC(0);
if TrackPopupMenu(pm, tpm_BottomAlign or tpm_RightAlign, pt.x,GetDeviceCaps(DC,HORZRES){pt.y}, 0, Wnd, nil)
then SetForegroundWindow(Wnd);
DestroyMenu(pm);
end;
end;//case lParam of
end;
DummyWindowProc := DefWindowProc(Wnd, Msg, wParam, lParam);
end;procedure WinMain;
var Wnd: hWnd;
Msg: TMsg;
WndClass: TWndClass;
begin
{ Previous instance running ? If so, exit }
if FindWindow(PChar(VG_AppName), nil)<>0 then Panic(PChar(VG_AppName + ' 已经运行。')); { Register the window class }
FillChar(WndClass, SizeOf(WndClass), 0);
WndClass.lpfnWndProc := @DummyWindowProc;
WndClass.hInstance := hInstance;
WndClass.lpszClassName := PChar(VG_AppName);
RegisterClass(WndClass); { Now create the dummy window }
Wnd := CreateWindow(PChar(VG_AppName), PChar(VG_AppName), WS_OVERLAPPEDWINDOW , 0, 0, 0, 0, 0, 0, hInstance, nil);
if Wnd<>0 then
begin
ShowWindow(Wnd, SW_HIDE);
while GetMessage(Msg, 0, 0, 0) do
begin
TranslateMessage(Msg);
DispatchMessage(Msg);
end;
end;
end;begin
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//系统变量初始化**************************************************************
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ServerInit;
AboutStr := '北京博达新创科技发展有限公司(R)' + #13;
AboutStr := AboutStr + '供热企业收费管理信息系统(C)' + #13;
AboutStr := AboutStr + 'Version of Server ' + GetApplicationVersion(Application.ExeName); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//创建主窗体,开始运行********************************************************
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Application.Initialize;
Application.CreateForm(TForm_Server, Form_Server);
WinMain;
end.
Forms,
Windows,
ShellAPI,
Messages,
Sysutils,
exSystem,
Pontifex_TLB in 'Pontifex_TLB.pas',
Server_CORBA in '..\2.program\0.服务器\Server_CORBA.pas' {CORBAServer_WeiHai: TCorbaDataModule} {CORBAServer_WeiHai: CoClass},
Server_System in '..\2.program\0.服务器\Server_System.pas',
Server in '..\2.program\0.服务器\Server.pas' {Form_Server};{$R *.TLB} {CORBA}{$R *.res}{$R Server.res}var AboutStr: string;
var NID: TNotifyIconData;
WndClass: array[0..50] of char;procedure Panic(szMessage: PChar);
begin
if szMessage<>nil then MessageBox(0, szMessage, PChar(VG_AppName), MB_OK);
Halt(0);
end;procedure HandleCommand(Wnd: hWnd; Cmd: Word);
begin
case Cmd of
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//主窗口********************************************************************
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ord('C'): if not Form_Server.Visible then Form_Server.ShowModal;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//关于**********************************************************************
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ord('A'): MessageBox(0, PChar(AboutStr), PChar('关于...'), MB_OK);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//退出系统******************************************************************
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ord('E'): begin
ServerOver;
if Form_Server.Visible then Form_Server.Close;
PostMessage(Wnd, WM_CLOSE, 0, 0);
end;
end;
end;function DummyWindowProc(Wnd: hWnd; Msg, wParam: Word; lParam: LongInt): LongInt; stdcall;
var TrayHandle: THandle;
DC: hDC;
pm: HMenu;
pt: TPoint;
begin
DummyWindowProc := 0;
StrPCopy(@WndClass[0], 'Quark');
TrayHandle := FindWindow(@WndClass[0], nil);
case Msg of
WM_CREATE: begin//Program initialisation - just set up a tray icon
NID.cbSize := SizeOf(NID);
NID.Wnd := Wnd;
NID.uID := 1;
NID.uFlags := nif_Message or nif_Icon or nif_Tip;
NID.uCallBackMessage := WM_User;
NID.hIcon := LoadIcon(hInstance, 'TRAYICON');
Lstrcpy(NID.szTip,'Pontifex for Windows');
Shell_NotifyIcon(nim_Add, @NID);
end;
WM_DESTROY: begin
Shell_NotifyIcon(nim_Delete, @NID);
PostQuitMessage(0);
ShowWindow(TrayHandle, SW_RESTORE);
end;
WM_COMMAND: begin//Command notification
HandleCommand(Wnd, LoWord(wParam));
Exit;
end;
WM_USER: case lParam of
//双击鼠标左键************************************************
WM_LBUTTONDBLCLK: if not Form_Server.Visible then Form_Server.ShowModal;
//单击鼠标右键************************************************
WM_RBUTTONDOWN: begin
GetCursorPos(pt);
pm := CreatePopupMenu;
AppendMenu(pm, 0, Ord('C'), '客户端状态');
AppendMenu(pm, MF_SEPARATOR, 0, nil);
AppendMenu(pm, 0, Ord('A'), '关于Pontifex...');
AppendMenu(pm, 0, Ord('E'), '退出');
SetForegroundWindow(Wnd);
DC := GetDC(0);
if TrackPopupMenu(pm, tpm_BottomAlign or tpm_RightAlign, pt.x,GetDeviceCaps(DC,HORZRES){pt.y}, 0, Wnd, nil)
then SetForegroundWindow(Wnd);
DestroyMenu(pm);
end;
end;//case lParam of
end;
DummyWindowProc := DefWindowProc(Wnd, Msg, wParam, lParam);
end;procedure WinMain;
var Wnd: hWnd;
Msg: TMsg;
WndClass: TWndClass;
begin
{ Previous instance running ? If so, exit }
if FindWindow(PChar(VG_AppName), nil)<>0 then Panic(PChar(VG_AppName + ' 已经运行。')); { Register the window class }
FillChar(WndClass, SizeOf(WndClass), 0);
WndClass.lpfnWndProc := @DummyWindowProc;
WndClass.hInstance := hInstance;
WndClass.lpszClassName := PChar(VG_AppName);
RegisterClass(WndClass); { Now create the dummy window }
Wnd := CreateWindow(PChar(VG_AppName), PChar(VG_AppName), WS_OVERLAPPEDWINDOW , 0, 0, 0, 0, 0, 0, hInstance, nil);
if Wnd<>0 then
begin
ShowWindow(Wnd, SW_HIDE);
while GetMessage(Msg, 0, 0, 0) do
begin
TranslateMessage(Msg);
DispatchMessage(Msg);
end;
end;
end;begin
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//系统变量初始化**************************************************************
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ServerInit;
AboutStr := '北京博达新创科技发展有限公司(R)' + #13;
AboutStr := AboutStr + '供热企业收费管理信息系统(C)' + #13;
AboutStr := AboutStr + 'Version of Server ' + GetApplicationVersion(Application.ExeName); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//创建主窗体,开始运行********************************************************
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Application.Initialize;
Application.CreateForm(TForm_Server, Form_Server);
WinMain;
end.
解决方案 »
- sql 问题
- CPort 哪里有2009版本的下载地址啊
- 怕吊扇会掉下来,怎么办??
- 好久不来了,发个个性帖嘿嘿~~
- 急,80分送各位前辈:动态创建的serversocket怎么接受clientsocket的连接
- 一个数据类型转换问题!
- 菜鸟问题!回答解决后马上结贴!
- 寻截获IP包的源码!
- 超难问题!如何在一个程序中得到另一个程序中的datagrid的数据!
- 注意!!!!高分提问: 把delphi工程转换到C++Builder
- 关于异常处理问题,不知如何得到 E…….ErrorCount(错误号)
- 在delphi中,当输入完对象名后的"."要过好久才出现提示,有没有办法象VB那样,立刻就出现提示。还有就是无方法,实现象VB那样自动变换大
要是没有用google,这方面的文章挺多的
Forms,
Windows,
ShellAPI,
Messages,
Sysutils,
exSystem,
Pontifex_TLB in 'Pontifex_TLB.pas',
Server_CORBA in '..\2.program\0.服务器\Server_CORBA.pas' {CORBAServer_WeiHai: TCorbaDataModule} {CORBAServer_WeiHai: CoClass},
Server_System in '..\2.program\0.服务器\Server_System.pas',
Server in '..\2.program\0.服务器\Server.pas' {Form_Server};{$R *.TLB} {CORBA}{$R *.res}{$R Server.res}var AboutStr: string;
var NID: TNotifyIconData;
WndClass: array[0..50] of char;procedure Panic(szMessage: PChar);
begin
if szMessage<>nil then MessageBox(0, szMessage, PChar(VG_AppName), MB_OK);
Halt(0);
end;procedure HandleCommand(Wnd: hWnd; Cmd: Word);
begin
case Cmd of
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//主窗口********************************************************************
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ord('C'): if not Form_Server.Visible then Form_Server.ShowModal;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//关于**********************************************************************
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ord('A'): MessageBox(0, PChar(AboutStr), PChar('关于...'), MB_OK);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//退出系统******************************************************************
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ord('E'): begin
ServerOver;
if Form_Server.Visible then Form_Server.Close;
PostMessage(Wnd, WM_CLOSE, 0, 0);
end;
end;
end;function DummyWindowProc(Wnd: hWnd; Msg, wParam: Word; lParam: LongInt): LongInt; stdcall;
var TrayHandle: THandle;
DC: hDC;
pm: HMenu;
pt: TPoint;
begin
DummyWindowProc := 0;
StrPCopy(@WndClass[0], 'Quark');
TrayHandle := FindWindow(@WndClass[0], nil);
case Msg of
WM_CREATE: begin//Program initialisation - just set up a tray icon
NID.cbSize := SizeOf(NID);
NID.Wnd := Wnd;
NID.uID := 1;
NID.uFlags := nif_Message or nif_Icon or nif_Tip;
NID.uCallBackMessage := WM_User;
NID.hIcon := LoadIcon(hInstance, 'TRAYICON');
Lstrcpy(NID.szTip,'Pontifex for Windows');
Shell_NotifyIcon(nim_Add, @NID);
end;
WM_DESTROY: begin
Shell_NotifyIcon(nim_Delete, @NID);
PostQuitMessage(0);
ShowWindow(TrayHandle, SW_RESTORE);
end;
WM_COMMAND: begin//Command notification
HandleCommand(Wnd, LoWord(wParam));
Exit;
end;
WM_USER: case lParam of
//双击鼠标左键************************************************
WM_LBUTTONDBLCLK: if not Form_Server.Visible then Form_Server.ShowModal;
//单击鼠标右键************************************************
WM_RBUTTONDOWN: begin
GetCursorPos(pt);
pm := CreatePopupMenu;
AppendMenu(pm, 0, Ord('C'), '客户端状态');
AppendMenu(pm, MF_SEPARATOR, 0, nil);
AppendMenu(pm, 0, Ord('A'), '关于Pontifex...');
AppendMenu(pm, 0, Ord('E'), '退出');
SetForegroundWindow(Wnd);
DC := GetDC(0);
if TrackPopupMenu(pm, tpm_BottomAlign or tpm_RightAlign, pt.x,GetDeviceCaps(DC,HORZRES){pt.y}, 0, Wnd, nil)
then SetForegroundWindow(Wnd);
DestroyMenu(pm);
end;
end;//case lParam of
end;
DummyWindowProc := DefWindowProc(Wnd, Msg, wParam, lParam);
end;procedure WinMain;
var Wnd: hWnd;
Msg: TMsg;
WndClass: TWndClass;
begin
{ Previous instance running ? If so, exit }
if FindWindow(PChar(VG_AppName), nil)<>0 then Panic(PChar(VG_AppName + ' 已经运行。')); { Register the window class }
FillChar(WndClass, SizeOf(WndClass), 0);
WndClass.lpfnWndProc := @DummyWindowProc;
WndClass.hInstance := hInstance;
WndClass.lpszClassName := PChar(VG_AppName);
RegisterClass(WndClass); { Now create the dummy window }
Wnd := CreateWindow(PChar(VG_AppName), PChar(VG_AppName), WS_OVERLAPPEDWINDOW , 0, 0, 0, 0, 0, 0, hInstance, nil);
if Wnd<>0 then
begin
ShowWindow(Wnd, SW_HIDE);
while GetMessage(Msg, 0, 0, 0) do
begin
TranslateMessage(Msg);
DispatchMessage(Msg);
end;
end;
end;begin
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//系统变量初始化**************************************************************
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ServerInit;
AboutStr := '北京博达新创科技发展有限公司(R)' + #13;
AboutStr := AboutStr + '供热企业收费管理信息系统(C)' + #13;
AboutStr := AboutStr + 'Version of Server ' + GetApplicationVersion(Application.ExeName); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//创建主窗体,开始运行********************************************************
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Application.Initialize;
Application.CreateForm(TForm_Server, Form_Server);
WinMain;
end.
Delphi还有例子
Samples->TrayIcon
procedure WMSysCommand(var Msg: TWMSysCommand); message WM_SYSCOMMAND;
procedure TForm1.WMSysCommand(var Msg: TWMSysCommand);
begin
if Msg.CmdType = SC_MINIMIZE then
begin
//最小化,关闭窗口即可 Hide;
end;
end;
至于放到 系统托盘 中看看别人的文章或用控件;
rxlib
procedure Tform1.ll(var message:TMessage);
begin
if (message.wParam=SC_MINIMIZE) then
begin
message.wParam:=0;
application.ShowMainForm:=false;
end;
inherited;
end;
在定义部分
procedure ll(var message:TMessage);
message WM_syscommand;