Outlook WPF Add-In

I created an add-in for Outlook using WPF. Everything works correctly, except for "Flare". When the WPF window opens, it will not focus on the Outlook form; it opens in the center of the screen. I have a WindowStartLocation installed for CenterOwner, but this does not seem to do the trick.

0
source share
3 answers

You can get a link 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.

Something similar to:

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 

This assumes that the Outlook window is on the first monitor and is maximized. Another logic must be written to take care of other unforeseen circumstances.

0
source

My solution, with Corey's guide:

 var sendToPulse = new Pulse_Outlook_Presentation.SendToPulse (); var interopApplication = Globals.ThisAddIn.Application; var x = (interopApplication.ActiveWindow ().Left + interopApplication.ActiveWindow ().Width / 2) - (sendToPulse.Width / 2); var y = (interopApplication.ActiveWindow ().Top + interopApplication.ActiveWindow ().Height / 2) - (sendToPulse.Height / 2); OutlookWin32Window parentWindow = new OutlookWin32Window (Globals.ThisAddIn.Application.ActiveWindow ()); sendToPulse.Left = x; sendToPulse.Top = y; 
+2
source

Scroll this search for the VBA answer - in its simplest form, where the application is the host and I am the shortcut for the current form.

 Private Sub UserForm_Initialize() ProgressFrame.Caption = "" Me.Left = Application.ActiveWindow().Left + Application.ActiveWindow().Width / 2 - (Me.Width / 2) Me.Top = Application.ActiveWindow().Top + Application.ActiveWindow().Height / 2 - (Me.Height / 2) End Sub 
0
source

Source: https://habr.com/ru/post/1397694/


All Articles