The Windows Form Method
This is how its done on Windows Forms forms, fairly straight forward.
//apphandle is the application handle for your Win32 application
IntPtr windowHandle = new IntPtr(Convert.ToInt32(apphandle));
WindowHandleWrapper windowWrapper = new WindowHandleWrapper(windowHandle);
MyWinForm = new MyForm();
MyWinForm.ShowDialog(windowWrapper);
But WPF forms don't support
public DialogResult ShowDialog(IWin32Window owner);
Doing this for WPF Forms
You do this by setting the owner of the WPF window/form.
// apphandle is the application handle for your Win32 application
IntPtr FormHandle = new IntPtr(Convert.ToInt32(apphandle));
// Create new WPF Form
var app = new MyWpfWindow();
// New Helper
var helper = new WindowInteropHelper(app);
// Point the FormHandle to owner of the
helper.Owner = FormHandle;
app.ShowDialog();
Easy eh ?
No comments:
Post a Comment
Comments are welcome, but are moderated and may take a wee while before shown.