Center Outlook WPF加载项 [英] Center Outlook WPF Add-In

查看:78
本文介绍了Center Outlook WPF加载项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用WPF为Outlook创建了一个加载项.一切正常,除了耀斑".当打开WPF窗口时,它不在Outlook窗体的中心,而是在屏幕上的中心打开.我已经将WindowStartLocation设置为CenterOwner,但这似乎并没有解决问题.

I have created an Add-In for Outlook using WPF. Everything is working correctly, except for the "Flare." When the WPF Window opens, it's not being centered on the Outlook form, it opens centered on the screen. I have the WindowStartLocation set to CenterOwner, but this doesn't seem to be doing the trick.

推荐答案

您应该能够获得对Outlook当前实例的引用,访问该实例的Application对象,并获得Window的大小和位置(左,顶部),并做一些数学运算以获取窗口的位置.

You should be able to get a reference to the current instance of Outlook, access the Application object for that instance and get the Window size, and location (Left, Top) and do some math to get the positioning for your window.

类似于:

Dim interopApplication As Outlook.Application = _
    Me.ActiveExplorer().Application

With interopApplication.ActiveWindow
    Dim _left = Me.Width - (.Width / 2)
    Dim _top = Me.Height - (.Height / 2)
End With

这假定Outlook窗口位于第一台监视器上并且已最大化.必须编写一些更多的逻辑来照顾其他意外情况

This supposes that the Outlook window is on the first monitor and is maximized. Some more logic will have to be written to take care of other contingencies

这篇关于Center Outlook WPF加载项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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