Window.State is Error

Window.State is Error

classof
Contributor Contributor
1,783 Views
8 Replies
Message 1 of 9

Window.State is Error

classof
Contributor
Contributor

Hello~

I study dotnet.

so, I referenced "AutoCAD .NET Developer's Guide".

but, I have a problem. I don't know why.

below code has Error.

below code copied from "AutoCAD .NET Developer's Guide".

please help me.


using System;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Windows;
using Autodesk.AutoCAD.Runtime;
using System.Drawing;


namespace ClassLibrary1
{
    public class Class1
    {
        [CommandMethod("MinMaxApplicationWindow")]
        public static void MinMaxApplicationWindow()
        {
            // Minimize the Application window
            Application.MainWindow.WindowState = Window.State.Minimized;  //Error
            System.Windows.Forms.MessageBox.Show("Minimized", "MinMax",
                        System.Windows.Forms.MessageBoxButtons.OK,
                        System.Windows.Forms.MessageBoxIcon.None,
                        System.Windows.Forms.MessageBoxDefaultButton.Button1,
                        System.Windows.Forms.MessageBoxOptions.ServiceNotification);

            // Maximize the Application window
            Application.MainWindow.WindowState = Window.State.Maximized;   //Error
            System.Windows.Forms.MessageBox.Show("Maximized", "MinMax");
          
        }
    }
}

0 Likes
Accepted solutions (1)
1,784 Views
8 Replies
Replies (8)
Message 2 of 9

Anonymous
Not applicable
Remove using System;
or
[CommandMethod("MinMaxApplicationWindow")]
        public static void MinMaxApplicationWindow()
        {
            // Minimize the Application window
            Application.MainWindow.WindowState = Autodesk.AutoCAD.Windows.Window.State.Minimized;  //Error
            System.Windows.Forms.MessageBox.Show("Minimized", "MinMax",
                        System.Windows.Forms.MessageBoxButtons.OK,
                        System.Windows.Forms.MessageBoxIcon.None,
                        System.Windows.Forms.MessageBoxDefaultButton.Button1,
                        System.Windows.Forms.MessageBoxOptions.ServiceNotification);

            // Maximize the Application window
            Application.MainWindow.WindowState = Autodesk.AutoCAD.Windows.Window.State.Maximized;   //Error
            System.Windows.Forms.MessageBox.Show("Maximized", "MinMax");

        }

 

0 Likes
Message 3 of 9

Anonymous
Not applicable

Although when you build it the compiler should figure out which Window namespace you are refering to. So try building it first.

 

 System.Windows.Window
Autodesk.AutoCAD.Windows.Window
0 Likes
Message 4 of 9

classof
Contributor
Contributor

Jeffrey_H

 

thank you..

 

I followed your answer. so I removed "using system".  but not solved.

 

"Autodesk.AutoCAD.Windows.Window.  has not "State".

 

Autodesk.AutoCAD.Windows.Window.(ReferenceEquals / GetDeviceIndependentScale / Equals / Create)

 

It has not "State". 

 

anyway thanks your reply. 

0 Likes
Message 5 of 9

Anonymous
Not applicable

Have you tried compiling it. Press F6 or use the toolbar.

0 Likes
Message 6 of 9

chiefbraincloud
Collaborator
Collaborator

That code worked fine pasted into my project.  What version of AutoCAD are you using?

Dave O.                                                                  Sig-Logos32.png
0 Likes
Message 7 of 9

classof
Contributor
Contributor

chiefbraincloud..

 

thaks your reply..

 

I have been using  AutoCad 2009 and "VS2008 express"

0 Likes
Message 8 of 9

chiefbraincloud
Collaborator
Collaborator
Accepted solution

That is the problem.  In 2010 AutoCAD the Object Browser shows this:

 

WindowState() As Autodesk.AutoCAD.Windows.Window.State

 

but in 2009, it expects a:

 

System.Windows.Forms.FormWindowState

 

So if you change your code to use the System Enum, it will work.  (I tested it in 2009)

Dave O.                                                                  Sig-Logos32.png
0 Likes
Message 9 of 9

classof
Contributor
Contributor

Wow~ thank you very much.. chiefbraincloud~

 

I did follow your reply. and then I solved my problem..

 

very thank youSmiley Happy

 

 

0 Likes