Author Topic: Changing the document window size via VB.net in 2013  (Read 2507 times)

0 Members and 1 Guest are viewing this topic.

BrianM

  • Guest
Changing the document window size via VB.net in 2013
« on: September 21, 2012, 09:58:49 AM »
I'm having an issue on a small program that I thought I would post here to see if anyone can provide some help. I'm trying to change the size of the AutoCAD document window with a simple program in vb.net.

Here's the code I have, which I beleive will work in earlier releases. Most of the code came from the AutoCAD DevBlog.

Dim doc As Document = Application.DocumentManager.MdiActiveDocument()

          Dim docWindow As Window = doc.Window

            Dim size As Size = docWindow.Size

            docWindow.WindowState = Window.State.Normal

            docWindow.Size = New Size(950, 580)

Window is a class of Autodesk.AutoCAD.Windows. However, there is no property, or method for changing the size. I have not been able to find a way to change the size in any other namespaces. I know I've done this in earlier releases. I'm sure I'm overlooking something simple. If anyone can provide some input I would greatly appreciate it.

Thanks
BrianM

TheMaster

  • Guest
Re: Changing the document window size via VB.net in 2013
« Reply #1 on: September 21, 2012, 01:25:47 PM »
I'm having an issue on a small program that I thought I would post here to see if anyone can provide some help. I'm trying to change the size of the AutoCAD document window with a simple program in vb.net.

Here's the code I have, which I beleive will work in earlier releases. Most of the code came from the AutoCAD DevBlog.

Dim doc As Document = Application.DocumentManager.MdiActiveDocument()

          Dim docWindow As Window = doc.Window

            Dim size As Size = docWindow.Size

            docWindow.WindowState = Window.State.Normal

            docWindow.Size = New Size(950, 580)

Window is a class of Autodesk.AutoCAD.Windows. However, there is no property, or method for changing the size. I have not been able to find a way to change the size in any other namespaces. I know I've done this in earlier releases. I'm sure I'm overlooking something simple. If anyone can provide some input I would greatly appreciate it.

Thanks
BrianM

It's important to note what release you're using (you mention 'earlier releases' only).

In AutoCAD 2013, you have to use the SetSize() extension method of the WindowExtension class.

I've noticed that there are some problems with VB.NET recognizing extension methods from the AutoCAD APIs, and I'm not entirely sure what that's about, but assuming you can get VB.NET to recognize those extension methods, here is what you have to do in 2013:

Code - Visual Basic: [Select]
  1.  
  2.    ' Imports Autodesk.AutoCAD.Windows
  3.  
  4.    Dim docWindow As Window = doc.Window
  5.    Dim size As Size = docWindow.Size
  6.    docWindow.WindowState = Window.State.Normal
  7.    docWindow.SetSize( New Size(950, 580) )
  8.  
  9.  

If you get an error when you try to compile this, then it's a problem with VB.net not recognizing extension methods, and you will instead have to use the method directly like this:

Code - Visual Basic: [Select]
  1.  
  2.    ' Imports Autodesk.AutoCAD.Windows
  3.  
  4.    Dim docWindow As Window = doc.Window
  5.    Dim size As Size = docWindow.Size
  6.    docWindow.WindowState = Window.State.Normal
  7.    WindowExtension.SetSize( docWindow, New Size(950, 580) )
  8.  
  9.  

« Last Edit: September 23, 2012, 06:50:29 PM by TT »