主页 > 编程资料 > Delphi >
发布时间:2015-09-22 作者:网络 阅读:156次

Delphi使程序的窗口出现在最前面并激活
var
pt, OldPt, NewPt: TPoint;
begin
//判断Application是否最小化,而不是主窗口的Handle, 使用Restore来还原
if IsIconic(Application.Handle) then
Application.Restore;

SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE or SWP_NOMOVE,',',');
SetWindowPos(Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE or SWP_NOMOVE,',',');

// 保存鼠标位置,模拟点击窗口,然后再还原鼠标位置
GetCursorPos(OldPt,',',');
NewPt:=Point(0, 0,',',');
Windows.ClientToScreen(Handle, NewPt,',',');
SetCursorPos(NewPt.X, NewPt.Y,',',');
mouse_event(MOUSEEVENTF_LEFTDOWN, NewPt.X, NewPt.Y, 0, 0,',',');
mouse_event(MOUSEEVENTF_LEFTUP, NewPt.X, NewPt.Y, 0, 0,',',');
SetCursorPos(OldPt.X, OldPt.Y,',',');
end;
关键字词: