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

ShowModalDialog question.....

5 REPLIES 5
Reply
Message 1 of 6
Natalie-C
1296 Views, 5 Replies

ShowModalDialog question.....

Im using ShowModalDialog to open up my form. Question, is it possible to specify the location you want the form to open?

Thanks in advance for any help!!
5 REPLIES 5
Message 2 of 6
Anonymous
in reply to: Natalie-C

This will place the dialog box at upper-left corner of the screen

MyDialogBox dlg = new MyDialogBox()

dlg.Left = Screen.PrimaryScreen.Bounds.Left + 50;

dlg.Top = Screen.PrimaryScreen.Bounds.Top + 50

if
(Autodesk.AutoCad.ApplicationServices.Application.ShowModalDialog(dlg)==DialogResult.OK)

{

//Do something when dialog dismissed, if you wish

}

dlg.Dispose();





wrote in message news:5303932@discussion.autodesk.com...
Im using ShowModalDialog to open up my form. Question, is it possible to
specify the location you want the form to open?

Thanks in advance for any help!!
Message 3 of 6
Natalie-C
in reply to: Natalie-C

That doesn't seem to work?

This is my code:

Dim legendFormAs Legend1 = New Legend1()
'----TRIED DIFFERENT THINGS HERE-----
Application.ShowModalDialog(legendForm)

Things that I've tried are:

legendForm.CenterToScreen()

legendForm.Left = Windows.Forms.Screen.PrimaryScreen.Bounds.Left+5
legendForm.Top = Windows.Forms.Screen.PrimaryScreen.Bounds.Top+5

legendForm.StartPosition = Windows.Forms.FormStartPosition.CenterScreen

None of the above seem to effect the position of the form?
Message 4 of 6
Anonymous
in reply to: Natalie-C

The reason is because AutoCAD manages the size/location
of your window for you, persists it in the registry, and then
restores it when you show the same form again, keyed to
the string returned by GetType().FullName on your form.

The ShowModalDialog() method is overloaded. Call the one
that takes the optional bool parameter, and pass false to
prevent it from persisting your forms size/position.

--
http://www.caddzone.com

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

wrote in message news:5304050@discussion.autodesk.com...
That doesn't seem to work?

This is my code:

Dim legendFormAs Legend1 = New Legend1()
'----TRIED DIFFERENT THINGS HERE-----
Application.ShowModalDialog(legendForm)

Things that I've tried are:

legendForm.CenterToScreen()

legendForm.Left = Windows.Forms.Screen.PrimaryScreen.Bounds.Left+5
legendForm.Top = Windows.Forms.Screen.PrimaryScreen.Bounds.Top+5

legendForm.StartPosition = Windows.Forms.FormStartPosition.CenterScreen

None of the above seem to effect the position of the form?
Message 5 of 6
Anonymous
in reply to: Natalie-C

I works for me. I have a modal dialog, when it is shown, a selected entity
in the Editor is zoomed to screen centre, so I place the dialog at
upper-left corner of the screen. It works always.

Note, if you need to specify a Win Form's location in code when it is
loaded, you need to set the Form's "StartPosition" property to "Manual".

wrote in message news:5304050@discussion.autodesk.com...
That doesn't seem to work?

This is my code:

Dim legendFormAs Legend1 = New Legend1()
'----TRIED DIFFERENT THINGS HERE-----
Application.ShowModalDialog(legendForm)

Things that I've tried are:

legendForm.CenterToScreen()

legendForm.Left = Windows.Forms.Screen.PrimaryScreen.Bounds.Left+5
legendForm.Top = Windows.Forms.Screen.PrimaryScreen.Bounds.Top+5

legendForm.StartPosition = Windows.Forms.FormStartPosition.CenterScreen

None of the above seem to effect the position of the form?
Message 6 of 6
Natalie-C
in reply to: Natalie-C

Yes!! That was it. I overloaded it and set it to False and that allowed me to set the position of the window.

Thanks everyone!!!

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