Print Page | Close Window

Finding a CommandBar by BarID (VB6)

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=2914
Printed Date: 17 June 2025 at 6:18pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Finding a CommandBar by BarID (VB6)
Posted By: Milkman
Subject: Finding a CommandBar by BarID (VB6)
Date 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





Replies:
Posted By: ylhyh
Date Posted: 05 December 2007 at 4:43am
thanks



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net