BUG: Menu Cannot be Disabled By CommandBar Controls Collection
ID: Q215397
|
The information in this article applies to:
-
Microsoft Windows CE Toolkit for Visual Basic 6.0, version 1.0
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 this to be a bug in the Microsoft products listed
at the beginning of this article.
MORE INFORMATION
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.
Additional query words:
vbce wce vbce6
Keywords : kbToolkit kbVBp600bug kbWinCE kbGrpVB
Version : WINDOWS:1.0
Platform : WINDOWS
Issue type : kbbug