Re: Delphi: Application Menu
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?
: What I would like a full form menu as an opening page and select the applications as needed. For example:
: If you selected Number 1 it would call up "traverseProject1.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.
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".
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:
[ DelphiLand: free Delphi source code, tips, tutorials ]