Print Page | Close Window

MRU list

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=12729
Printed Date: 18 June 2025 at 4:06am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: MRU list
Posted By: MadRiver
Subject: MRU list
Date 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




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


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







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




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