Re: Delphi: Application Menu


[ Delphi Forum -- by DelphiLand ]

Posted by webmaster Guido on December 19, 2003

In Reply to: Re: Application Menu posted by Lionel on December 17, 2003:

: : : I have several applications that I have created using Delphi 7 and would like to create a Menu to call up each compiled application as needed. I have tried using the Delphi Menu Component but it is not what I am looking for. I am looking for a way to create a menu that will call up a set of compiled Delphi applications as needed. I have tried multiple forms and the Delphi Menu Component to call them up but this gets a little messy. Any suggestions?
: As to the Delphi menu component: I tried it and did not like it located at the top of my form. My first form had nothing on it but a menu at the top of the form and I would then go to other forms to run my applications.

: What I would like a full form menu as an opening page and select the applications as needed. For example:
: *******
: MENU
: *******
: (1) Compute Traverse
: (2) Compute Curve Data
: (3) Triangle Solutions
: (4) Compute Coordinates
: (5) Exit

: If you selected Number 1 it would call up "traverseProject1.exe"
: If you selected Number 2 it would call "curve2Project2.exe

: This is only two applications of six but I think you can see what I would like to do. Also, there may be another component that would allow this format but I am not aware of one so any suggestions will be appreciated.
:
: PS: I use a menu "case routine" in Turbo Pascal back in the old days and that worked ok but those days are gone. ( - ;
------------------

If you think of it, a menu is a lot like a listbox. So let's simulate it with a listbox component: fill the listbox with the titles of your programs. You can fill it in the Object Inspector, but it's easier to maintain the code if you do this under program control, for example at program startup.

Next, create an event handler for the OnClick event of the listbox (or the OnDblClick event, if you prefer a double click). In that procedure, find out which item is selected, and launch the corresponding program. For example, using a "case" construction:

case Listbox1.ItemIndex of
  0: launch_program_1;
  1: launch_program_2;
  2: launch_program_3;
  ...
end;

You could also let the user select a program, followed with a click on a button "Run".
Or, to add a nice effect, run the selected program when the user selects it and presses the ENTER key on the keyboard.

It's a bit too long to go over all the code here. I made a demo project with some extra's and zipped it into LAUNCHER.ZIP. You can download it from this password protected page:

http://www.festra.com/dclub
User name: dclub
Password: your membership access password

Also other DelphiLand Club members are invited to download this project :)


[ Delphi Forum ]
[ DelphiLand: free Delphi source code, tips, tutorials ]