591

sharing Global variables in BCB

Am o problema de partajare a variabilelor yntre unituri, de exemplu vreau sa atribui valoare unei variabile declarate yn alt unit shi nu obtzin nish o figa ceea ce vreau.iata de exeplu(mai jos), yn functziavoid TfrmSettings::SetFormValues()Term.COMName nu ia valoarea "aaa".Pls help, unde e buba?++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//---------------------------------------------------------------------Unit1.h#ifndef Unit1H#define Unit1Hclass TForm1 : public TForm{ __published:// IDE-managed Components TButton *btnT_Activate; __fastcall TForm1(TComponent* Owner); bla bla bla};class Settings{public:// Serial Port AnsiString COMName;};Settings Term;//---------------------------------------------------------------------------extern PACKAGE TForm1 *Form1;//---------------------------------------------------------------------------#endif++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//-----------------------------------------------------------------fSettings.h#ifndef fSettingsH#define fSettingsH//---------------------------------------------------------------------------#include #include #include #include //---------------------------------------------------------------------------class TfrmSettings : public TForm{__published:// IDE-managed Components TButton *btnApply; void __fastcall btnApplyClick(TObject *Sender); void __fastcall FormClose(TObject *Sender, TCloseAction &Action);private:// User declarationspublic:// User declarations __fastcall TfrmSettings(TComponent* Owner); void SetFormValues(bool getset);//Copy values, Settings Class Form Compoents void SetComponentVal();//Set values to Components};//---------------------------------------------------------------------------extern PACKAGE TfrmSettings *frmSettings;//---------------------------------------------------------------------------#endif++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//---------------------------------------------------------------fSettings.cpp#include #pragma hdrstop#include "fSettings.h"#include "Unit1.h"#include "Globalvars.h"#include //---------------------------------------------------------------------------#pragma package(smart_init)#pragma resource "*.dfm"TfrmSettings *frmSettings;//---------------------------------------------------------------------------__fastcall TfrmSettings::TfrmSettings(TComponent* Owner) : TForm(Owner){}//---------------------------------------------------------------------------void TfrmSettings::SetFormValues(){ Term.COMName="aaa";//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! aici e buba}//void//---------------------------------------------------------------------------void __fastcall TfrmSettings::btnApplyClick(TObject *Sender){SetFormValues();Close();}//---------------------------------------------------------------------------
0