![]() |
Creating a Popup Menu |
Post Reply ![]() |
Author | |
Neil ![]() Groupie ![]() Joined: 16 December 2007 Status: Offline Points: 40 |
![]() ![]() ![]() ![]() ![]() Posted: 17 December 2007 at 7:59pm |
I want to create a popup menu (through code - NOT the designer), and (if possible) to be able to add KeyBindings (i.e. hot keys) to the pop up menus.
1). I can see a PopupControl in the documentation, but I cannot locate it in the object hierarchy - also, the VB6 object browser cannot locate it (search for PopupControl fails to find it) - so it is not clear how to create/use this control 2). I am aware (after searching this forum's archives), that there is a VB6 sample that apparently shows how to do the above - (atleast - how to show popups). However, I have not been able to find an example that shows popup creation in code (i.e. without the help of teh designer). Anyone knows how to do this? |
|
![]() |
|
ijwelch ![]() Senior Member ![]() Joined: 20 June 2006 Status: Offline Points: 262 |
![]() ![]() ![]() ![]() ![]() |
Here's a basic popup menu:
Dim oBar As XtremeCommandBars.CommandBar Dim oControl As XtremeCommandBars.CommandBarControl Dim oPopup As XtremeCommandBars.CommandBarPopup Set oBar = CommandBars1.Add("Popup Toolbar Name", xtpBarPopup) With oBar.Controls 'standard items .Add xtpControlButton, ID_ITEM1, "Item1" .Add xtpControlButton, ID_ITEM2, "Item2" .Add(xtpControlButton, ID_ITEM3, "Item3").BeginGroup = True 'checkbox Set oControl = .Add(xtpControlCheckBox, ID_ITEM4, "Checkbox") oControl.Checked = True oControl.BeginGroup = True 'sub-menu Set oPopup = .Add(xtpControlPopup, ID_ITEM5, "Sub Menu") With oPopup.CommandBar.Controls .Add xtpControlButton, ID_SUBITEM1, "SubItem1" .Add xtpControlButton, ID_SUBITEM2, "SubItem2" End With End With 'show it oBar.ShowPopup Keybindings are included in the VB RibbonSample (in Form_Load event). |
|
![]() |
|
Neil ![]() Groupie ![]() Joined: 16 December 2007 Status: Offline Points: 40 |
![]() ![]() ![]() ![]() ![]() |
Fantastic!. This is EXACTLY what I needed. BTW, I do not have the RibbonSample. Could you please include a few lines of code that show how to use keybindings (hotkeys) with PopupMenu?
MTIA |
|
![]() |
|
ijwelch ![]() Senior Member ![]() Joined: 20 June 2006 Status: Offline Points: 262 |
![]() ![]() ![]() ![]() ![]() |
Yep,
These lines add the keybindings: CommandBars.KeyBindings.Add FCONTROL, Asc("N"), ID_FILE_NEW CommandBars.KeyBindings.Add FCONTROL, Asc("O"), ID_FILE_OPEN CommandBars.KeyBindings.Add FCONTROL, Asc("S"), ID_FILE_SAVE CommandBars.KeyBindings.Add FCONTROL, Asc("X"), ID_EDIT_CUT CommandBars.KeyBindings.Add FCONTROL, Asc("C"), ID_EDIT_COPY CommandBars.KeyBindings.Add FCONTROL, Asc("V"), ID_EDIT_PASTE And these constants define the values for special keys: Public Const FSHIFT = 4 Public Const FCONTROL = 8 Public Const FALT = 16 Public Const VK_BACK = &H8 Public Const VK_TAB = &H9 Public Const VK_ESCAPE = &H1B Public Const VK_SPACE = &H20 Public Const VK_PRIOR = &H21 Public Const VK_NEXT = &H22 Public Const VK_END = &H23 Public Const VK_HOME = &H24 Public Const VK_LEFT = &H25 Public Const VK_UP = &H26 Public Const VK_RIGHT = &H27 Public Const VK_DOWN = &H28 Public Const VK_INSERT = &H2D Public Const VK_DELETE = &H2E Public Const VK_MULTIPLY = &H6A Public Const VK_ADD = &H6B Public Const VK_SEPARATOR = &H6C Public Const VK_SUBTRACT = &H6D Public Const VK_DECIMAL = &H6E Public Const VK_DIVIDE = &H6F Public Const VK_F1 = &H70 Public Const VK_F2 = &H71 Public Const VK_F3 = &H72 Public Const VK_F4 = &H73 Public Const VK_F5 = &H74 Public Const VK_F6 = &H75 Public Const VK_F7 = &H76 Public Const VK_F8 = &H77 Public Const VK_F9 = &H78 Public Const VK_F10 = &H79 Public Const VK_F11 = &H7A Public Const VK_F12 = &H7B |
|
![]() |
|
Neil ![]() Groupie ![]() Joined: 16 December 2007 Status: Offline Points: 40 |
![]() ![]() ![]() ![]() ![]() |
Once again, thanks very much for your help
|
|
![]() |
|
Ayub ![]() Newbie ![]() Joined: 08 January 2008 Location: India Status: Offline Points: 6 |
![]() ![]() ![]() ![]() ![]() |
Can we get C++ code for the same?
|
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |