如何在Outlook撰写窗口最上面的? [英] how to make the Outlook Compose window top most?

查看:215
本文介绍了如何在Outlook撰写窗口最上面的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建一个Outlook邮件。有时会出现在Outlook撰写窗口的后面其他窗口。

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 = "someone@example.com";

Outlook.Application oApp = new Outlook.Application();
Outlook._MailItem oMailItem = (Outlook._MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);
oMailItem.To = address;

oMailItem.Subject = "Help";

oMailItem.BodyFormat = Outlook.OlBodyFormat.olFormatPlain;
oMailItem.Attachments.Add("H:\\file.txt");

oMailItem.Body = "Call me";  
// body, bcc etc...
oMailItem.Display(true);



我使用的WinForm和.NET 2.0(目标)

I am using WinForm and .Net 2.0 (target)

推荐答案

首先,请拨打MailItem.GetInspector得到检查对象(然后你可以叫Inspector.Display),其次,投给督察IOleWindow的接口并调用IOleWindows :: GetWindow来检索检查员的HWND。一旦你有,你可以调用SetForegroundWindow。有一点要记住的是,Windows将n要将该窗口置于前台,如果父进程是不是在前台。您将需要使用AttachThreadInput函数,该函数 - 见下文(德尔福):

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;

这篇关于如何在Outlook撰写窗口最上面的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆