function LockSetForegroundWindow; external 'user32.dll' name 'LockSetForegroundWindow';
function wdSetForegroundWindow(Handle: THandle): Boolean;
begin
//-----------------------------------------------------
//作者:linzhenqun
//时间:2006-11-1
//说明:使Win98以上的窗口都可以设置Foreground的函数
//-----------------------------------------------------
if ((Win32Platform = VER_PLATFORM_WIN32_NT) and (Win32MajorVersion> 4))//up win 2000
or ((Win32Platform = VER_PLATFORM_WIN32_WINDOWS) and //up win 98
((Win32MajorVersion > 4) or
((Win32MajorVersion = 4) and
(Win32MinorVersion > 0)))) then
LockSetForegroundWindow(LSFW_UNLOCK);
Result := SetForegroundWindow(Handle);
end;
现在你在时间事件中写下如下代码:
Application.Restore;
wdSetForegroundWindow(Handle);
那么,窗口就可以自己激活自己了,爽吧!