delphi(api)系统托盘
来源:互联网 发布:前端怎么连接数据库 编辑:程序博客网 时间:2024/06/01 14:24
好简单的一个事例啊,昨天翻下上去几年的资料,找到的这个。
//delphi用API制作的系统托盘加弹出菜单, 用了将近两年的。NET再看下这个有点感觉不同
//也是以前开发时常用的这种方法
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,shellapi, StdCtrls, Menus;
const wm_icon = WM_USER + 100;
type
TForm1 = class(TForm)
Button2: TButton;
procedure Button2Click(Sender: TObject);
procedure user_sysmenu(var msg:twmmenuselect); message WM_COMMAND;
private
{ Private declarations }
procedure OnIconNotify(var Message: TMessage); message wm_icon;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure tform1.user_sysmenu(var msg:twmmenuselect);//处理弹出菜单的选择项
begin
if msg.IDItem =999 then
self.Close
else
inherited;
end;
procedure tform1.OnIconNotify(var Message: TMessage); //处理程序提示区图标 消息
var
menu:HMENU;
rect:trect;
pp:tpoint;
begin
if Message.LParam =WM_RBUTTONDOWN then
begin
rect.Left:=56;
rect.Top:=0;
rect.Right:=100;
rect.Bottom:=88;
//rect.BottomRight:= point(LOWORD(message.lParam),HIWORD(message.lParam));
menu:=createpopupmenu();
appendmenu(menu,MF_STRING,999,'exit');
GetCursorPos ( pp);//current mouse postion
TrackPopupMenu(menu, TPM_LEFTALIGN , pp.x , pp.y ,0,self.Handle,@rect);
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
cc:TNotifyIconData ;
begin
cc.cbSize:= sizeof(cc);
cc.Wnd:= self.Handle;
cc.uID := 1;
cc.hIcon := Application.Icon.Handle; // 窗口句柄
cc.szTip := 'This is a test application' ;
cc.uFlags := NIF_ICON or NIF_TIP or NIF_MESSAGE; // 指明哪些字段有效
cc.uCallbackMessage:= wm_icon ; //处理的消息
Shell_NotifyIcon(NIM_ADD, @cc); // destroy window NIM_DELETE + index
end;
end.
- delphi(api)系统托盘
- 系统托盘api
- delphi编写系统托盘程序
- Delphi实现系统托盘图标
- Delphi 添加系统托盘
- delphi最小化到系统托盘
- Delphi 系统托盘 TrayIcon(1)
- Delphi 添加系统托盘
- Win32 API实现系统托盘
- Win32 API 实现系统托盘程序
- Win32 API 实现系统托盘程序
- Win32 API 实现系统托盘程序
- Win32 API 实现系统托盘程序
- Windows API 之系统托盘图标
- Win32 API 实现系统托盘程序
- Win32 API 实现系统托盘程序
- windows API 创建系统托盘图标
- windows API 创建系统托盘图标
- java.sql.BatchUpdateException: ORA-01031: 权限不足
- Acegi-security-samples-tutorial-1.0.7.zip 实例学习笔记
- 每天坚持读10篇以上的技术类文章,一年后,二年后---(注无内容)
- 0X000000该内存不能为read的解决方法
- Hibernate关系映射
- delphi(api)系统托盘
- 60个生活小常识
- Acegi-security-samples-tutorial-1.0.7.zip 实例代码解析
- JSP快速入门教程——全十讲
- 函数指针
- java面试题
- channel bank
- 把秒换成时间显示
- 进度条的操作