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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to create an Object given its name and its class name?

Status
Not open for further replies.

dohamsg

Programmer
Sep 24, 2007
2
0
0
Hi,

Here is a link to a sample code implementing a user interface ( SDI, because MDI is confusing for many users ).

At the event : FormShow of the Main Form, I don't know how to restore the last embedded form, using its name and its Class name; any suggestions will be appreciated.


NB. the project uses only native delphi 2007 components.

Thanks.
 
I know this not where to put it but might be what you're looking for:
Code:
procedure TfrmMain.FormShow(Sender: TObject);
begin
  with Sender as TForm do
    ShowMessage('Sender is ' + Sender.ClassName);


Roo
Delphi Rules!
 
I haven't actually downloaded your code to look at, but in the FormShow you can use FindComponent to find a form if you know its name. FindComponent returns a TComponent, so you will need to cast the result to TForm (or whatever type you expect)

e.g.
Code:
procedure TMainForm.FormShow(Sender: TObject);
var
  frmLastForm: TForm;
begin
  frmLastForm := Application.FindComponent('EmbeddedForm1') as TForm;
end;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top