ShowModalDialog question.....

ShowModalDialog question.....

Anonymous
Not applicable
1,569 Views
5 Replies
Message 1 of 6

ShowModalDialog question.....

Anonymous
Not applicable
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!!
0 Likes
1,570 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
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!!
0 Likes
Message 3 of 6

Anonymous
Not applicable
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?
0 Likes
Message 4 of 6

Anonymous
Not applicable
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
Not applicable
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

Anonymous
Not applicable
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!!!