Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Command Bars
  New Posts New Posts RSS Feed - Recent documents
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Recent documents

 Post Reply Post Reply
Author
Message
JvdH View Drop Down
Groupie
Groupie


Joined: 09 May 2008
Status: Offline
Points: 50
Post Options Post Options   Thanks (0) Thanks(0)   Quote JvdH Quote  Post ReplyReply Direct Link To This Post Topic: Recent documents
    Posted: 12 January 2011 at 4:16pm
Is it possible to add an item to the recent documents list on runtime (after the Ribbonbar is created)?
Is it possible to open the systembutton control to execute the following:
Set control = frmMain.CommandBars.CreateCommandBarControl("CXTPRibbonControlSystemPopupBarListItem")
            control.Caption = "test"
            control.Id = 1004
            .AddControl control
 
Or am I thinking in a total wrong direction?
 
Thank you in advance :).
Product: Xtreme SuitePro (ActiveX) version 13.2.1
Platform: Windows 7 (64bit)
Language: Visual Basic 6.0 SP6
Back to Top
JvdH View Drop Down
Groupie
Groupie


Joined: 09 May 2008
Status: Offline
Points: 50
Post Options Post Options   Thanks (0) Thanks(0)   Quote JvdH Quote  Post ReplyReply Direct Link To This Post Posted: 18 January 2011 at 11:57am
So, nobody has a solution for this?
Product: Xtreme SuitePro (ActiveX) version 13.2.1
Platform: Windows 7 (64bit)
Language: Visual Basic 6.0 SP6
Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1354
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 18 January 2011 at 12:08pm
Something like this?


Option Explicit

Private mo_Rbn As RibbonBar
Private mo_SysBtn As XtremeCommandBars.CommandBarPopup

Private Sub Command1_Click()
   Dim lo_Control As CommandBarControl

   Set lo_Control = Me.CommandBars1.CreateCommandBarControl("CXTPRibbonControlSystemPopupBarListItem")
   With lo_Control
      .Caption = "test"
      .Id = 1004
   End With
  
   mo_SysBtn.CommandBar.Controls.AddControl lo_Control
End Sub

Private Sub Form_Load()
   With Me.CommandBars1
      .EnableOffice2007Frame True
     
      Set mo_Rbn = .AddRibbonBar("Main")
      With mo_Rbn
         Set mo_SysBtn = .AddSystemButton
         mo_SysBtn.Caption = "&File"
      End With
     
   End With
End Sub


or maybe more concise if you don't specifically need a CXTPRibbonControlSystemPopupBarListItem:


Option Explicit

Private mo_Rbn As RibbonBar
Private mo_SysBtn As XtremeCommandBars.CommandBarPopup

Private Sub Command1_Click()
   mo_SysBtn.CommandBar.Controls.Add xtpControlButton, 1004, "Test"
End Sub

Private Sub Form_Load()
   With Me.CommandBars1
      .EnableOffice2007Frame True
     
      Set mo_Rbn = .AddRibbonBar("Main")
      With mo_Rbn
         Set mo_SysBtn = .AddSystemButton
         mo_SysBtn.Caption = "&File"
      End With
     
   End With
End Sub

Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6

Back to Top
markmark View Drop Down
Senior Member
Senior Member


Joined: 30 November 2007
Status: Offline
Points: 142
Post Options Post Options   Thanks (0) Thanks(0)   Quote markmark Quote  Post ReplyReply Direct Link To This Post Posted: 18 January 2011 at 12:48pm
Hi
 
jpbro solution may be better, but I have just spent the last 1/2 hour trying to find a way for you, so I will post what I found.
 
Working from the codejock Ribbon Sample vbp,
I had to add an Id to the ControlFile
 
Set ControlFile = RibbonBar.AddSystemButton()
ControlFile.Id = 50
 
Then from a button just place on the form I run
Private Sub Command1_Click()
    Dim Control As CommandBarControl
    Dim ControlFile As CommandBarPopup
    Dim RibbonBar As RibbonBar
   
    Set RibbonBar = CommandBars.ActiveMenuBar
    Set ControlFile = RibbonBar.FindControl(, 50)
   
    With ControlFile.CommandBar.Controls
        Set Control = CommandBars.CreateCommandBarControl("CXTPRibbonControlSystemPopupBarListItem")
        Control.Caption = "frmMain3.frm"
        .AddControl Control
    End With
End Sub
 
Hope that makes sence, what took me awhile to find was the  CommandBars.ActiveMenuBar
which gives you the RibbonBar object

Mark

Product: Xtreme SuitePro (ActiveX) version 13.0.0
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0
Back to Top
JvdH View Drop Down
Groupie
Groupie


Joined: 09 May 2008
Status: Offline
Points: 50
Post Options Post Options   Thanks (0) Thanks(0)   Quote JvdH Quote  Post ReplyReply Direct Link To This Post Posted: 18 January 2011 at 2:22pm
Hey Mark and JPBro, thank you for your help. I'm really appreciating this!
 
Can't thank you guys enough :)
 
Is there another way to delete an item from the list?
Created this for now (reloading the whole menu):
Private Function Reload_SystemMenu()
    frmMain.ControlFile.CommandBar.Controls.DeleteAll
    Dim lo_Control As CommandBarControl
    With frmMain.ControlFile.CommandBar.Controls
        .Add xtpControlButton, ID_NEW, LANG_ID_NEW
        .Add xtpControlButton, ID_DELETE, LANG_ID_DELETE
    End With
    Set lo_Control = frmMain.CommandBars.CreateCommandBarControl("CXTPRibbonControlSystemPopupBarListCaption")
    With lo_Control
        lo_Control.Caption = "Filelist"
        lo_Control.BeginGroup = True
        lo_Control.Id = ID_FILELIST
    End With
    frmMain.ControlFile.CommandBar.Controls.AddControl lo_Control
    If tmpStrg <> "" Then
        FileName = Left$(tmpStrg, Len(tmpStrg) - 4)
        Set lo_Control = frmMain.CommandBars.CreateCommandBarControl("CXTPRibbonControlSystemPopupBarListItem")
        With lo_Control
            lo_Control.Caption = FileName
            lo_Control.Id = ID_FILENAME
        End With
        frmMain.ControlFile.CommandBar.Controls.AddControl lo_Control
        tmpStrg = Dir$
    End If
    Set lo_Control = frmMain.CommandBars.CreateCommandBarControl("CXTPRibbonControlSystemPopupBarButton")
    With lo_Control
        lo_Control.Caption = "Exit " & M_APP_NAME_LONG
        lo_Control.Id = ID_EXIT
    End With
    frmMain.ControlFile.CommandBar.Controls.AddControl lo_Control
End Function
Product: Xtreme SuitePro (ActiveX) version 13.2.1
Platform: Windows 7 (64bit)
Language: Visual Basic 6.0 SP6
Back to Top
markmark View Drop Down
Senior Member
Senior Member


Joined: 30 November 2007
Status: Offline
Points: 142
Post Options Post Options   Thanks (0) Thanks(0)   Quote markmark Quote  Post ReplyReply Direct Link To This Post Posted: 18 January 2011 at 5:43pm
Hi
Not to sure if I am helping here, but Command1_Click adds and Command2_Click deletes
all I had to add from my previous example was an  id =23, then find it and delete it.
 
Private Sub Command1_Click()
    Dim Control As CommandBarControl
    Dim ControlFile As CommandBarPopup
    Dim RibbonBar As RibbonBar
   
    Set RibbonBar = CommandBars.ActiveMenuBar
    Set ControlFile = RibbonBar.FindControl(, 50)
   
    With ControlFile.CommandBar.Controls
        Set Control = CommandBars.CreateCommandBarControl("CXTPRibbonControlSystemPopupBarListItem")
        Control.Caption = "frmMain3.frm"
        Control.Id = 23
        .AddControl Control
    End With
End Sub

Private Sub Command2_Click()
    Dim Control As CommandBarControl
    Dim ControlFile As CommandBarPopup
    Dim RibbonBar As RibbonBar
   
    Set RibbonBar = CommandBars.ActiveMenuBar
    Set ControlFile = RibbonBar.FindControl(, 50)
    With ControlFile.CommandBar.Controls
        Set Control = .Find(, 23)
        Control.Delete
    End With
   
End Sub
Product: Xtreme SuitePro (ActiveX) version 13.0.0
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0
Back to Top
JvdH View Drop Down
Groupie
Groupie


Joined: 09 May 2008
Status: Offline
Points: 50
Post Options Post Options   Thanks (0) Thanks(0)   Quote JvdH Quote  Post ReplyReply Direct Link To This Post Posted: 22 January 2011 at 4:32am
Hey Mark,
 
Thanks for your reply.
 
All the items have the same ID on my list. This would not work for deleting just record.
Product: Xtreme SuitePro (ActiveX) version 13.2.1
Platform: Windows 7 (64bit)
Language: Visual Basic 6.0 SP6
Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1354
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 22 January 2011 at 11:33am
You really should give all of your items a unique ID, as it does make things easier - but assuming that you are keeping track of the recent file names, you can remove them by Caption. Here's an example based on my previous example:


Option Explicit

Private mo_SysBtn As XtremeCommandBars.CommandBarPopup

Private Sub Command1_Click()
   Dim lo_Control As CommandBarControl

   Set lo_Control = Me.CommandBars1.CreateCommandBarControl("CXTPRibbonControlSystemPopupBarListItem")
   With lo_Control
      .Caption = "Not a Recent File"
      .Id = 1003
   End With
   mo_SysBtn.CommandBar.Controls.AddControl lo_Control


   Set lo_Control = Me.CommandBars1.CreateCommandBarControl("CXTPRibbonControlSystemPopupBarListItem")
   With lo_Control
      .Caption = "Test 1"
      .Id = 1004
   End With
   mo_SysBtn.CommandBar.Controls.AddControl lo_Control
  
   Set lo_Control = Me.CommandBars1.CreateCommandBarControl("CXTPRibbonControlSystemPopupBarListItem")
   With lo_Control
      .Caption = "Test 2"
      .Id = 1004
   End With
   mo_SysBtn.CommandBar.Controls.AddControl lo_Control
  
   Set lo_Control = Me.CommandBars1.CreateCommandBarControl("CXTPRibbonControlSystemPopupBarListItem")
   With lo_Control
      .Caption = "Test 3"
      .Id = 1004
   End With
   mo_SysBtn.CommandBar.Controls.AddControl lo_Control
  
   Set lo_Control = Me.CommandBars1.CreateCommandBarControl("CXTPRibbonControlSystemPopupBarListItem")
   With lo_Control
      .Caption = "Test 4"
      .Id = 1004
   End With
   mo_SysBtn.CommandBar.Controls.AddControl lo_Control
  
   Set lo_Control = Me.CommandBars1.CreateCommandBarControl("CXTPRibbonControlSystemPopupBarListItem")
   With lo_Control
      .Caption = "Not a Recent File"
      .Id = 1005
   End With
   mo_SysBtn.CommandBar.Controls.AddControl lo_Control
End Sub

Private Sub Command2_Click()
   Dim i As Long
  
   Dim lo_Ctrl As CommandBarControl
  
   For i = mo_SysBtn.CommandBar.Controls.Count To 1 Step -1
      Set lo_Ctrl = mo_SysBtn.CommandBar.Controls.Item(i)
      If lo_Ctrl.Id = 1004 Then
         If lo_Ctrl.Caption = "Test 3" Then
            lo_Ctrl.Delete
         End If
      End If
   Next i
End Sub

Private Sub Form_Load()
   With Me.CommandBars1
      .EnableOffice2007Frame True
     
      With .AddRibbonBar("Main")
         Set mo_SysBtn = .AddSystemButton
         mo_SysBtn.Caption = "&File"
      End With
     
   End With
End Sub

Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6

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