function ForceForegroundWindow(HWND: THandle): BOOL; var hCurWnd: THandle; begin hCurWnd := GetForeGroundWindow; AttachThreadInput( GetWindowThreadProcessID(hCurWnd, nil), GetCurrentThreadID, True); Result := SetForegroundWindow(HWND); AttachThreadInput( GetWindowThreadProcessID(hCurWnd, nil), GetCurrentThreadID, False); end;procedure BringSelfToFront; begin if IsIconic(Application.handle) then Application.Restore else ForceForegroundWindow(Application.handle); end;
自己看看吧,什么Restore,Maximize,BringToFront,等等。
frmMain.SetFocus;
PostMessage(frmMain.Handle,WM_SYSCOMMAND,SC_MAXIMIZE,0);
Application.BringToFront;我做了这样的操作,还是不行!
var
hCurWnd: THandle;
begin
hCurWnd := GetForeGroundWindow;
AttachThreadInput(
GetWindowThreadProcessID(hCurWnd, nil),
GetCurrentThreadID,
True);
Result := SetForegroundWindow(HWND);
AttachThreadInput(
GetWindowThreadProcessID(hCurWnd, nil),
GetCurrentThreadID,
False);
end;procedure BringSelfToFront;
begin
if IsIconic(Application.handle) then
Application.Restore
else
ForceForegroundWindow(Application.handle);
end;