Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

creating AND using cmdButtons at runtime 1

Status
Not open for further replies.

markSaunders

Programmer
Jun 23, 2000
196
GB
i have an app that allows the use of shortcut buttons as defined by the user.

i need the system to read (from an ini) file the existing shortcut.Buttons along with the relative command line. i then need to allow the user to add a button - i can then store the command line to be run with that particular button in the same ini file.

how, though, do i get the button from the file and ensure that the correct command line is executed when the button is selected (i cant get my head around the button 'existing' with a name etc.)

cheers for any assistance that may be offered.
mark

Mark Saunders
 
The best way to do it would be to store the required settings in the file so that you can parse each one individually.
If you have a control array on the form for command buttons then you can add a new command button to that control array and then set the properties from the file.
To enable seperate commands to be executed jsut bring the code if you have to/need to into an array and access them using a SELECT CASE statement in the event procedure. The easiest way to do this would be to associate the index in the control array with the index in the array of commands.

James :) James Culshaw
jculshaw@active-data-solutions.co.uk
 
so do you suggest, say, a file formated such as

[tt][cmdShortcut]
|0 'index reference
|frm001 'form to be run when button selected

|1 '|(pipe) used to identify for parsing
|frm002

|2
|frmPrefs [/tt]...

how would the vb app store and call the form name relative to the button?

[tt]btnClicked = cmdShortcut(Index)

Select Case btnClicked
Case Is = 0
frm_How_Am_I_Identified?.Show
[/tt]...

cheers for your help I-)
m

Mark Saunders
 
the forms are created already and the idea is to offer the user a quicker method (quicker than using the standard menu) of loading up each form (in the MDI environment) for use. i could decide that forms 1, 55 and 131 are the most important and so should have a shortcut to them, but if the user thinks forms 1, 71 and 92 are the most important they need to tell the system they're the buttons they want to see.

the proposition is to allow the user to type in the option (this would be the [tt]form.caption[/tt] and match up with the [tt]form.name[/tt])they wish to associate with the 'newly created' button 1.2.3 or 4 etc. that is then placed on the screen (in a predefined 'shortcut button holding' area)
Mark Saunders
:)
 
A rahter painfull way would be to use a select case that contains all the captions or IDs in it and then store this name value in the array to use in the SELECt which then has the Form.Open command associated with it.
I know that this isn't elegant and probably is not quite what you where after but it works.

James :) James Culshaw
jculshaw@active-data-solutions.co.uk
 
the main problerm with this solution would probably maintainability.

what if a [tt]form.name[/tt] (or [tt].caption[/tt]) is changed or a new form is added - then the select case could have to be amended to include/amend this [tt]form.name[/tt] (or [tt].caption[/tt])on each client.

ideally i need a function or class that would accept the, say, [tt]comShortcut(iNumber).Caption[/tt] (either through the [tt]_Click[/tt] event or even text typed in via an input box) then take this text and use it as described above for a

Code:
'confirm form exists and is not open
'convert comShortcut(iNumber).Caption to string? sFormNameSelected
 Load sFormNameSelected
 sFormNameSelected.Show

cheers anyone for anyHelp! Mark Saunders :)
 
mark,

Since this is VB, I assume that your users do not (often) have new forms to select. If this is true, you could just list the forms (Name; Caption; Id; Selected) in a table.

Give the user access to the table, with the capability to modify the [Selected].

For each item selected, you could then add a cmd button, set it's caption (to the Form Caption?) and set it's index to the Id field value.

The click event of the cmd button should probably just pass the index to a common routine which uses the same table to show the selected form.



MichaelRed
mred@duvallgroup.com
There is never time to do it right but there is always time to do it over
 
my problem here is that the package is an erp solution and there are a vast number of forms available to many of the users. the main form would therefore have literally hundreds of forms available - i suppose, to concurr with your point, each user would still only have a core of forms they use so (aside from having to write the code) it would be continually accessed time and time again.
cheers Mark Saunders :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top