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

Centre form in AutoCAD Window

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
SRSDS
1702 Views, 4 Replies

Centre form in AutoCAD Window

Hi,

 

How do I position a form in the center of the AutoCAD application?

Often users have two monitor screens and the form loads in the primrary screen instead of the one they are using.

4 REPLIES 4
Message 2 of 5
fieldguy
in reply to: SRSDS

It depends.  What type of form is it?  Do you need user input other than Yes / No?

 

http://msdn.microsoft.com/en-CA/library/aa984358(v=vs.71).aspx

 

http://msdn.microsoft.com/en-us/library/aa984420(v=vs.71).aspx

 

 

Message 3 of 5
SRSDS
in reply to: fieldguy

A modal form but the problem is that I would like to show the form on the monitor that AutoCAD appears on.

ShowModalDialog and ShowModelessDialog both show the form on the primary screen. and not the  screen that AutoCAD appears on.

Message 4 of 5
fieldguy
in reply to: SRSDS

Try the windows form showdialog like this.

 

myform.StartPosition = FormStartPosition.CenterParent;
myform.ShowDialog();

Message 5 of 5
norman.yuan
in reply to: fieldguy

Dialog box in AutoCAD should be shown using Application.ShowModal[Modeless]Dialog(), rather than Windows.Forms.Form.Show()/ShowDialog().

 

Application.ShowModal[Modeless]Dialog() has 3 overrides, unless you use the one that has  a third boolean argument being false, AutoCAD will remember the dialog box's position when it closes, and show at the same position next time the dialog box is called up.

 

If you need to write code to position the dialog box, you can have code in Form's Shown event handler to set form's position regardless if AutoCAD remember the form previous position or not.

 

You can use Widows.Forms.Screen class to iterate through all screens and find primary screen. You can also use Application.MainWindow to find out main AutoCAD window's size/location. With all this information in hand, you can then place your dialog box at the position you want.

Norman Yuan

Drive CAD With Code

EESignature

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

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report