开发者

How do I ensure the MAPI client receives focus when I launch it?

I've got a function that launches a user's default e-mail program开发者_如何学Python via MAPI. The mail program usually launches on top of my app, but sometimes it doesn't; sometimes my application remains on top of the desktop display. Is there any way to assure the user's e-mail program will launch on top of the desktop, not buried behind other open applications?


you need to find the window wich you want to be on top using findwindow api an then call setforegroundwindow api


I think ShellExecute with SW_SHOWNORMAL or SW_SHOW flag is the best solution you can do. In combination with mailto: argument it will be something like that:

ShellExecute(Self.Handle, nil, '"mailto:somebody@example.com?subject=This is ' +
  'the subject&body=The message''s first paragraph.%0ASecond paragraph.%0AThird ' +
  'Paragraph."', nil, nil, SW_SHOWNORMAL);

Of course this method can be used only for creating simple messages.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜