Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Calling a Different Form when Show() from another form



Permlink Replies: 4 - Last Post: Sep 28, 2015 11:53 AM Last Post By: Remy Lebeau (Te...
Doug Hay

Posts: 122
Registered: 5/26/05
Calling a Different Form when Show() from another form
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 22, 2015 12:19 PM
In my project I have a sort of generic library form with functions that read the INI file and things like that. In the project options, I have this form listed before my main form (the form the user should see), then I just show my main form and hide the library form. A regular CPP file would be OK also, if that would work.

When my 'main' form starts it calls the INI functions, and the entire C++ Builder XE8 crashes. Why am I not able to call functions that I assumed should be available?

Thanks again for the help,
Doug
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Calling a Different Form when Show() from another form
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 22, 2015 9:12 PM   in response to: Doug Hay in response to: Doug Hay
Doug wrote:

When my 'main' form starts it calls the INI functions, and the entire
C++ Builder XE8 crashes. Why am I not able to call functions that I
assumed should be available?

Hard to say without seeing your actual code.

Are you calling the INI functions in the main Form's constructor? If so,
then the INI form has not been created yet. Either:

1. delay the INI calls until a later time, such as in the main form's OnShow
event

2. create the INI form first. Do not auto-create it in the Project Options,
or it will become the "main" form (the first form created by Application->CreateForm()
becomes the "main" form. In your project's WinMain(), or even in your main
form's constructor, use 'new' to create the INI form.

--
Remy Lebeau (TeamB)
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Calling a Different Form when Show() from another form
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 22, 2015 9:13 PM   in response to: Doug Hay in response to: Doug Hay
Doug wrote:

In my project I have a sort of generic library form with functions
that read the INI file and things like that. In the project options,
I have this form listed before my main form (the form the user should
see), then I just show my main form and hide the library form.

Why are you using a Form at all to expose access to an INI file? Why not
just make them flat functions? Or, forget the library and just use the RTL's
own TIniFile class directly instead.

--
Remy Lebeau (TeamB)
Doug Hay

Posts: 122
Registered: 5/26/05
Re: Calling a Different Form when Show() from another form
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 28, 2015 11:35 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
The INI functions are just one of 50 things in the file and really not relevant to the discussion. The issue is when can I call functions that are in different files in the project. The 'library' file contains generic functions that I call from all of my files in the project.

Thanks!

Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Calling a Different Form when Show() from another form
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 28, 2015 11:53 AM   in response to: Doug Hay in response to: Doug Hay
Doug wrote:

The issue is when can I call functions that are in different files in the
project.

If the functions are not members of a class, or are static members, then
you can call them at anytime. If they are non-static members of a class,
they cannot be (safely) called until after an instance of that class has
been created first.

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02