.NET

Reply
Active Contributor
Chris Ludtke
Posts: 44
Registered: ‎04-12-2005
Message 1 of 5 (257 Views)

Modal Form - ShowDialog

257 Views, 4 Replies
11-30-2005 08:19 AM
I am experiencing some "Random" issues related to showing a form in a project of mine.

I started out using the "ShowDialog" method of the form. This method proved to work well while debugging and initial testing. When my custom application was installed on a larger scale, about 70 percent of the installs would not show the dialog.

Here is something strange : on those installs, the form was not visible, but some of the "buttons" where available (I was able to activate controls via an invisible region of the AutoCAD screen)

After some research, I modified the code to use the "ShowDialog" method of the AutoCAD application. Here is methods that I used

Dim oPDFdialog As New frmPDFFileDia(Me, myDrawingFileName)
Dim oPDFDiaResult As System.Windows.Forms.DialogResult
oPDFDiaResult = Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(oPDFdialog.oForm)

....
I added this property to my form
Friend ReadOnly Property oForm() As System.Windows.Forms.Form
Get
oForm = CType(Me, System.Windows.Forms.Form)
End Get
End Property

I am reasonably sure that the form is not "behind" the AutoCAD Applications form. I can execute a "Ctrl-Tab" and "Activate". When this is done, I see nothing.

Do I need to do the following ?

You might try using SetWindowLong() from user32.dll with its second
parameter set to GWL_HWNDPARENT (-8) to tell your form that acad is its
parent.

If so, does anyone have an example?

Does anyone have any clues?
If I execute methods on the form that change Z-Order or visibility, does that override or cause problems with the showdialog method of
Autodesk.AutoCAD.ApplicationServices.Application

Any help would be appreciated.
*Tony Tanzillo
Message 2 of 5 (257 Views)

Re: Modal Form - ShowDialog

11-30-2005 09:36 AM in reply to: Chris Ludtke
It helps to understand how inheritance works
in a true OOP language.

Your frmPDFFileDia class is derived from the
System.Windows.Forms.Form class, so you do
not need to expose a property of that type on
the form. You should be able to pass 'Me' as
the Form parameter (or 'Me As Form') to the
ShowModalDialog() method and your form
should appear.

There is no need to use SetWindowLong to set
the owner window if you call ShowModalDialog,
because the latter does that for you.


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

wrote in message news:5025641@discussion.autodesk.com...
I am experiencing some "Random" issues related to showing a form in a project of mine.

I started out using the "ShowDialog" method of the form. This method proved to work well while debugging and initial testing. When my custom application was installed on a larger scale, about 70 percent of the installs would not show the dialog.

Here is something strange : on those installs, the form was not visible, but some of the "buttons" where available (I was able to activate controls via an invisible region of the AutoCAD screen)

After some research, I modified the code to use the "ShowDialog" method of the AutoCAD application. Here is methods that I used

Dim oPDFdialog As New frmPDFFileDia(Me, myDrawingFileName)
Dim oPDFDiaResult As System.Windows.Forms.DialogResult
oPDFDiaResult = Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(oPDFdialog.oForm)

....
I added this property to my form
Friend ReadOnly Property oForm() As System.Windows.Forms.Form
Get
oForm = CType(Me, System.Windows.Forms.Form)
End Get
End Property

I am reasonably sure that the form is not "behind" the AutoCAD Applications form. I can execute a "Ctrl-Tab" and "Activate". When this is done, I see nothing.

Do I need to do the following ?

You might try using SetWindowLong() from user32.dll with its second
parameter set to GWL_HWNDPARENT (-8) to tell your form that acad is its
parent.

If so, does anyone have an example?

Does anyone have any clues?
If I execute methods on the form that change Z-Order or visibility, does that override or cause problems with the showdialog method of
Autodesk.AutoCAD.ApplicationServices.Application

Any help would be appreciated.
Active Contributor
Chris Ludtke
Posts: 44
Registered: ‎04-12-2005
Message 3 of 5 (257 Views)

Re: Modal Form - ShowDialog

11-30-2005 10:14 AM in reply to: Chris Ludtke
Thanks Tony,

I started with this ...

Dim oPDFDiaResult As System.Windows.Forms.DialogResult
oPDFDiaResult = Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(oPDFdialog)

I used the "ctype" function only as an effort to fix the problem after the above did not work outside of the debug mode (this has worked with other API's resolving some issues) Note that the anomolies occur on about 70% of the machines that I have this application loaded onto.

The ShowDialog method is executed from a class that does not contain the "Command Method" subroutine.

There are other command line options for ShowDialog. Is it possible that the Parent Form is not being correctly identified.

I would assume that (in this case) the parent form should be the AutoCAD application. How would I get the IWin32Window for the AutoCAD application?

Also, this form contains controls that I created. Do I need to use the AutoCAD application to perform ShowDialog functions that are spawned from the original form (whose parent is not the AutoCAD application?
*Tony Tanzillo
Message 4 of 5 (257 Views)

Re: Modal Form - ShowDialog

11-30-2005 03:29 PM in reply to: Chris Ludtke
Do not use the ShowDialog method to display a form.

Use the ShowModalDialog method of the Application object.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

wrote in message news:5025774@discussion.autodesk.com...
Thanks Tony,

I started with this ...

Dim oPDFDiaResult As System.Windows.Forms.DialogResult
oPDFDiaResult = Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(oPDFdialog)

I used the "ctype" function only as an effort to fix the problem after the above did not work outside of the debug mode (this has worked with other API's resolving some issues) Note that the anomolies occur on about 70% of the machines that I have this application loaded onto.

The ShowDialog method is executed from a class that does not contain the "Command Method" subroutine.

There are other command line options for ShowDialog. Is it possible that the Parent Form is not being correctly identified.

I would assume that (in this case) the parent form should be the AutoCAD application. How would I get the IWin32Window for the AutoCAD application?

Also, this form contains controls that I created. Do I need to use the AutoCAD application to perform ShowDialog functions that are spawned from the original form (whose parent is not the AutoCAD application?
Distinguished Contributor
fantum
Posts: 313
Registered: ‎12-06-2004
Message 5 of 5 (257 Views)

Re: Modal Form - ShowDialog

12-01-2005 08:40 AM in reply to: Chris Ludtke
>Here is something strange : on those installs, the form was not
>visible, but some of the "buttons" where available (I was able to
>activate controls via an invisible region of the AutoCAD screen)

Are all installs on identical OS's?

What's the setting for the .Opacity() property of the form and is it changed at run-time?
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.