My skills as a programmer are limited, although I have been using C++Builder since version 3.
I have a project in C++Builder 2007 with a class having a property "aVers" returning the FileVersion in an AnsiString.
For certain values of FileVersion I want the application to show a message and close immediately after the OK button has been pressed. When I use the "Close()" function, the following message appears after I press OK: "Cannot change Visible in OnShow or OnHide." with the red dot and white cross in its window. After pressing OK again, the application is NOT closed.
To get it working I added a Timer component to the main Form with a 100 msec Interval. In the Timer function I call Close(). This setup works as I want it. But I have the feeling that it is not good practice...
The relevant code snippets follow.
In this example, when I comment out "Close()" and uncomment "Timer1-> etc." it works fine; as shown it fails.
What can be the reason for the error message as described above and how should I tackle this problem? Your comments will be welcomed!
Alex314
I have a project in C++Builder 2007 with a class having a property "aVers" returning the FileVersion in an AnsiString.
For certain values of FileVersion I want the application to show a message and close immediately after the OK button has been pressed. When I use the "Close()" function, the following message appears after I press OK: "Cannot change Visible in OnShow or OnHide." with the red dot and white cross in its window. After pressing OK again, the application is NOT closed.
To get it working I added a Timer component to the main Form with a 100 msec Interval. In the Timer function I call Close(). This setup works as I want it. But I have the feeling that it is not good practice...
The relevant code snippets follow.
Code:
...
// // this code is in the FormActivate function
// get the version now
//TRadio *VersObj; // TRadio is defined in the Main Form header code.
RadioObj = new TFreq; // TFreq is a class derived from TRadio;
// retrieves the Version of App2 from
// "App2.exe". Makes use of "CreateProcess"
// and hides the console window when active.
Version = RadioObj->aVers;
delete RadioObj;
RadioObj = NULL;
if ((Version.AnsiPos("a")) || (Version.AnsiPos("b"))) {
ShowMessage ("unsupported Version " + Version + ";\n"
" the application will exit.");
//Timer1->Enabled = true;
Close();
}
...
Code:
...
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
Close();
}
...
In this example, when I comment out "Close()" and uncomment "Timer1-> etc." it works fine; as shown it fails.
What can be the reason for the error message as described above and how should I tackle this problem? Your comments will be welcomed!
Alex314