如何让图标缩小在右下角(100分)

  • 主题发起人 xiaoyudelphi
  • 开始时间
A

apple_ge

Unregistered / Unconfirmed
GUEST, unregistred user!
前面那位叫thong_517的仁兄,你也太不负责任了吧
抓来的程序根本就不对,本人运行过了,图标并没有显示在系统栏。
我这有本人以前写过的一段代码,运行过的,绝对正确。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ShellAPI;
const MY_MESSAGE=34098;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
procedure FormPaint(Sender: TObject);
private
procedure OnIconNotify(var Message: TMessage);
message MY_MESSAGE;
public
{}
end;

var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.OnIconNotify(var Message: TMessage);
const
Busy:Boolean = false;
begin
if not Busy then
begin
Busy := true;
if Message.LParam=WM_LBUTTONDOWN then
if Application.MessageBox('Are you sure to exit the application?','Exit', MB_YESNO)=IDYES then
Close;
Busy := false;
end;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
nid: TNotifyIconData;
begin
nid.cbSize := sizeof(nid);
// nid变量的字节数
nid.Wnd := Handle;
// 主窗口句柄
nid.uID := 1;
// 内部标识,可设为任意数
nid.hIcon := Application.Icon.Handle;
// 要加入的图标句柄,
nid.szTip := 'This is a test application';
// 提示字符串
nid.uCallbackMessage := MY_MESSAGE;
// 回调函数消息
nid.uFlags := NIF_ICON or NIF_TIP or NIF_MESSAGE;
// 指明哪些字段
if not Shell_NotifyIcon(NIM_ADD, @nid) then
begin
ShowMessage('Failed!');
Application.Terminate;
end;

SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
end;

procedure TForm1.FormClose(Sender: TObject;
var Action: TCloseAction);
var
nid: TNotifyIconData;
begin
nid.cbSize := sizeof(nid);
// nid变量的字节数
nid.uID := 1;
//内部标识,与加入小图标时的数一致
nid.Wnd := Handle;
//主窗口句柄
Shell_NotifyIcon(NIM_DELETE, @nid);
//去掉小图标
end;

procedure TForm1.FormPaint(Sender: TObject);
begin
//隐藏应用程序窗口
Hide;
end;

end.
 

拓荒国

Unregistered / Unconfirmed
GUEST, unregistred user!

李衍智

Unregistered / Unconfirmed
GUEST, unregistred user!
本身系统就带TrayIcon控件呀。何必找,设置几个属性就解决了。
 

花 儿

Unregistered / Unconfirmed
GUEST, unregistred user!
有控件的
 
G

gxcooo

Unregistered / Unconfirmed
GUEST, unregistred user!
rxlib里有TrayIcon控件
 
B

bubble

Unregistered / Unconfirmed
GUEST, unregistred user!
多人接受答案了。
 

Similar threads

S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
990
DelphiTeacher的专栏
D
顶部