Print Page | Close Window

Launch a popup menu

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=472
Printed Date: 25 June 2024 at 2:57am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Launch a popup menu
Posted By: amstel
Subject: Launch a popup menu
Date 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




Replies:
Posted By: SuperMario
Date 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.  


Posted By: amstel
Date 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.



Posted By: SuperMario
Date 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.


Posted By: amstel
Date Posted: 24 February 2004 at 1:51pm
Ok thanks, but how to change icons ? Icons from this sample is not in a imagelist control ?


Posted By: SuperMario
Date 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?



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net