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

MRU list

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


Joined: 21 August 2008
Location: United States
Status: Offline
Points: 22
Post Options Post Options   Thanks (0) Thanks(0)   Quote MadRiver Quote  Post ReplyReply Direct Link To This Post Topic: MRU list
    Posted: 19 November 2008 at 4:42pm
Can someone point me towards some information about implementing a Most Recently Used file list? I found things like this in the samples:
Control = ControlFile.CommandBar.Controls.Add(XtremeCommandBars.XTPControlType.xtpControlButton, ID.ID_FILE_MRU_FILE1, "Recent File", false, false);
but as far as I could tell, those controls never get used.
Thanks for any pointers...
Xtreme CommandBars ActiveX v 12.1.0

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 20 November 2008 at 1:59am
Hello,
 its for MFC only. ActiveX users have to implement it manually :(
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Albert1 View Drop Down
Groupie
Groupie
Avatar

Joined: 01 February 2007
Location: Italy
Status: Offline
Points: 66
Post Options Post Options   Thanks (0) Thanks(0)   Quote Albert1 Quote  Post ReplyReply Direct Link To This Post Posted: 20 November 2008 at 12:20pm
Hello,

I suggest to do this way:

Download the class cMRUFileList and include it in the Project:

http://www.vbaccelerator.com/codelib/filemru/filemru.htm

and adapt this code to your need (you can try it in a simple Form1 with a CommandBar and a Button):




Option Explicit

Const ID_FILE_EXIT = 1051

Const ID_FILE_MRU_1 = 40001
Const ID_FILE_MRU_2 = 40002
Const ID_FILE_MRU_3 = 40003
Const ID_FILE_MRU_4 = 40004

Public m_cMRU As New cMRUFileList

Private Sub Form_Load()
Dim Item As CommandBarAction
   
    CommandBars1.EnableActions
   
    With CommandBars1.Actions
        ' MRU
        Set Item = .Add(ID_FILE_MRU_1, "&1)", "1)", "", "File")
        Set Item = .Add(ID_FILE_MRU_2, "&2)", "2)", "", "File")
        Set Item = .Add(ID_FILE_MRU_3, "&3)", "3)", "", "File")
        Set Item = .Add(ID_FILE_MRU_4, "&4)", "4)", "", "File")
        ' EXIT
        .Add ID_FILE_EXIT, "Exit", "", "", "File"
    End With

    Dim ControlFile As CommandBarPopup
   
    Set ControlFile = CommandBars1.ActiveMenuBar.Controls.Add(xtpControlPopup, 0, "&File", -1, False)
    With ControlFile.CommandBar
        ' MRU Group
        .Controls.Add xtpControlButton, ID_FILE_MRU_1, ""
        .Controls(.Controls.Count).BeginGroup = True
        .Controls.Add xtpControlButton, ID_FILE_MRU_2, ""
        .Controls.Add xtpControlButton, ID_FILE_MRU_3, ""
        .Controls.Add xtpControlButton, ID_FILE_MRU_4, ""
        '
        .Controls.Add xtpControlButton, ID_FILE_EXIT, ""
        .Controls(.Controls.Count).BeginGroup = True
    End With

    ' Most Recently Used
    m_cMRU.MaxFileCount = 4
    m_cMRU.Load "MyApp", "MySection"
    Call pDisplayMRU


End Sub

Private Sub CommandBars1_Execute(ByVal Control As XtremeCommandBars.ICommandBarControl)
Dim i As Integer
Dim strS As String
   
    Select Case Control.Id
        ' ...
        Case ID_FILE_MRU_1 To ID_FILE_MRU_4
            Call LoadDocument(m_cMRU.file(CLng(Control.Id - ID_FILE_MRU_1 + 1)))
       
        Case ID_FILE_EXIT:
            Unload Me
        ' ...
    End Select

End Sub

Private Sub Command1_Click()
    LoadDocument ("File1")
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
       
    m_cMRU.Save "MyApp", "MySection"

End Sub

Public Sub pDisplayMRU()
Dim iFile As Integer
Dim Item As CommandBarControl
   
    For iFile = 1 To m_cMRU.MaxFileCount
        Set Item = CommandBars1.FindControl(, ID_FILE_MRU_1 + (iFile - 1), , True)
        If Not (Item Is Nothing) Then
            If (iFile <= m_cMRU.FileCount) And (m_cMRU.FileExists(iFile)) Then
                Item.Visible = True
                Item.Caption = m_cMRU.MenuCaption(iFile)
                Item.DescriptionText = m_cMRU.file(iFile)
                If iFile = 1 Then
                    Item.Checked = True
                End If
            Else
                Item.Visible = False
            End If
        End If
    Next iFile
   
End Sub


Private Sub LoadDocument(fname As String)

    m_cMRU.AddFile fname
   
'    If FileExists Then
'        m_cMRU.AddFile fname
'    Else
'        m_cMRU.RemoveFile fname
'    End If
   
    pDisplayMRU
   
End Sub

Private Sub SaveDocument(fname As String)
   
    m_cMRU.AddFile fname
    pDisplayMRU

End Sub





Back to Top
MadRiver View Drop Down
Groupie
Groupie


Joined: 21 August 2008
Location: United States
Status: Offline
Points: 22
Post Options Post Options   Thanks (0) Thanks(0)   Quote MadRiver Quote  Post ReplyReply Direct Link To This Post Posted: 21 November 2008 at 12:28pm
Thanks for the reply.
Now I just have to translate it to C++....
Xtreme CommandBars ActiveX v 12.1.0

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.