x
This website is using cookies. We use cookies to ensure that we give you the best experience on our website. More info. That's Fine
HPC:Factor Logo 
 
Latest Forum Activity

How do I make my command bar work? (eVB)

I dunk for bananas Page Icon Posted 2024-01-07 8:16 PM
#
Avatar image of I dunk for bananas
H/PC Elite

Posts:
667
Location:
Europe
Status:
Hi all! For some reason I cannot figure our why my CommandBar buttons aren't working. I'm pretty certain that it has something to do with the Item.Key part, but I just cannot figure out what to put in place of that bit. Any ideas?

Sub InitCommandBar() 
  Dim mnuMain As CommandbarLib.CommandBarMenuBar 
Dim mnuFile As CommandbarLib.Item
Dim mnuEdit As CommandbarLib.Item

Set mnuMain = CommandBar1.Controls.Add(cbrMenuBar, "MainMenu")
'add File menu items
Set mnuFile = mnuMain.Items.Add(1, "mnuFile", "File")
mnuFile.SubItems.Add , "mnuBackup", "Backup DB"
mnuFile.SubItems.Add , "mnuExit", "Exit"

'add Help menu items
Set mnuEdit = mnuMain.Items.Add(2, "mnuHelp", "Help")
mnuEdit.SubItems.Add , "mnuAbout", "About"

End Sub

Private Sub CommandBar1_ButtonClick(ByVal Button As CommandbarLib.CommandBarButton)

Select Case Item.Key
Case "mnuBackup"
'Add mnuBackup procedure code here.

Case "mnuExit"
App.End

Case "mnuAbout"
'Add mnuAbout procedure code here.

End Select

End Sub
 Top of the page
C:Amie Page Icon Posted 2024-01-07 8:52 PM
#
Avatar image of C:Amie
Administrator
H/PC Oracle

Posts:
17,925
Location:
United Kingdom
Status:
After a quick glance, assuming CommandBar1 is defined in the UI code, you have not got a valid stack scope reference for what "Item" is. I am assuming your intention is to look at the Id reference of the button? In which case

Select Case Item.Key
Needs to be
Select Case Button.ID
It is likely that you are using the wrong event though and mixing code samples. I'd guess that it is not CommandBar1_ButtonClick you want but:

Private Sub CommandBar1_MenuClick(ByVal Item As CommandbarLib.Item) 
Select Case Item.Key
Case "mnuBackup"
'Add mnuBackup procedure code here.
Case "mnuExit"
App.End
Case "mnuAbout"
'Add mnuAbout procedure code here.
End Select
End Sub
Which will put Item into scope.

Making something interesting?
 Top of the page
WinCEDev Page Icon Posted 2024-01-08 9:11 AM
#
Avatar image of WinCEDev
Factor Fanatic

Posts:
62
Location:
Europe
Status:
The CommandBar control is very confusing (and buggy ).
@C:Amie is right, you need the MenuClick event here instead of the ButtonClick event, that one is used for toolbar buttons.

Everything else is looking good!

Edited by WinCEDev 2024-01-08 9:12 AM
 Top of the page
I dunk for bananas Page Icon Posted 2024-01-08 9:13 AM
#
Avatar image of I dunk for bananas
H/PC Elite

Posts:
667
Location:
Europe
Status:
Thank you C:Amie, that works flawlessly!
I'm making a little project management software for myself (just a database and forms and checklists), though it's pretty janky
 Top of the page
C:Amie Page Icon Posted 2024-01-08 12:12 PM
#
Avatar image of C:Amie
Administrator
H/PC Oracle

Posts:
17,925
Location:
United Kingdom
Status:
Sounds good
I hope when the time comes you'll share some screenshots - and perhaps share it with the community one day .
 Top of the page
I dunk for bananas Page Icon Posted 2024-01-08 12:17 PM
#
Avatar image of I dunk for bananas
H/PC Elite

Posts:
667
Location:
Europe
Status:
C:Amie - 2024-01-08 12:12 PM


Sounds good
I hope when the time comes you'll share some screenshots - and perhaps share it with the community one day .


Sure, would you be interested? I was already thinking it'd be a good to share the project with the community since I'm not the most well-versed with development Especially the way I'm doing the database is pretty janky
 Top of the page
C:Amie Page Icon Posted 2024-01-08 1:12 PM
#
Avatar image of C:Amie
Administrator
H/PC Oracle

Posts:
17,925
Location:
United Kingdom
Status:
I'm sure that I and the community can help you with any problems you might be having, and offer a few tips if any are needed. It sounds as though you are getting pretty adapt though, if you are playing with ADO and the system database drivers

I would certainly love to see some screenshots of what you've come up with so far!
 Top of the page
Jump to forum:
Seconds to generate: 0.171 - Cached queries : 45 - Executed queries : 29