Hello, everyone.
I have a small autocad plugin including license checking dialog.
I wanna make to request license key so it shows customized modal dialog before some commands work.
but after license key dialog exit AutoCAD does not work and not responsive.
my codes are followings.
IntPtr acadHandle = Application.MainWindow.Handle;
using(LicenseForm licfrm = new LicenseForm())
{
NativeWindow nativeWindow = new NativeWindow();
nativeWindow.AssignHandle(acadHandle);
licfrm.ShowDialog(nativeWindow);
nativeWindow.ReleaseHandle();
}
return;
How to solve it? I am enclosing working video.
Solved! Go to Solution.
Solved by norman.yuan. Go to Solution.
Firstly, you should not call Show()/ShowDialog() from you LicenseForm (be it WinForm, or WPF dialog box). Instead, call:
Application.ShowModal[Modeless]Dialog[Winodw]() method.
Secondly, you did not say/show anything about NativeWindow class, but I suspect it is the cause of the hanging,
Anyway, if you use Application.ShowModalDialog(), your UI (LicenseForm) would automatically owned by AutoCAD's main window inexplicitly, or you can pass the main window's handle to explicitly make the main window as the dialogbox's owner. Whichever overloaded method you call, you would not have the "hanging" issue.
NativeWindow is just a wrapper for a window handle, and shouldn't be needed for what you're doing. You should follow @norman.yuan's advice for showing a modal dialog.
Can't find what you're looking for? Ask the community or share your knowledge.