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

Window.State is Error

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
classof
1376 Views, 8 Replies

Window.State is Error

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");
          
        }
    }
}

8 REPLIES 8
Message 2 of 9
Jeffrey_H
in reply to: classof

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");

        }

 

You can also find your answers @ TheSwamp
Message 3 of 9
Jeffrey_H
in reply to: Jeffrey_H

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
You can also find your answers @ TheSwamp
Message 4 of 9
classof
in reply to: Jeffrey_H

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. 

Message 5 of 9
Jeffrey_H
in reply to: classof

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

You can also find your answers @ TheSwamp
Message 6 of 9
chiefbraincloud
in reply to: classof

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

Dave O.                                                                  Sig-Logos32.png
Message 7 of 9
classof
in reply to: chiefbraincloud

chiefbraincloud..

 

thaks your reply..

 

I have been using  AutoCad 2009 and "VS2008 express"

Message 8 of 9
chiefbraincloud
in reply to: classof

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
Message 9 of 9
classof
in reply to: chiefbraincloud

Wow~ thank you very much.. chiefbraincloud~

 

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

 

very thank youSmiley Happy

 

 

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