In a managed class implemented as a com object, I want to pass a window handle from the client into the com object and use it as the parent of a form shown as a dialog. How can I convert the handle (passed as a long) into a IWin32Window object
IWin32Window is an interface so you will have to create a class which
implements this interface and then use this class for your stuff.
internal class MyNativeWindow : IWin32Window
{
private IntPtr m_MyHandle;
internal MyNativeWindow (long handle)
{
m_MyHandle = new IntPtr(handle);
}
public System.IntPtr Handle
{
get
{
return m_MyHandle;
}
}
}
and when you want to show the dialog,
Form f = new YourForm(); //create your form
ParentWindow = new MyNativeWindow (<whatever handle value you have got>);
f.ShowDialog(ParentWindow);
HTH,
--Saurabh
> In a managed class implemented as a com object, I want to pass a window handle from the client into the com object and use it as the parent of a
form shown as a dialog. How can I convert the handle (passed as a long)
into a IWin32Window object.
Clyde LeFevre - 03 Jun 2004 15:54 GMT
Thanks, that looks just what I need.