问题
My goal is to use Form as progress bar of the Visio Application during some long actions.
Which means, the Form should be display on top of the Visio Application.
I also need the Form as non modal dialog (means not Form.ShowDialog()
) in order to letting the Visio app to continue works while the Form is appeares.
I've already tried the following steps:
- Create a wrapper class that implements the IWin32Window.
public class WindowWrapper : System.Windows.Forms.IWin32Window
{
public WindowWrapper(IntPtr handle)
{
_hwnd = handle;
}
public WindowWrapper(Window window)
{
_hwnd = new WindowInteropHelper(window).Handle;
}
public IntPtr Handle
{
get { return _hwnd; }
}
private IntPtr _hwnd;
}
from here
- Passing the Application.WindowHandle as the owner as follows:
myForm = new Form();
myForm .Show(new WindowWrapper(new IntPtr(Application.WindowHandle)));
from here
but unfortunately, the Application.WindowHandle
Does not work well for a particular computer and throws some error (If necessary, i believe i can reproduce it and quote the error/exception).
When i tried the Application.WindowHandle32
instead of Application.WindowHandle
there is no error, but the Form go behind the Visio Application instead of display on top of the Visio.
Please help, how can i cause the Form to display on top of the Visio for using the Form as progress bar?
Can you please do some order and explain for me the differences between the following properties of the Visio Application?
Application.WindowHandle
Application.WindowHandle32
Application.InstanceHandle
Application.InstanceHandle32
Application.InstanceHandle64
来源:https://stackoverflow.com/questions/61988104/how-to-use-form-showiwin32window