Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Command Bars
  New Posts New Posts RSS Feed - Creating a Popup Menu
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Creating a Popup Menu

 Post Reply Post Reply
Author
Message
Neil View Drop Down
Groupie
Groupie


Joined: 16 December 2007
Status: Offline
Points: 40
Post Options Post Options   Thanks (0) Thanks(0)   Quote Neil Quote  Post ReplyReply Direct Link To This Post Topic: Creating a Popup Menu
    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?
Back to Top
ijwelch View Drop Down
Senior Member
Senior Member


Joined: 20 June 2006
Status: Offline
Points: 262
Post Options Post Options   Thanks (0) Thanks(0)   Quote ijwelch Quote  Post ReplyReply Direct Link To This Post Posted: 17 December 2007 at 9:36pm
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).

Back to Top
Neil View Drop Down
Groupie
Groupie


Joined: 16 December 2007
Status: Offline
Points: 40
Post Options Post Options   Thanks (0) Thanks(0)   Quote Neil Quote  Post ReplyReply Direct Link To This Post Posted: 18 December 2007 at 5:46am
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
Back to Top
ijwelch View Drop Down
Senior Member
Senior Member


Joined: 20 June 2006
Status: Offline
Points: 262
Post Options Post Options   Thanks (0) Thanks(0)   Quote ijwelch Quote  Post ReplyReply Direct Link To This Post Posted: 18 December 2007 at 6:01am
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
Back to Top
Neil View Drop Down
Groupie
Groupie


Joined: 16 December 2007
Status: Offline
Points: 40
Post Options Post Options   Thanks (0) Thanks(0)   Quote Neil Quote  Post ReplyReply Direct Link To This Post Posted: 18 December 2007 at 8:11am
Once again, thanks very much for your help
Back to Top
Ayub View Drop Down
Newbie
Newbie


Joined: 08 January 2008
Location: India
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ayub Quote  Post ReplyReply Direct Link To This Post Posted: 09 January 2008 at 5:56am
Can we get C++ code for the same?
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.184 seconds.