Guest_imported
New member
- Jan 1, 1970
- 0
My code below has two Forms. On Form1 is a checkbox and in FormClose the checkbox status is saved to a file. At FormCreate the checkbox status is read and if true I wanted to display Form2. When the checkbox is true I get an Access Violation Error. What am I doing wrong?
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
TIniFile *WinIni = new TIniFile("IniTester.ini"
if (CheckBox1->Checked==true)
WinIni->WriteBool ("CheckBox1", "checked", true);
else
WinIni->WriteBool ("CheckBox1", "checked", false);
delete WinIni;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
TIniFile *WinIni = new TIniFile("IniTester.ini"
CheckBox1->Checked=(WinIni->ReadBool("CheckBox1","Checked",CheckBox1->Checked));
delete WinIni;
Form1->Refresh();
if (CheckBox1->Checked==true)
{
Form2->Show();
}
}
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
TIniFile *WinIni = new TIniFile("IniTester.ini"
if (CheckBox1->Checked==true)
WinIni->WriteBool ("CheckBox1", "checked", true);
else
WinIni->WriteBool ("CheckBox1", "checked", false);
delete WinIni;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
TIniFile *WinIni = new TIniFile("IniTester.ini"
CheckBox1->Checked=(WinIni->ReadBool("CheckBox1","Checked",CheckBox1->Checked));
delete WinIni;
Form1->Refresh();
if (CheckBox1->Checked==true)
{
Form2->Show();
}
}