Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Command Bars
  New Posts New Posts RSS Feed - Launch a popup menu
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Launch a popup menu

 Post Reply Post Reply
Author
Message
amstel View Drop Down
Newbie
Newbie


Joined: 23 February 2004
Location: France
Status: Offline
Points: 18
Post Options Post Options   Thanks (0) Thanks(0)   Quote amstel Quote  Post ReplyReply Direct Link To This Post Topic: Launch a popup menu
    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

Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post Posted: 24 February 2004 at 12:13pm
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.  
Back to Top
amstel View Drop Down
Newbie
Newbie


Joined: 23 February 2004
Location: France
Status: Offline
Points: 18
Post Options Post Options   Thanks (0) Thanks(0)   Quote amstel Quote  Post ReplyReply Direct Link To This Post Posted: 24 February 2004 at 12:38pm

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.

Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post Posted: 24 February 2004 at 1:18pm
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.
Back to Top
amstel View Drop Down
Newbie
Newbie


Joined: 23 February 2004
Location: France
Status: Offline
Points: 18
Post Options Post Options   Thanks (0) Thanks(0)   Quote amstel Quote  Post ReplyReply Direct Link To This Post Posted: 24 February 2004 at 1:51pm
Ok thanks, but how to change icons ? Icons from this sample is not in a imagelist control ?
Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post Posted: 24 February 2004 at 2:00pm
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?
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.158 seconds.