?
Solved

Open button with Recent List

Posted on 2003-03-22
2
Medium Priority
?
227 Views
Last Modified: 2010-04-04
I would like to create an open button that when executed opens the opendialog option (this is easy lol), and when I open more files an arrow appears (this button with an arrow is similar to the one to select a font/color on Word etc.) that lists recent files that was opened, and also on this menu that have the recent files a button to clean the recent files list

thanks for any help on this
0
Comment
Question by:paulo67
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
lmikle earned 360 total points
ID: 8185899
Use a TToolButton with tbsDropdown style.
Attach any popup menu to DropdownMenu property.
Also, add to this menu separator and 'Clear' menu item.

In following example popup menu has separator as 1st item and 'Clear' menu item as 2nd. Set Tag property on separator menu item to 1 (this will be used as stop flag).

Create procedure that will be called then recent menu item will be clicked:

procedure TForm1.RecentMIClick(Sender: TObject);
begin
  // Show file name that placed in item caption
  ShowMessage((Sender As TMenuItem).Caption);
end;



Then you open any file(s) add menu items in a head of this popup menu:

procedure TForm1.ToolButton1Click(Sender: TObject);
var
  I, J : Integer;
  MI : TMenuItem;
begin
  // OpenDialog1.Execute - call standard open handler

  // peocessing opened files
  For I := 0 To openDialog1.Files.Count-1 Do
    Begin
      // Check - does file already exists. If Yes - remove one
      For J := 0 To PopupMenu1.Items.Count-1 Do
        Begin
          If PopupMenu1.Items[J].Tag = 1 Then Break;
          If PopupMenu1.Items[J].Caption = OpenDialog1.Files[I] Then
            Begin
              Popupmenu1.Items.Delete(J);
              Break;
            End;
        End;

      // Add new menu item
      MI := TMenuItem.Create(Self);
      MI.Caption := OpenDialog1.Files[I];
      MI.OnClick := RecentMIClick;
      PopupMenu1.Items.Insert(0,MI);
    end;
end;

And at the finish create a clear handler - it will remove all items except separator and 'Clear' item. We use a separator Tag property as stop flag too:

procedure TForm1.Clear1Click(Sender: TObject);
begin
  While PopupMenu1.Items.Count > 0 Do
    Begin
      If PopupMenu1.Items[0].Tag = 1 Then Break;
      PopupMenu1.Items.Delete(0);
    End;
end;
0
 

Author Comment

by:paulo67
ID: 8271792
sorry i had some problems with my computer and couldn't login anymore
thanks for the help it works great
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month12 days, 14 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question