
June 20th, 2003, 02:54 PM
|
 |
Big Endian
|
|
Join Date: May 2001
Location: Fly-over country
|
|
Once solution using a header file was discussed a few days ago:
http://forums.devshed.com/showthread.php?threadid=64656
Another solution that can work in BCB is to use a DataModule. The original concept behind a data module was to put all of your connection controls, client datasets, etc. into a global class that could be accessed by all the forms. Since there is only one copy of this object created at program start, it can also be used to store global values. For example in my program under Project->Option->Forms, I Auto-Create my main MDI form and my DataModule. I store constants at the top of the .h file. I store global variables as public properties of the class. I also have some global functions which are methods of the class. Any initialization can be done in the DataModule constuctor. Then from my code I can call them like:
UserName->Text = GlobalDM->UserName;
Or I can have a central error logging routine I can call from any form:
GlobalDM->ProcessError(ErrType, ErrNbr, ErrDescription, FormName, FormRoutine);
I don't know if one method is better than the other. They have both worked for me.
Last edited by dcaillouet : June 20th, 2003 at 02:56 PM.
|