![]() |
Launch a popup menu |
Post Reply ![]() |
Author | |
amstel ![]() Newbie ![]() Joined: 23 February 2004 Location: France Status: Offline Points: 18 |
![]() ![]() ![]() ![]() ![]() Posted: 24 February 2004 at 11:55am |
How to launch at runtime a popupmenu ? The menu is created with Command Bar Designer. Thanks for your help J-Marc From Paris, France |
|
![]() |
|
SuperMario ![]() Admin Group ![]() ![]() Joined: 14 February 2004 Status: Offline Points: 18057 |
![]() ![]() ![]() ![]() ![]() |
Could you be more specific? Is your command bar
xtpBarPopup? I wasn't aware that you could create a popup menu in
the designer. When should the popupmenu be displayed? When
the user righ-clicks the document? I can show you how to add a
popup menu via code when the user right clicks the document.
|
|
![]() |
|
amstel ![]() Newbie ![]() Joined: 23 February 2004 Location: France Status: Offline Points: 18 |
![]() ![]() ![]() ![]() ![]() |
I create a menu in designer (xtpControlPopup) I want display this menu at runtime in a popupmenu when the user right-clic on a label text. |
|
![]() |
|
SuperMario ![]() Admin Group ![]() ![]() Joined: 14 February 2004 Status: Offline Points: 18057 |
![]() ![]() ![]() ![]() ![]() |
OK, xtpControlPopup is a button control, not a command bar. To
have a popup command bar it must be type xtpBarPopup. You can not
create a popup command bar in the designer, it must be done via
code. I will assume you have a SDI application with a rich
textbox control called rtfText. To create and add a popup menu to
your code add the following code to the rtf_MouseUp event procedure.
Private Sub rtfText_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single) If (Button = 2) Then Set Popup = CommandBars.Add("Popup", xtpBarPopup) With Popup.Controls &nbs p; .Add xtpControlButton, ID_FILE_NEW, "&New", -1, False &nbs p; .Add xtpControlButton, ID_FILE_OPEN, "&Open", -1, False &nbs p; .Add xtpControlButton, ID_FILE_SAVE, "&Save", -1, False &nbs p; Set Control = .Add(xtpControlButton, ID_FILE_PRINT, "&Print", -1, False) &nbs p; Control.BeginGroup = True &nbs p; Set Control = .Add(xtpControlButton, ID_EDIT_CUT, "Cu&t", -1, False) &nbs p; Control.BeginGroup = True &nbs p; .Add xtpControlButton, ID_EDIT_COPY, "&Copy", -1, False &nbs p; .Add xtpControlButton, ID_EDIT_PASTE, "&Paste", -1, False End With Popup.ShowPopup End If This is illustrated in the SDI and MDI command Bars examples. ![]() |
|
![]() |
|
amstel ![]() Newbie ![]() Joined: 23 February 2004 Location: France Status: Offline Points: 18 |
![]() ![]() ![]() ![]() ![]() |
Ok thanks, but how to change icons ? Icons from this sample is not in a imagelist control ?
|
|
![]() |
|
SuperMario ![]() Admin Group ![]() ![]() Joined: 14 February 2004 Status: Offline Points: 18057 |
![]() ![]() ![]() ![]() ![]() |
You do not need an imagelist control. All of the popup menu
controls should have a corresponding control somwhere in the toolbar or
menubar. So all of the icons will already be added in the
designer. Just make sure that you assign the same ID to the popup
controls as you did to the controls in the menu and toolbar. This
will make them have the same Icon and perform the same actions.
Did this help? ![]() |
|
![]() |
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 |