RT
解决方案 »
- 两个advstringgrid的列同步互换,请问怎么实现啊
- 今天整整27了,希望收到大家的祝福!也希望有好的产品解释给我!
- 我想知道数据库程序数据的检查是在录入窗体做好还是在数据提交的时候做好,你们是怎么做的呢?
- 这两个怎样调用急用!!!!!!!!!!!!
- 关于Delphi访问EJB组件
- sqlserver2000应用程序发布~!我还是搞不懂~!懂得人来帮帮我~!
- DBGrid能不能用程序直接一行一行赋值?(不给DataSource赋值)
- interface中的uses语句和implemetation中的uses语句有何不同?
- 用ADO連接MSSQL2000后.如何用ADOCommand進行查詢呢
- 各位高手:我的程序中客户端需要通过Socket与服务器通讯以存取数据库中的数据,包括浏览、查询、增、删、改等,是否能够实现?
- 高分请教一下怎样在一个dbgrid的列表头单击取得所单击的对应的字段?
- 遇到难题,食欲不振:一个rave打印的问题,请帮忙
var
nid: TNotifyIconData;
begin
nid.cbSize := sizeof(nid);
nid.Wnd := Handle;
nid.uID := 0;
nid.hIcon := Application.Icon.Handle;
StrPCopy(nid.szTip, pProgamVersion);
nid.uCallbackMessage := WM_ICONMESSAGE;
nid.uFlags := NIF_ICON or NIF_TIP or NIF_MESSAGE;
if not Shell_NotifyIcon(NIM_ADD, @nid) then
begin
ShowMessage('System Error!');
Application.Terminate;
end;
// SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
Caption := pProgamVersion;
PageControl1.ActivePageIndex := 0;
IniFileName := ExtractFileDir(ParamStr(0)) + '\Config.INI';
CommonFileName := ExtractFileDir(ParamStr(0)) + '\CommonFiles.TXT';
ReadIniFile;
ReadTxtFile;
end;procedure TfmTaskSearcher.FormClose(Sender: TObject; var Action: TCloseAction);
var
nid: TNotifyIconData;
begin
nid.cbSize := SizeOf(nid);
nid.uID := 0;
nid.Wnd := Handle;
Shell_NotifyIcon(NIM_DELETE, @nid);
end;注意,在uses部分加入shellapi
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,shellapi, Menus, AppEvnts,Registry;
const
mousemsg = wm_user + 1; //自定义消息,用于处理用户在图标上点击鼠标的事件
iid = 100; //用户自定义数值,在TnotifyIconDataA类型全局变量ntida中使用
type
TForm1 = class(TForm)
Button1: TButton;
PopupMenu1: TPopupMenu;
N1: TMenuItem;
ApplicationEvents1: TApplicationEvents;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button1Click(Sender: TObject);
procedure ApplicationEvents1Minimize(Sender: TObject);
procedure FormShow(Sender: TObject);
private
procedure mousemessage(var message: tmessage); message mousemsg;
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
ntida:TNotifyIcondataA; //用于增加和删除系统状态图标
implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
begin
ntida.cbSize := sizeof(tnotifyicondataa); //指定ntida的长度
ntida.Wnd := handle; //取应用程序主窗体的句柄
ntida.uID := iid; //用户自定义的一个数值,在uCallbackMessage参数指定的消息中使
ntida.uFlags := nif_icon + nif_tip +
nif_message; //指定在该结构中uCallbackMessage、hIcon和szTip参数都有效
ntida.uCallbackMessage := mousemsg;
//指定的窗口消息
// ntida.hIcon := Application.Icon.handle;
//指定系统状态栏显示应用程序的图标句柄
ntida.szTip := 'Icon';
//当鼠标停留在系统状态栏该图标上时,出现该提示信息
shell_notifyicona(NIM_ADD, @ntida);
//在系统状态栏增加一个新图标
end;
procedure TForm1.mousemessage(var message: tmessage);
var
mousept: TPoint; //鼠标点击位置
begin
inherited;
if message.LParam = wm_rbuttonup then begin //用鼠标右键点击图标
getcursorpos(mousept); //获取光标位置
popupmenu1.popup(mousept.x, mousept.y);
//在光标位置弹出选单
end;
if message.LParam = wm_lbuttonup then begin //用鼠标左键点击图标
{ //显示应用程序窗口
ShowWindow(Handle, SW_SHOW);
//在任务栏上显示应用程序窗口
ShowWindow(Application.handle, SW_SHOW);
SetWindowLong(Application.Handle, GWL_EXSTYLE,
not (GetWindowLong(Application.handle, GWL_EXSTYLE)
or WS_EX_TOOLWINDOW and not WS_EX_APPWINDOW)); }
end;
message.Result := 0;
end;procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caNone; //不对窗体进行任何操作
ShowWindow(Handle, SW_HIDE); //隐藏主窗体
//隐藏应用程序窗口在任务栏上的显示
ShowWindow(Application.Handle, SW_HIDE);
SetWindowLong(Application.Handle, GWL_EXSTYLE,
not (GetWindowLong(Application.handle, GWL_EXSTYLE)
or WS_EX_TOOLWINDOW and not WS_EX_APPWINDOW));
end;procedure TForm1.Button1Click(Sender: TObject);
begin
ntida.cbSize := sizeof(tnotifyicondataa);
ntida.wnd := handle;
ntida.uID := iid;
ntida.uFlags := nif_icon + nif_tip + nif_message;
ntida.uCallbackMessage := mousemsg;
ntida.hIcon := Application.Icon.handle;
ntida.szTip := 'Icon';
shell_notifyicona(NIM_DELETE, @ntida);
//删除已有的应用程序图标
Application.Terminate;
//中断应用程序运行,退出应用程序
end;end.
哈哈,贴一个连接地址好了,自己上去看,都是代码,一个一个测试,感觉哪个好用哪个吧!
var
NotifyIconData: TNotifyIconData;Shell_NotifyIcon(NIM_ADD, @NotifyIconData); //添加
Shell_NotifyIcon(NIM_DELETE, @NotifyIconData); //删除
只是用上面两句话就可以看到效果了(在托盘那有图标),只是它没有任何功能.
------------------------------------------------------------------------要让它有功能,关键是NotifyIconData的初始化.
比如让它有个图标先用下面两句初始化一下,就可看到一个白白的图标. NotifyIconData.uFlags := NIF_ICON;
NotifyIconData.hIcon := LoadIcon(0, IDI_WINLOGO);更详细的可参考楼上各位的代码,或Win32SDK,msdn
Shell_NotifyIcon( NIM_DELETE, @NotifyIcon);
其实关键搞清楚TNotifyIconData就可以了
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,shellapi, Menus, AppEvnts,Registry;
const
mousemsg = wm_user + 1; //自定义消息,用于处理用户在图标上点击鼠标的事件
iid = 100; //用户自定义数值,在TnotifyIconDataA类型全局变量ntida中使用
type
TForm1 = class(TForm)
Button1: TButton;
PopupMenu1: TPopupMenu;
N1: TMenuItem;
ApplicationEvents1: TApplicationEvents;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button1Click(Sender: TObject);
procedure ApplicationEvents1Minimize(Sender: TObject);
procedure FormShow(Sender: TObject);
private
procedure mousemessage(var message: tmessage); message mousemsg;
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
ntida:TNotifyIcondataA; //用于增加和删除系统状态图标
implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
begin
ntida.cbSize := sizeof(tnotifyicondataa); //指定ntida的长度
ntida.Wnd := handle; //取应用程序主窗体的句柄
ntida.uID := iid; //用户自定义的一个数值,在uCallbackMessage参数指定的消息中使
ntida.uFlags := nif_icon + nif_tip +
nif_message; //指定在该结构中uCallbackMessage、hIcon和szTip参数都有效
ntida.uCallbackMessage := mousemsg;
//指定的窗口消息
// ntida.hIcon := Application.Icon.handle;
//指定系统状态栏显示应用程序的图标句柄
ntida.szTip := 'Icon';
//当鼠标停留在系统状态栏该图标上时,出现该提示信息
shell_notifyicona(NIM_ADD, @ntida);
//在系统状态栏增加一个新图标
end;
procedure TForm1.mousemessage(var message: tmessage);
var
mousept: TPoint; //鼠标点击位置
begin
inherited;
if message.LParam = wm_rbuttonup then begin //用鼠标右键点击图标
getcursorpos(mousept); //获取光标位置
popupmenu1.popup(mousept.x, mousept.y);
//在光标位置弹出选单
end;
if message.LParam = wm_lbuttonup then begin //用鼠标左键点击图标
{ //显示应用程序窗口
ShowWindow(Handle, SW_SHOW);
//在任务栏上显示应用程序窗口
ShowWindow(Application.handle, SW_SHOW);
SetWindowLong(Application.Handle, GWL_EXSTYLE,
not (GetWindowLong(Application.handle, GWL_EXSTYLE)
or WS_EX_TOOLWINDOW and not WS_EX_APPWINDOW)); }
end;
message.Result := 0;
end;procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caNone; //不对窗体进行任何操作
ShowWindow(Handle, SW_HIDE); //隐藏主窗体
//隐藏应用程序窗口在任务栏上的显示
ShowWindow(Application.Handle, SW_HIDE);
SetWindowLong(Application.Handle, GWL_EXSTYLE,
not (GetWindowLong(Application.handle, GWL_EXSTYLE)
or WS_EX_TOOLWINDOW and not WS_EX_APPWINDOW));
end;procedure TForm1.Button1Click(Sender: TObject);
begin
ntida.cbSize := sizeof(tnotifyicondataa);
ntida.wnd := handle;
ntida.uID := iid;
ntida.uFlags := nif_icon + nif_tip + nif_message;
ntida.uCallbackMessage := mousemsg;
ntida.hIcon := Application.Icon.handle;
ntida.szTip := 'Icon';
shell_notifyicona(NIM_DELETE, @ntida);
//删除已有的应用程序图标
Application.Terminate;
//中断应用程序运行,退出应用程序
end;end.