Owner
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));
System.Windows.Forms.MessageBox.Show(
owner,
"This is a message",
"Message Box Caption",
System.Windows.Forms.MessageBoxButtons.OK,
System.Windows.Forms.MessageBoxIcon.Stop);
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