AutoCAD is not responsive after closing customized dialog.

AutoCAD is not responsive after closing customized dialog.

MarkJamesRogolino
Advocate Advocate
548 Views
4 Replies
Message 1 of 5

AutoCAD is not responsive after closing customized dialog.

MarkJamesRogolino
Advocate
Advocate

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.

0 Likes
Accepted solutions (1)
549 Views
4 Replies
Replies (4)
Message 2 of 5

norman.yuan
Mentor
Mentor
Accepted 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.

 

Norman Yuan

Drive CAD With Code

EESignature

Message 3 of 5

ActivistInvestor
Mentor
Mentor

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.

0 Likes
Message 4 of 5

_gile
Consultant
Consultant

Hi,

You may find inspiration in these examples of AutoCAD user interfaces.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 5 of 5

MarkJamesRogolino
Advocate
Advocate

Thank you, _gile

0 Likes