启动后直接最小化到托盘栏 我做了一个程序,点最小化按钮可以实现到托盘栏,点托盘栏的小图标也可以恢复到桌面上,但是我想实现程序在启动时直接就在托盘栏显示,在桌面与任务栏上不显示怎么办? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 formshow中加入你控制托盘的代码试过吗 unit ServerMain;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, IniFiles, ExtCtrls, bsSkinData, BusinessSkinForm, Menus, bsSkinMenus,shellapi, ImgList;type Tmain = class(TForm) bsSkinData: TbsSkinData; bsBusinessSkinForm1: TbsBusinessSkinForm; Image1: TImage; Timer1: TTimer; Label1: TLabel; PopupMenu1: TbsSkinPopupMenu; N1: TMenuItem; N2: TMenuItem; N3: TMenuItem; N4: TMenuItem; Timer2: TTimer; ImageList1: TImageList; procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure N3Click(Sender: TObject); procedure N4Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); private { Private declarations } public { Public declarations } procedure WndProc(var Msg: TMessage); override; end;const TrayMsgStr = 'TrayNotifyIconMsg';var main: Tmain; shi,fen,miao:integer; nd0,nd1: NotifyIconData; hs: array[0..1]of LongWord; WM_TRAYNOTIFY: Cardinal; IconFlag: integer;implementation{$R *.DFM}procedure TMain.WndProc(var Msg: TMessage);var pt:TPoint;begin with Msg do begin if Msg = WM_TRAYNOTIFY then begin case lParam of WM_LBUTTONDOWN: begin hs[1]:=LoadIcon(hInstance, 'Icon1'); nd1.cbSize := sizeof(NotifyIconData); nd1.Wnd := Handle; nd1.uID := 1; nd1.uFlags := NIF_MESSAGE or NIF_ICON or NIF_TIP; nd1.uCallbackMessage := WM_TRAYNOTIFY; nd1.hIcon := hs[1]; StrPLCopy(nd1.szTip, 'Thank You !',63); Shell_NotifyIcon(NIM_MODIFY,@nd1); IconFlag :=1; Main.Show ; end; WM_LBUTTONDBLCLK: begin ShowMessage('double click'); end; WM_RBUTTONDOWN: begin SetForegroundWindow(Handle); GetCursorPos(pt); PopupMenu1.Popup(Pt.X, Pt.Y); end; end; end; end; inherited;end;procedure Tmain.FormCreate(Sender: TObject);begin setwindowlong(application.handle,gwl_exstyle,ws_ex_toolwindow); WM_TRAYNOTIFY := RegisterWindowMessage(TrayMsgStr); hs[0]:=LoadIcon(hInstance, 'MainIcon'); nd0.cbSize := sizeof(NotifyIconData); nd0.Wnd := Handle; nd0.uID := 0; nd0.uFlags := NIF_MESSAGE or NIF_ICON or NIF_TIP; nd0.uCallbackMessage := WM_TRAYNOTIFY; nd0.hIcon := hs[0]; StrPLCopy(nd0.szTip, '速普得应用服务器,正在运行...',63); Shell_NotifyIcon(NIM_ADD,@nd0); IconFlag :=0; with Timer2 do begin Enabled := False; Interval := GetDoubleClickTime; end;end;procedure Tmain.FormDestroy(Sender: TObject);begin if (IconFlag=0) then Shell_NotifyIcon(NIM_DELETE, @nd0) else Shell_NotifyIcon(NIM_DELETE, @nd1);end;procedure Tmain.N3Click(Sender: TObject);begin main.Show;end;procedure Tmain.N4Click(Sender: TObject);begin beep; if messagedlg('如果你退出该服务,ERP系统将无法正常运行!'+#13+'你确定要强行退出应用服务器吗? Y/N',mtwarning,[mbyes,mbno],0) = mryes then Application.Terminate;end;procedure Tmain.FormClose(Sender: TObject; var Action: TCloseAction);begin Action := caNone; main.Hide;end;end. 用戶cooltrayicon控件,一切變得簡單. 教你个最简单的方法: 步陬1.主窗体为form1,将form1设置成透明,并把大小缩成一个点,放在角落。 步陬2.双击主窗体,加入代码:SetWindowLong(Application.handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW);在您的程序中加入这两步就可以实现程序一启动主窗口不显示。 其实原理是一样的吧,最小化的时候捕获SYSCOMMAND消息,把窗口最小化到左下角处再加一个托盘图标。那么你程序一运行,Onshow事件中,发送最小化消息不就行啦postMessage(Application.handle,WM_SYSCOMMAND,SC_MINIMIZE,0); 高手帮忙解决一下海量数据导入的问题 杂牌军提问:不想搞成控制台程序,但同时又不想用MainForm,可以吗? 如何给1861发短信取得余额,求助 GLScene帮助,中英文对照 请教如何在程序中安装一个已经写好了的存储过程。 紧急求救:将数据导出到Excel时遇到的问题 adoquery中的极简单语句问题,在线给分!!! 我杀死了一个锁键盘和鼠标的进程后鼠标能动了,但键盘仍然被锁.有什么办法能解锁键盘? 怎样把一个字符串转换成ACII码(函数) delphi调用wervice出错 fastreport打印附表的问题求教,在线等待! 多线程提问,create里的参数好像没用的阿?
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, IniFiles, ExtCtrls, bsSkinData, BusinessSkinForm, Menus,
bsSkinMenus,shellapi, ImgList;type
Tmain = class(TForm)
bsSkinData: TbsSkinData;
bsBusinessSkinForm1: TbsBusinessSkinForm;
Image1: TImage;
Timer1: TTimer;
Label1: TLabel;
PopupMenu1: TbsSkinPopupMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
Timer2: TTimer;
ImageList1: TImageList;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure N3Click(Sender: TObject);
procedure N4Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
procedure WndProc(var Msg: TMessage); override;
end;const
TrayMsgStr = 'TrayNotifyIconMsg';var
main: Tmain;
shi,fen,miao:integer;
nd0,nd1: NotifyIconData;
hs: array[0..1]of LongWord;
WM_TRAYNOTIFY: Cardinal;
IconFlag: integer;implementation{$R *.DFM}procedure TMain.WndProc(var Msg: TMessage);
var
pt:TPoint;
begin
with Msg do
begin
if Msg = WM_TRAYNOTIFY then
begin
case lParam of
WM_LBUTTONDOWN:
begin
hs[1]:=LoadIcon(hInstance, 'Icon1');
nd1.cbSize := sizeof(NotifyIconData);
nd1.Wnd := Handle;
nd1.uID := 1;
nd1.uFlags := NIF_MESSAGE or NIF_ICON or NIF_TIP;
nd1.uCallbackMessage := WM_TRAYNOTIFY;
nd1.hIcon := hs[1];
StrPLCopy(nd1.szTip, 'Thank You !',63);
Shell_NotifyIcon(NIM_MODIFY,@nd1);
IconFlag :=1;
Main.Show ;
end;
WM_LBUTTONDBLCLK:
begin
ShowMessage('double click');
end;
WM_RBUTTONDOWN:
begin
SetForegroundWindow(Handle);
GetCursorPos(pt);
PopupMenu1.Popup(Pt.X, Pt.Y);
end;
end;
end;
end;
inherited;
end;procedure Tmain.FormCreate(Sender: TObject);
begin
setwindowlong(application.handle,gwl_exstyle,ws_ex_toolwindow);
WM_TRAYNOTIFY := RegisterWindowMessage(TrayMsgStr);
hs[0]:=LoadIcon(hInstance, 'MainIcon');
nd0.cbSize := sizeof(NotifyIconData);
nd0.Wnd := Handle;
nd0.uID := 0;
nd0.uFlags := NIF_MESSAGE or NIF_ICON or NIF_TIP;
nd0.uCallbackMessage := WM_TRAYNOTIFY;
nd0.hIcon := hs[0];
StrPLCopy(nd0.szTip, '速普得应用服务器,正在运行...',63);
Shell_NotifyIcon(NIM_ADD,@nd0);
IconFlag :=0;
with Timer2 do
begin
Enabled := False;
Interval := GetDoubleClickTime;
end;
end;procedure Tmain.FormDestroy(Sender: TObject);
begin
if (IconFlag=0) then
Shell_NotifyIcon(NIM_DELETE, @nd0)
else
Shell_NotifyIcon(NIM_DELETE, @nd1);
end;procedure Tmain.N3Click(Sender: TObject);
begin
main.Show;
end;procedure Tmain.N4Click(Sender: TObject);
begin
beep;
if messagedlg('如果你退出该服务,ERP系统将无法正常运行!'+#13+'你确定要强行退出应用服务器吗? Y/N',mtwarning,[mbyes,mbno],0) = mryes then
Application.Terminate;
end;procedure Tmain.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caNone;
main.Hide;
end;end.
步陬2.双击主窗体,加入代码:SetWindowLong(Application.handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW);在您的程序中加入这两步就可以实现程序一启动主窗口不显示。
再加一个托盘图标。那么你程序一运行,Onshow事件中,发送最小化消息不就行啦
postMessage(Application.handle,WM_SYSCOMMAND,SC_MINIMIZE,0);