How can i get the name of the Form, that i've called Showmodal one step before ( parentform )

Posted on 2011-02-15
Last Modified: 2012-05-11

i am using Delhpi 7, and would like to get the parent form name after called Showmodal.

when i place a button on the main form ( called : Main_1 ), and create a new form ( called . Parent_1 ), the buttonclick does : showmodal Parent_1.

and when the active form is Parent_1, i wolud like to get it's parent name ( Main_1 ).

can anyone help me?
Question by:RT_
LVL 32

Accepted Solution

ewangoya earned 50 total points
ID: 34897934

Two ways I can think of

1. Make the calling form the Owner of the form being created

    Form2 := TForm2.Create(Self);  //where self is the current form

    Then in Form2 to get the calling forms name/title you can use
    if (Owner is TForm) then
       TitleOfCaller := TForm(Owner).Caption
    //nameOfCaller := TForm(Owner).name

2.   Add the parent form title to the form and pass it on create

    TForm2 = class(TForm)
       FParentFormTitle: string;
       property ParentFormtitle: string read FParentFormTitle write FParentFormTitle;

    when calling from MainForm
    Form2 := TForm2.Create(Application);
      Form2.ParentFormTitle := Caption;


Author Closing Comment

ID: 34898098
lot of thanks!

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question