问题1:上面的回答应该可以满足,GetTickCount是个有趣而且好用的函数。如果你的机器
是server,可以用它来检测系统长期运行的时间。
问题2:如果只是最小化图标回到托盘区,已经有很多解答,这里提供一段代码实现图标在
托盘区时程序最大化及最小化时的动态过程(即不是瞬间最大最小化,有普通窗口的动画过
程)
unit TestForm
interface
uses
Windows, Classes, Forms, Controls, StdCtrls, ExtCtrls
type
TZoomAction = (zaMinimize, zaMaximize)
TfrmTest = class(TForm)
procedure FormClose(Sender: TObject
var Action: TCloseAction)
procedure FormShow(Sender: TObject)
private
{ Private declarations }
public
{ Public declarations }
end
var
frmTest: TfrmTest
implementation
{$R *.DFM}
procedure ZoomEffect(theForm: TForm
theOperation: TZoomAction)
var
rcStart: TRect
rcEnd: TRect
rcTray: TRect
hwndTray : hWnd
hwndChild: hWnd
begin
{ Find the system tray area bounding rectangle }
hwndTray := FindWindow('Shell_TrayWnd', nil)
hwndChild := FindWindowEx(hwndTray, 0, 'TrayNotifyWnd', nil)
GetWindowRect(hwndChild, rcTray)
{ Check for minimize/maximize and swap start/end}
if theOperation = zaMinimize then
begin
rcStart := theForm.BoundsRect
rcEnd := rcTray
end
else
begin
rcEnd := theForm.BoundsRect
rcStart := rcTray
end
{ Here the magic happens... }
DrawAnimatedRects(theForm.Handle, IDANI_CAPTION, rcStart, rcEnd)
end
procedure TfrmTest.FormClose(Sender: TObject
var Action: TCloseAction)
begin
ZoomEffect(Self, zaMinimize)
end
procedure TfrmTest.FormShow(Sender: TObject)
begin
ZoomEffect(Self, zaMaximize)
end
end.