Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Command Bars
  New Posts New Posts RSS Feed - Finding a CommandBar by BarID (VB6)
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Finding a CommandBar by BarID (VB6)

 Post Reply Post Reply
Author
Message
Milkman View Drop Down
Newbie
Newbie


Joined: 16 September 2005
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote Milkman Quote  Post ReplyReply Direct Link To This Post Topic: Finding a CommandBar by BarID (VB6)
    Posted: 18 September 2005 at 1:29pm
The CommandBars control doesn't include a function that will find a Command Bar by BarID.  The sample programs use the Command Bar index value; however, that is a limited approach.  Use the piece of code below to create a CommandBar object from a BarID. 

Private Function FindCommandBar(ByVal cbBarID As Long) As CommandBar
'This function returns a command bar object whose BarID matches cbBarID
'Declare Temporary Variables
Dim Bar As CommandBar
'Search through command bars for controls matching the ID Value
For Each Bar In CommandBars
    If Bar.BarID = cbBarID Then
        'Match Found
        Set FindCommandBar = Bar
        Exit Function
    End If
Next
End Function


With this piece of code you can directly access CommandBar objects through a single line of code:

FindCommandBar(ID_STANDARD_BAR).Visible = True


Or perhaps in your toolbar menu commands:

Private Sub CommandBars_Execute(ByVal Control As XtremeCommandBars.ICommandBarControl)

Select Case Control.Id
    Case ID_VIEW_TOOLBAR_STANDARD:    FindCommandBar(ID_STANDARD_BAR).Visible = Not FindCommandBar(ID_STANDARD_BAR).Visible
End Select


If you plan on using it like this, make sure to put a line of code in the update procedure indicate the status of the toolbar in the dropdown menus.

Private Sub CommandBars_Update(ByVal Control As XtremeCommandBars.ICommandBarControl)

If Control Is Nothing Then Exit Sub
Select Case Control.Id
    Case ID_VIEW_TOOLBAR_STANDARD:    Control.Checked = FindCommandBar(ID_STANDARD_BAR).Visible
End Select
End Sub




Edited by Milkman
Back to Top
ylhyh View Drop Down
Newbie
Newbie


Joined: 24 October 2007
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote ylhyh Quote  Post ReplyReply Direct Link To This Post Posted: 05 December 2007 at 4:43am
thanks
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.047 seconds.