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!

Multiple forms 1

Status
Not open for further replies.

michaenh

Programmer
Aug 7, 2002
205
NO
Hi everyone.

I am back again with more questions.
Well I have multiple forms and I want to open a specific form.

Here is my code:
// Get wizard
procedure TMainForm.GetWizard(SID: integer);
begin
case SID of //SID is a uniq identifier from my database
1: OpenWizard(TFormA01.Create(Self)); //SA01
2: OpenWizard(TFormA02.Create(Self)); //SA02
7: OpenWizard(TFormA07.Create(Self)); //SA07
else
MessageDlg('Case error! Michael', mtError, [mbOK], 0);
end;
end;

// Open Wizard
procedure TMainForm.OpenWizard(Wizard : TForm);
begin
try
Wizard.Top := 250; //126;
Wizard.Left := 450; //260;
Wizard.Caption := NodeTv.Text; //retrieve text from treeview
Wizard.ShowModal;
finally
FreeAndNil(Wizard); //free
end;
end;

To solve my question is how do I refer to a special form instead of using case sentences.

I want to create a better code(more dynamic program).
Maybe something like this:
OpenWizard(temp.Create(Self));

temp is variabel that I get from a database. (the name of the form). I will get an error if it compare string with TForm.

Any solutions anyone? Any convertion between string and TForm? I dont think so?

Many thanks
Michael
 
func.
var
test: TLabel;
begin
test := TLabel(Self.FindComponent(temp)); //temp components name
test.Caption := 'test';
end;

Maybe there are some simular function with FindComponent...
???for FindForm????


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top