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");
}
}
}
Solved! Go to Solution.
Solved by chiefbraincloud. Go to Solution.
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"); }
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
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.
That code worked fine pasted into my project. What version of AutoCAD are you using?
chiefbraincloud..
thaks your reply..
I have been using AutoCad 2009 and "VS2008 express"
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)
Wow~ thank you very much.. chiefbraincloud~
I did follow your reply. and then I solved my problem..
very thank you
Can't find what you're looking for? Ask the community or share your knowledge.