我需将调用DLL中的Form最小化后,在拖盘中显示图标,怎么实现?
解决方案 »
- sql 同时查询 日期 姓名是否已有记录。
- 超难问题!!!! 如何 修改 cxDateEdit 控件 下拉 选择日期 里面 按钮 文字???? 急!!!!!!!!
- 关于一个编译错误!!!!!急啊!
- 图片打印问题
- 干掉小日本——ttzzj首次放分
- 救命!我的源码没了,如何得到程序可执行体的某个控件的值?(在线等)
- 一个语法问题
- delphi数据库控件简单问题,100分送上!!!
- 高分请教 连接 SQL Server服务器的问题—在线等待!?
- 请问各位Delphi生成的EXE程序,运行时是否可以带参数,如DOS那样???如何带???
- 在文本文件中按行写入数据和提取数据
- TImage组件默认支持*.bmp,*.ico,*.emf,*.wmf;能否改变这个默认值,使其支持更多的图像格式呢?
捕捉到dllForm最小化的消息就显示到托盘
//DLL
library DLLICON;uses
SysUtils,
Classes,
UScktFM in 'DLLForm.pas' {DM};{$R *.res}
exports
CreateForm,
DestroyForm;
begin
end.//From
unit DLLForm;interfaceuses
Windows, Messages, SysUtils, Classes, Forms,
Dialogs, ShellAPI;type
TDM = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
IconData: TNotifyIconData;
procedure AddIconToTray;
procedure DelIconFromTray; public
{ Public declarations }
end;
procedure CreateForm ; stdcall;
procedure DestroyForm ; stdcall;
var
DM: TDM;
implementation{$R *.dfm}procedure CreateForm ; stdcall;
begin
if DM = nil then
begin
DM := TDM.Create(Nil);
DM.Show;
end;
end;procedure DestroyForm ; stdcall;
begin
if DM <> nil then
DM.Free;
end;procedure TDM.AddIconToTray;
begin
ZeroMemory(@IconData, SizeOf(TNotifyIconData));
IconData.cbSize := SizeOf(TNotifyIconData);
IconData.Wnd := Handle;
IconData.uID := 1;
IconData.uFlags := NIF_MESSAGE or NIF_ICON or NIF_TIP;
IconData.uCallbackMessage := WM_TrayIcon;
IconData.hIcon := Self.Icon.Handle;
IconData.szTip := 'DLL托盘图标';
Shell_NotifyIcon(NIM_ADD, @IconData);
end;procedure TDM.DelIconFromTray;
begin
Shell_NotifyIcon(NIM_DELETE, @IconData);
end;procedure TDM.FormCreate(Sender: TObject);
begin
Self.AddIconToTray;
end;procedure TDM.FormDestroy(Sender: TObject);
begin
Self.DelIconFromTray;
end;end;
//调用方法(静态)
procedure CreateForm; stdcall; external DLLICON.dll'
procedure DestroyForm; stdcall; external DLLICON.dll'
//DLL
library DLLICON;uses
SysUtils,
Classes,
DLLForm in 'DLLForm.pas' {DM};//这里改正{$R *.res}
exports
CreateForm,
DestroyForm;
begin
end.