Form1 connects to a database and keeps the connection in a published property Form1->DBSession.
In the project source I would like to make sure that this session is closed, even if the program is aborted throwing an exception (in a library).
My code includes the form using
USEFORM("fForm1.cpp", Form1);
When writing this code in WinMain
try {
Application->Initialize();
Application->CreateForm( __classid(TForm1), &Form1 );
Application->Run();
}
__finally
{ Form1->DBSession->Close(); }
the compiler does not compile as it does not know TForm1. I cannot include the header file as I need to use USEFORM and get a redeclaration error including.