当前位置: 首页 > 编程语言 > C#

如何让OutlookCompose窗口置顶?分享

时间:2023-04-10 21:48:26 C#

如何让OutlookCompose窗口置顶?我正在创建outlook消息。有时OutlookCompose窗口出现在其他窗口后面。我怎样才能成为顶级?字符串地址="someone@example.com";Outlook.ApplicationoApp=newOutlook.Application();Outlook._MailItemoMailItem=(Outlook._MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);oMailItem.To=地址;oMailItem.Subject="帮助";oMailItem.BodyFormat=Outlook.OlBodyFormat.olFormatPlain;oMailItem.Attachments.Add("H:\file.txt");oMailItem.Body="给我打电话";//正文、密件抄送等..oMailItem.Display(true);我正在使用WinForm和.Net2.0(目标)首先,调用MailItem.GetInspector来获取Inspector对象(然后您可以调用Inspector.Display),其次,将Inspector转换为IOleWindow接口并调用IOleWindows::GetWindow来检索检查员的HWND。一旦你有了它,你就可以调用SetForegroundWindow。要记住的一件事是,如果父进程不在前台,Windows不会将窗口带到前台。需要用到AttachThreadInput函数——见下(Delphi):以上是C#学习教程:如何让OutlookCompose窗口置顶?如果分享的内容对你有用,需要进一步了解C#学习教程,希望大家多多关注——functionForceForegroundWindow(hWnd:THandle):BOOL;varhCurWnd:THandle;开始hCurWnd:=GetForegroundWindow;AttachThreadInput(GetWindowThreadProcessId(hCurWnd,nil),GetCurrentThreadId,True);结果:=SetForegroundWindow(hWnd);AttachThreadInput(GetWindowThreadProcessId(hCurWnd,nil),GetCurrentThreadId,False);结尾;联系管理员删除。如需转载请注明出处: