How to bring my application to the front?

后端 未结 8 682
孤城傲影
孤城傲影 2020-12-08 15:32

I know all the reasons why it is a bad idea. I dislike it if an application steals input focus, but this is for purely personal use and I want it to happen; it will not dist

8条回答
  •  無奈伤痛
    2020-12-08 16:05

    function WinActivate(const AWinTitle: string): boolean;
    var
      _WindowHandle: HWND;
    begin
      Result := false;
      _WindowHandle := FindWindow(nil, PWideChar(AWinTitle));
      if _WindowHandle <> 0 then
      begin
        if IsIconic(_WindowHandle) then
          Result := ShowWindow(_WindowHandle, SW_RESTORE)
        else
          Result := SetForegroundWindow(_WindowHandle);
      end;
    end;
    
    if WinActivate(self.Caption) then
      ShowMessage('This works for me in Windows 10');
    

提交回复
热议问题