Print Page | Close Window

Displaying PopUp menu from one commandbar

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=1697
Printed Date: 04 November 2024 at 4:57pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Displaying PopUp menu from one commandbar
Posted By: ianp
Subject: Displaying PopUp menu from one commandbar
Date Posted: 24 January 2005 at 9:23am

I have an SDI form which contains a commandbar control and a docking pane.

The docking pane loads a form which contains a second commandbar control.

Each commandbar control contains a control of type xtpControlPopup.

On the SDI form, the PopUp has several controls added to its commandbar.controls collection

On the DockingPane form, the PopUp has no controls added to its commandbar.controls collection. However, it needs to display the same controls as the SDI PopUp.

Is is possible to re-use the SDI PopUp on the Docking Pane? Or do I have to add the controls to both forms???




Replies:
Posted By: SuperMario
Date Posted: 24 January 2005 at 9:28am
I'm thinking you can use the Copy method to copy from one to another.  But I have not tried this myself, so I can't say for sure. 

I'm thinking something like this:

Private Sub rtfText_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
   
    If (Button = 2) Then
        If CommandBars.DesignerControls Is Nothing Then Exit Sub
       
        Dim Control As CommandBarControl, ContextControl As CommandBarControl
        Dim Popup As CommandBar
       
        Set Control = frmForm1.CommandBars.DesignerControls.Find(, ID_CONTEXT_MENU)
        If Control Is Nothing Then Exit Sub
         &nbs p;       
        Set Popup = frmForm2.CommandBars.Add("Popup", xtpBarPopup)
        For Each ContextControl In Control.CommandBar.Controls
         &nbs p;  ContextControl.Copy Popup
        Next
         &nbs p;     
        Popup.ShowPopup
    End If
End Sub


Posted By: ianp
Date Posted: 24 January 2005 at 4:26pm

Thanks SuperMario, that's exactly what I'm after...


Dim xcbSourcePop As CommandBarPopup, xcbNewPop As CommandBarPopup, xcbDestBar As CommandBar
' Assign variables
Set xcbSourcePop = Form1.CommandBars1.ActiveMenuBar.FindControl(xtpControlPopup , 12)
Set xcbDestBar = Me.CommandBars2.ActiveMenuBar
' Create New ControlPopup
Set xcbNewPop = Me.CommandBars2.ActiveMenuBar.Controls.Add(xtpControlPopup, Me.hWnd, "test " & Me.hWnd)
' Copy Controls from Source ControlPopup CommandBar
For Each xcbSourceCtrl In xcbSourcePop.CommandBar.Controls
    xcbSourceCtrl.Copy xcbNewPop.CommandBar
Next

Oddly, if you copy the controlpopup from form1, to form2, all the commandbar.controls are all disabled???


Dim xcbSourcePop As CommandBarPopup, xcbNewPop As CommandBarPopup, xcbDestBar As CommandBar
' Assign variables
Set xcbSourcePop = Form1.CommandBars1.ActiveMenuBar.FindControl(xtpControlPopup , ID_POP_TEST)
Set xcbDestBar = Form2.CommandBars2.ActiveMenuBar
' Copy ControlPopup
Set xcbNewPop = xcbSourcePop.Copy(xcbDestBar)

 




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