Microsoft KB Archive/215397

= BUG: Menu Cannot be Disabled By CommandBar Controls Collection =

Article ID: 215397

Article Last Modified on 8/19/2005

-

APPLIES TO


 * Microsoft Windows CE Toolkit for Visual Basic 6.0

-



This article was previously published under Q215397



SYMPTOMS
A Windows CE CommandBar menu is not disabled when accessing the object through the Controls collection of the CommandBar.



RESOLUTION
Enable and disable a CommandBar menu object by accessing the Enabled property of the CommandBarMenuBar object.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps by Step Example
 Start a new Windows CE H/PC Pro Project in Visual Basic. Form1 is created by default. Add a CommandBar control, a ListBox and two CommandButtons to Form1.  Paste the following code in to the form's code window: Option Explicit Dim cbrMnuBar As CommandBarMenuBar

Private Sub Form_Activate Set cbrMnuBar = CommandBar1.Controls.Add(cbrMenuBar) cbrMnuBar.Items.Add, , "MenuBug" cbrMnuBar.Items(1).SubItems.Add, , "SubMenuBug" cbrMnuBar.Items.Add, , "MenuFix" cbrMnuBar.Items(2).SubItems.Add, , "SubMenuFix" Command1.Caption = "Disable MenuBug" Command2.Caption = "Disable MenuFix" End Sub

Private Sub Command1_Click CommandBar1.Controls(1).Enabled = Not CommandBar1.Controls(1).Enabled List1.AddItem "MenuBug Enabled = " & CommandBar1.Controls(1).Enabled If CommandBar1.Controls(1).Enabled Then Command1.Caption = "Disable MenuBug" Else Command1.Caption = "Enable MenuBug" End If End Sub

Private Sub Command2_Click cbrMnuBar.Items(2).Enabled = Not cbrMnuBar.Items(2).Enabled List1.AddItem "MenuFix Enabled = " & cbrMnuBar.Items(2).Enabled If cbrMnuBar.Items(2).Enabled Then Command2.Caption = "Disable MenuFix" Else Command2.Caption = "Enable MenuFix" End If End Sub

Private Sub CommandBar1_MenuClick(ByVal Item As CommandbarLib.Item) MsgBox Item.Caption & " click fired" End Sub

 Click Command1 to disable the first menu and notice that clicking the menu still fires the MenuClick event and the menu still appears enabled. The menu has not been disabled. Click Command2 and notice that the second menu has been disabled and the MenuClick event does not fire.</ol>

Additional query words: vbce wce vbce6

Keywords: kbbug kbtoolkit kbpending KB215397

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.