I resolve the problem with use IWin32Window
interface instead NativeWindow
:
public class Win32Window : System.Windows.Forms.IWin32Window
{
public Win32Window(int windowHandle)
{
_windowHandle = new IntPtr(windowHandle);
}
IntPtr _windowHandle;
public IntPtr Handle
{
get { return _windowHandle; }
}
}
After this I change form initialize code below:
private void button1_Click(object sender, RibbonControlEventArgs e)
{
// initialize form
var frm = new Form();
frm.FormBorderStyle = FormBorderStyle.FixedSingle;
frm.MinimizeBox = false;
frm.MaximizeBox = false;
frm.Text = "Test Form";
frm.StartPosition = FormStartPosition.CenterScreen;
Forms.Add(frm);
// create the native window handle
var nw = new Win32Window(Globals.ThisAddIn.Application.Hwnd);
// show with owner
frm.Show(nw);
}