how to make the Outlook Compose window top most?

后端 未结 1 1388
醉梦人生
醉梦人生 2020-12-22 06:51

I am creating an Outlook Message. Sometimes the Outlook Compose window appears behind other windows.

How can I make it the top most?

String address =         


        
相关标签:
1条回答
  • 2020-12-22 07:19

    Firstly, call MailItem.GetInspector to get the Inspector object (you can then call Inspector.Display), secondly, cast Inspector to IOleWindow interface and call IOleWindows::GetWindow to retrieve the inspector's HWND. Once you have that, you can call SetForegroundWindow. One thing to keep in mind is that Windows will nto bring the window to the foreground if the parent process is not in the foreground. You would need to use AttachThreadInput function for that - see below (Delphi):

    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;
    
    0 讨论(0)
提交回复
热议问题