Author Topic: Expanded menu on AutoCAD status bar  (Read 4462 times)

0 Members and 1 Guest are viewing this topic.

Andrey Bushman

  • Swamp Rat
  • Posts: 864
Expanded menu on AutoCAD status bar
« on: October 17, 2012, 06:22:45 AM »
Hi all,

How can I create on AutoCAD status bar an expanded menu, with items, as at the screen (look attached file)? How can I add into it checked/unchecked item? How can I create a hierarchy of nested elements in it? How can I set icons for such elements? How can I set enable/disable status for such items?

I can do it through WPF, but how can I do it through .NET API?

« Last Edit: October 17, 2012, 06:26:57 AM by Andrey »

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Expanded menu on AutoCAD status bar
« Reply #1 on: October 17, 2012, 07:58:10 AM »
Have you looked at Pane Class?
and
Document.StatusBar.Panes.Add()----2012     Document.GetStatusBar().Panes.Add()----2013
Application.StatusBar.Panes.Add(); 
You can toogle PaneStyles.PopOut to make active and create a System.Windows.Forms.ContextMenu and pass it to Pane.DisplayContextMenu()
 
For Drawing status bar you might need
 
Code: [Select]

         [DllImport("accore.dll", EntryPoint = "?acedShowDrawingStatusBars@@YAHH@Z", CallingConvention = CallingConvention.StdCall)]
         public static extern bool ShowDrawingStatusBars(bool show);
« Last Edit: October 17, 2012, 08:01:22 AM by Jeff H »

Andrey Bushman

  • Swamp Rat
  • Posts: 864
Re: Expanded menu on AutoCAD status bar
« Reply #2 on: October 17, 2012, 08:08:48 AM »
Have you looked at Pane Class?
and
Document.StatusBar.Panes.Add()----2012     Document.GetStatusBar().Panes.Add()----2013
Application.StatusBar.Panes.Add(); 
You can toogle PaneStyles.PopOut to make active and create a System.Windows.Forms.ContextMenu and pass it to Pane.DisplayContextMenu()
 
For Drawing status bar you might need
 
Code: [Select]

         [DllImport("accore.dll", EntryPoint = "?acedShowDrawingStatusBars@@YAHH@Z", CallingConvention = CallingConvention.StdCall)]
         public static extern bool ShowDrawingStatusBars(bool show);
Thank you, but what about AutoCAD 2009?

kaefer

  • Guest
Re: Expanded menu on AutoCAD status bar
« Reply #3 on: October 17, 2012, 08:18:03 AM »
Thank you, but what about AutoCAD 2009?

This is a pane in the back... There's no ?acedShowDrawingStatusBars@@YAHH@Z in 2009's acad.exe?

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Expanded menu on AutoCAD status bar
« Reply #4 on: October 17, 2012, 08:26:30 AM »
Thank you, but what about AutoCAD 2009?

This is a pane in the back... There's no ?acedShowDrawingStatusBars@@YAHH@Z in 2009's acad.exe?

There was in ACAD.exe in 2008 !
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Andrey Bushman

  • Swamp Rat
  • Posts: 864
Re: Expanded menu on AutoCAD status bar
« Reply #5 on: October 17, 2012, 09:44:08 AM »
You can toogle PaneStyles.PopOut to make active and create a System.Windows.Forms.ContextMenu and pass it to Pane.DisplayContextMenu()
Thank you very much!
Code - C#: [Select]
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using WinForms = System.Windows.Forms;
  6. //Autodesk namespaces ***************
  7. using acad = Autodesk.AutoCAD.ApplicationServices.Application;
  8. using AcApp = Autodesk.AutoCAD.ApplicationServices;
  9. using AcDb = Autodesk.AutoCAD.DatabaseServices;
  10. using AcEd = Autodesk.AutoCAD.EditorInput;
  11. using AcRtm = Autodesk.AutoCAD.Runtime;
  12. using AcPub = Autodesk.AutoCAD.Publishing;
  13. using AcPlt = Autodesk.AutoCAD.PlottingServices;
  14. using AcGem = Autodesk.AutoCAD.Geometry;
  15. using AcCol = Autodesk.AutoCAD.Colors;
  16. using AcCMod = Autodesk.AutoCAD.ComponentModel;
  17. using AcGInt = Autodesk.AutoCAD.GraphicsInterface;
  18. using AcGSys = Autodesk.AutoCAD.GraphicsSystem;
  19. using AcLayMng = Autodesk.AutoCAD.LayerManager;
  20. using AcWin = Autodesk.AutoCAD.Windows;
  21. using AcICen = Autodesk.AutoCAD.AcInfoCenterConn;
  22. //************************************
  23. ...
  24. /// <summary>
  25. /// Create new Pane instance into AutoCAD statusbar.
  26. /// </summary>
  27. [AcRtm.CommandMethod("sbTest")]
  28. public void StatusBar() {
  29.         AcApp.Document doc = acad.DocumentManager.MdiActiveDocument;
  30.  
  31.         AcWin.TrayItem ti = new AcWin.TrayItem();
  32.         ti.ToolTipText = "My tray item tooltip";
  33.         ti.Icon = msnIcon;
  34.         acad.StatusBar.TrayItems.Add(ti);                      
  35.  
  36.         AcWin.Pane pane = new AcWin.Pane();
  37.         pane.Icon = iconIco;
  38.         pane.ToolTipText = "My Pane tooltip";
  39.         pane.Style = AcWin.PaneStyles.Normal;
  40.         pane.MouseDown += new AcWin.StatusBarMouseDownEventHandler(pane_MouseDown);
  41.         acad.StatusBar.Panes.Add(pane);
  42.        
  43.         AcWin.TrayItem ti2 = new AcWin.TrayItem();
  44.         ti2.ToolTipText = "My tray item tooltip";
  45.         ti2.Icon = setupIcon;
  46.         doc.StatusBar.TrayItems.Add(ti2);
  47. }
  48.  
  49. void pane_MouseDown(object sender, AcWin.StatusBarMouseDownEventArgs e) {
  50.         WinForms.ContextMenu contextMenu = new WinForms.ContextMenu();
  51.         contextMenu.Name = "my menu";
  52.         contextMenu.MenuItems.Add(new WinForms.MenuItem("item"));
  53.         contextMenu.MenuItems.Add(new WinForms.MenuItem("item2"));
  54.         WinForms.MenuItem item = new WinForms.MenuItem("item3");
  55.         WinForms.MenuItem subitem = new WinForms.MenuItem("subItem");
  56.         item.MenuItems.Add(subitem);
  57.         contextMenu.MenuItems.Add(item);
  58.         AcWin.Pane pane = (AcWin.Pane)sender;
  59.         pane.DisplayContextMenu(contextMenu, new System.Drawing.Point(e.X, e.Y));
  60. }
  61. ...
  62.