Dynamically draws an add-in toolbar button.  
             
            
Visual Basic sample code showing how to dynamically draw a toolbar button
- Add the toolbar button command in the IEdmAddIn5::GetAddInInfo implementation:
poCmdMgr.AddCmd 1000, "First command", EdmMenu_HasToolbarButton Or EdmMenu_OwnerDrawToolbarButton, "This is the first command", "First command", -1, -1 
- At the top of your class implementation, add declarations of the Win32 GDI functions that you want to use (read more about this in the Visual Basic online help):
Private Declare Sub LineTo Lib "Gdi32" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long)
Private Declare Sub MoveToEx Lib "Gdi32" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long, ByVal OldPnt As Long)
Private Declare Sub Arc Lib "Gdi32" (ByVal hDC As Long, _
                                     ByVal x1 As Long, ByVal y1 As Long, _
                                     ByVal x2 As Long, ByVal y2 As Long, _
                                     ByVal xstart As Long, ByVal ystart As Long, _
                                     ByVal xend As Long, ByVal yend As Long) 
- Implement IEdmAddInDrawButton5::DrawToolbarButton (called by SOLIDWORKS PDM Professional):
Private Sub IEdmAddInDrawButton5_DrawToolbarButton(ByVal lCmdID As Long, ByVal hDC As Long, poDestRect As EdmLib.EdmRect, ByVal eState As EdmLib.EdmButtonState, plRetBackgroundColor As Long)
On Error GoTo ErrHand 
If eState = BState_Cold Then 
  'Draw a cross using the default pen 
  MoveToEx hDC, poDestRect.mlLeft, poDestRect.mlTop, 0 
  LineTo hDC, poDestRect.mlRight, poDestRect.mlBottom 
  MoveToEx hDC, poDestRect.mlLeft, poDestRect.mlBottom, 0 
  LineTo hDC, poDestRect.mlRight, poDestRect.mlTop 
Else 
  'Draw a circle using the default pen 
  Arc hDC, poDestRect.mlLeft, poDestRect.mlTop, poDestRect.mlRight, poDestRect.mlBottom, _ 
  poDestRect.mlLeft + (poDestRect.mlRight - poDestRect.mlLeft) / 2, poDestRect.mlTop, _ 
  poDestRect.mlLeft + (poDestRect.mlRight - poDestRect.mlLeft) / 2, poDestRect.mlTop 
End If 
Exit Sub 
ErrHand: 
Dim errnum As String 
errnum = Err.Number 
MsgBox "Error drawing toolbar button!" + vbLf + Err.Description + vbLf + errnum 
End Sub