Author Topic: AutoCAD status bar  (Read 3239 times)

0 Members and 1 Guest are viewing this topic.

Andrey Bushman

  • Swamp Rat
  • Posts: 864
AutoCAD status bar
« on: October 15, 2012, 04:21:04 AM »
I have wrote such simple code:
Code - C#: [Select]
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. //Autodesk namespaces ***************
  6. using acad = Autodesk.AutoCAD.ApplicationServices.Application;
  7. using AcApp = Autodesk.AutoCAD.ApplicationServices;
  8. using AcDb = Autodesk.AutoCAD.DatabaseServices;
  9. using AcEd = Autodesk.AutoCAD.EditorInput;
  10. using AcRtm = Autodesk.AutoCAD.Runtime;
  11. using AcPub = Autodesk.AutoCAD.Publishing;
  12. using AcPlt = Autodesk.AutoCAD.PlottingServices;
  13. using AcGem = Autodesk.AutoCAD.Geometry;
  14. using AcCol = Autodesk.AutoCAD.Colors;
  15. using AcCMod = Autodesk.AutoCAD.ComponentModel;
  16. using AcGInt = Autodesk.AutoCAD.GraphicsInterface;
  17. using AcGSys = Autodesk.AutoCAD.GraphicsSystem;
  18. using AcLayMng = Autodesk.AutoCAD.LayerManager;
  19. using AcWin = Autodesk.AutoCAD.Windows;
  20. using AcICen = Autodesk.AutoCAD.AcInfoCenterConn;
  21. //************************************
  22.  
  23. ...
  24.  
  25. [AcRtm.CommandMethod("sbTest")]
  26. public void StatusBar() {
  27.         AcApp.Document doc = acad.DocumentManager.MdiActiveDocument;
  28.         AcWin.TrayItem ti = new AcWin.TrayItem();
  29.         ti.ToolTipText = "My tray item tooltip";
  30.         ti.Icon = new System.Drawing.Icon(@"C:\Program Files\Microsoft Office\OFFICE11\MSN.ICO");
  31.         acad.StatusBar.TrayItems.Add(ti);
  32. }
  33.  
But I receive the strange behavior (look GIF screen). Why it happens?

Cathy

  • Guest
Re: AutoCAD status bar
« Reply #1 on: October 16, 2012, 02:40:34 PM »
What are your TRAYSETTINGS?

Andrey Bushman

  • Swamp Rat
  • Posts: 864
Re: AutoCAD status bar
« Reply #2 on: October 16, 2012, 02:44:57 PM »
What are your TRAYSETTINGS?
Why it for you?
« Last Edit: October 16, 2012, 02:50:12 PM by Andrey »

Chumplybum

  • Newt
  • Posts: 97
Re: AutoCAD status bar
« Reply #3 on: October 16, 2012, 08:36:12 PM »
Hi Andrey, I remember having this problem a long time ago... from memory the solution I used was to move the 'TrayItem' into a property instead of having it in the commandmethod:

Code: [Select]
    Private m_TrayItem As AAW.TrayItem = Nothing
    ''' <summary>
    '''
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public ReadOnly Property TrayItem() As AAW.TrayItem
        Get
            If Me.m_TrayItem Is Nothing Then
                Me.m_TrayItem = New Autodesk.AutoCAD.Windows.TrayItem
                Me.m_TrayItem.Icon = My.Resources.AutoPurge
                Me.m_TrayItem.ToolTipText = AUTO_PURGE_TOOLTIP
                Me.m_TrayItem.Visible = True

                AddHandler m_TrayItem.MouseDown, AddressOf callback_MouseDown
            End If
            Return Me.m_TrayItem
        End Get
    End Property


this code is untested, but should work:
Code: [Select]
<commandmethod("test")> _
public sub testtrayitem ()


        applicationservices.application.StatusBar.TrayItems.Add(Me.TrayItem)
        applicationservices.application.UpdateScreen()

end sub


this may also solve the issue (see bottom of page for solution):
http://forums.autodesk.com/t5/NET/TrayItem-Icon-disappears/td-p/2386483

Andrey Bushman

  • Swamp Rat
  • Posts: 864
Re: AutoCAD status bar
« Reply #4 on: October 17, 2012, 06:12:47 AM »
2 Chumplybum

I try it:
Quote
When the icon is defined as static global variable then the icon does not disappear.
It is simple solution, and it works for me.

Thank you!