在delphi7中怎么使窗口最小化后显示到任务栏上?????
本人急切等待高人解答!!!!!!!
本人急切等待高人解答!!!!!!!
解决方案 »
- 为什么fastreport老提示EVariantTypeCastError ?
- delphi新手弱弱的问一下:TMediaPlay控件如何播放.dat .rm或.rmvb格式的文件?
- SocketConnection做三层,出现连接占线导致另外一个命令
- listview编辑问题
- 请问高手,我为什么读出的是空的阿?
- 请教这样的效果是用了什么控件?多谢。
- 问一个简单算法的思路(指派问题)
- 这个窗体为何老是显示,我该如何隐藏它,关于这个程序有什么好建议吗?
- Ehlib 的 DBGridEh 控件怎样才能像 dxDBGrid 控件那样输出文件到 EXCEL ?
- 怎样在注册表中搜索某一主键值(或者列出某一主键值下所以子键值的内容)
- 如何下载文件??80高分求!!
- 添加数据报错的问题?在线等待!!!!!!!!!!
begin
application.Minimize; //這樣不可以嗎?
end;
unit MainFrm;interface{ 记住在uses部分中包括 ShellAPI }
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ShellAPI, ExtCtrls;{ 自定义消息,当小图标捕捉到鼠标事件时 Windows 向回调函数发送此消息 }
const MY_MESSAGE = WM_USER + 100;type
TMainForm = class(TForm)
Timer1: TTimer;
procedure OnIconNotify(var Message: TMessage);
message MY_MESSAGE; procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormPaint(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
MainForm: TMainForm;implementation{$R *.dfm}{ 当小图标捕捉到鼠标事件时进入此过程 }
procedure TMainForm.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('真的要退出日志定时清楚程序吗?', '提示', MB_YESNO)=IDYES then
Close;
Busy := False;
end;
end;{ 当主Form建立时通知windows加入小图标 }
procedure TMainForm.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 := '定时清楚日志'; //提示字符串
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;{ 程序被关闭时通知windows去掉小图标 }
procedure TMainForm.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;{ 主窗口初始化完毕并显示时将激活 Paint 重画事件, 此时将主窗口隐藏 }
procedure TMainForm.FormPaint(Sender: TObject);
begin
Hide;
end;procedure TMainForm.Timer1Timer(Sender: TObject);
var
Hand : THandle;
begin
Hand := OpenEventLog('192.168.0.11','Application'); //打开本地日志
ClearEventLog(Hand,'c:\dd.evt'); //清除日志,指定备份文件
CloseEventLog(Hand); //关闭句柄
DeleteFile('c:\dd.evt'); //删除备份文件
Hand := OpenEventLog('192.168.0.11','System');
ClearEventLog(Hand,'c:\dd.evt');
CloseEventLog(Hand);
DeleteFile('c:\dd.evt');
end;end.
api也可以啊。