.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Modal Form - ShowDialog

4 REPLIES 4
Reply
Message 1 of 5
Anonymous
548 Views, 4 Replies

Modal Form - ShowDialog

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.
4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: Anonymous

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.
Message 3 of 5
Anonymous
in reply to: Anonymous

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?
Message 4 of 5
Anonymous
in reply to: Anonymous

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?
Message 5 of 5
fantum
in reply to: Anonymous

>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?

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost