怎样把窗口最小化时,放到任务栏右边(50分)

  • 主题发起人 black_eagle
  • 开始时间
B

black_eagle

Unregistered / Unconfirmed
GUEST, unregistred user!
怎样把窗口最小化时,放到任务栏右边(即放到输入法旁边)[:)]
 
Systray而已。有源码,你搜索一下吧。实在不想的话,装个构件把,简单、明了。
如AHM构件组。
 
怎么搜索,地址?,关键字
 
很多控件包都有这个东东。
 
在DFW用全文搜索。
 
rx 控件包带有这个东东,不过那控件要自己响应窗口最小化事件。
 
我有个例子,完全符合你的要求,给我发信:gxcoo@163.com
 
Raise控件最好
 
var
Busy: Boolean;
begin
busy:=false;
if not Busy then
begin
busy := true;
if Message.LParam=WM_LBUTTONDOWN then
if Application.MessageBox('Are you sure','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.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;

{将程序的窗口样式设为TOOL窗口,可避免在任务条上出现}
SetWindowLong(Application.Handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW);
end;

……
delphi6+win98编译通过。。。
 
全部如下
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,shellapi;
{自定义消息,当小图标捕捉到鼠标事件时Windows向回调函数发送此消息}
const MY_MESSAGE = WM_USER + 100;
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
{ Public declarations }
end;

var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.OnIconNotify(var Message: TMessage);
var
Busy: Boolean;
begin
busy:=false;
if not Busy then
begin
busy := true;
if Message.LParam=WM_LBUTTONDOWN then
if Application.MessageBox('Are you sure','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.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;

{将程序的窗口样式设为TOOL窗口,可避免在任务条上出现}
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.cbSize := sizeof(nid);
// nid变量的字节数
nid.uID := 1;
//内部标识,与加入小图标时的数一致
nid.Wnd := Handle;
//主窗口句柄
Shell_NotifyIcon(NIM_DELETE,@nid);
//去掉小图标
Shell_NotifyIcon(NIM_DELETE,@nid);
//去掉小图标
end;

procedure TForm1.FormPaint(Sender: TObject);
begin
Hide;
end;

end.
 
顶部