used autoCAD 2006 and Visual Studio Express 2008 C#:
using System;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using acadApp = Autodesk.AutoCAD.ApplicationServices.Application;
using Autodesk.AutoCAD.Windows;
using Autodesk.AutoCAD.EditorInput;
namespace buttons
{
public class PaneButtons
{
//test to see if button is loaded
static bool buttonLoaded = false;
[CommandMethod("BTEST")]
public static void PaneButton()
{
Pane appPaneButton = new Pane();
//Set the buttons properties
appPaneButton.Enabled = true;
appPaneButton.Visible = true;
appPaneButton.Style = PaneStyles.Normal;
appPaneButton.Text = "B-Test";
appPaneButton.ToolTipText = "This is a command prompt test.";
if (buttonLoaded == false)
{
//Hook into the MouseDown event to run code when the button is pressed.
appPaneButton.MouseDown += new StatusBarMouseDownEventHandler(OnAppMouseDown);
//Add the button to the applications status bar
//Items can also be added to the tray area
acadApp.StatusBar.Panes.Add(appPaneButton);
acadApp.StatusBar.Update();
buttonLoaded = true;
}
}
private static void OnAppMouseDown(object sender, StatusBarMouseDownEventArgs e)
{
//open editor
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
Pane paneButton = (Pane)sender;
if (paneButton.Style == PaneStyles.PopOut)
{
paneButton.Style = PaneStyles.Normal;
ed.WriteMessage("{0}<activated>", Environment.NewLine);
Autodesk.AutoCAD.Internal.Utils.PostCommandPrompt();
}
else
{
paneButton.Style = PaneStyles.PopOut;
ed.WriteMessage("{0}<de-activated>", Environment.NewLine);
Autodesk.AutoCAD.Internal.Utils.PostCommandPrompt();
}
acadApp.StatusBar.Update();
}
}
}
Updated your code and added a reference to 'acmgdinternal.dll'
Cheers,
Glenn.