Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Multiple files

Multiple files

Multiple files

Hi, this is probably basic, but it is driving me nuts.  I built two programs totaly seperate from each other with Builder5.  I am trying to use a button on one form to open the other program/form modaly and do stuff with that one, then exit and go back to the first one.  It seems that with some tinkering I can get them to work, but I hate doing it that way, I try it the same way with another program that has a lot of variables and then I get multiple declarations, it never seems to be the same.  When I cleared those out of the way, I get a duplicate declaration error on this statment "TDisplayMessage *DisplayMessage;"  I put a #ifndef statement in there and then the next line won't work...right on down the line.  Basicaly, how do you get two forms to work together without conflicting???
thnx for the patience.

RE: Multiple files


It's hard to catch what may be wrong for sure. Your problem may be due that file 1 includes file 2 and file 2 includes file 1. Kind of round trip. It is most of the time possible to get out of this kind of problem by a careful organisation of declarations and definitions.

I don't know if this is relevant to your problem, but why not creating a third object, (an "association class") whose role would be to hold a pointer to an instance of each form, and to manage the communication between each form.

In this case, the forms don't have to know each other; instead, they need to know their father. You avoid the "round trip" include loop.

Then Form1 accesses Form2's methods by something like this:


where CallForm2sMethod implements the call you need to Form2.

Hope that helps


RE: Multiple files

Visit Borland (Inprise): C++ Builder. They can get you big help with C++ Builder. Here is the older versions of Borland C++.

RE: Multiple files

so you want to open another program in your first one? if thats what you want, do this:


//selects the program and how to use it
        SHELLEXECUTEINFO exeinfo;
        memset(&exeinfo, 0, sizeof(exeinfo));

        if (!ShellExecuteEx(&exeinfo))
         MessageDlg("Your IP config. file is missing.", mtError, TMsgDlgButtons() << mbOK,0);

This will open WinIPCfg, the program to find your local IP address. you can modify it to open any other program just like that.


RE: Multiple files

Technicaly, I don't want to open a seperate file, I want to compile it into one larger file, makes it simpler for persons using it when I e-mail it to them.  I guess want to make it modal, they have to finish it to get back to the original window.  I want to compile the first program, get it working then make a second that will do something else.  Then put a button on the first the will run the second in a modal window then when that one is done close it and return to the first window.  I have gotten this to work, but it seems to be guess work, I thought just including the second file and then using SecondWindow->ShowModal() would work, but I can't just incluse the *.cpp file because some of the initializing...I assume... is being done behind the scenes in other files that Borland creates, when I try to include those files, I get errors.  I hope I didn't just confuse the issue, but it is the best I can do.  Thanx, and I will have to make a note of how to make files run seperately, it is a good idea.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close