If you are displaying a message box inside Excel, then Excel is the owner by default.
For this reason you do not need to use the owner parameter inside a VSTO add-in.
Assigning the owner parameter has nothing to do with displaying in the centre of the parent.

System.Windows.Forms.IWin32Window owner; 
owner = new WindowWrapper(new IntPtr(Globals.ThisAddIn.Application.Hwnd));

   "This is a message",
   "Message Box Caption",

public class WindowWrapper : System.Windows.Forms.IWin32Window
    private IntPtr _hwnd;
    public WindowWrapper(IntPtr handle)
        _hwnd = handle;
    public IntPtr Handle
        get { return _hwnd; }

© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext