Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Command Bars
  New Posts New Posts RSS Feed - Displaying PopUp menu from one commandbar
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Displaying PopUp menu from one commandbar

 Post Reply Post Reply
Author
Message
ianp View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 19 December 2003
Location: United Kingdom
Status: Offline
Points: 119
Post Options Post Options   Thanks (0) Thanks(0)   Quote ianp Quote  Post ReplyReply Direct Link To This Post Topic: Displaying PopUp menu from one commandbar
    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???

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 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
Back to Top
ianp View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 19 December 2003
Location: United Kingdom
Status: Offline
Points: 119
Post Options Post Options   Thanks (0) Thanks(0)   Quote ianp Quote  Post ReplyReply Direct Link To This Post 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)

 

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.156 seconds.