Board index » cppbuilder » Dialog in main form constructor
William Riley
![]() CBuilder Developer |
Dialog in main form constructor2006-11-07 10:11:02 AM cppbuilder71 Here's my problem. I have a program with several forms. One form is a dialog box that I made using the Dialog wizard. This sets up an Application->CreateForm instance for the dialog. Here is the basic file Application->Initialize(); Application->CreateForm(__classid(TMIBdownloadForm), &MIBdownloadForm); Application->CreateForm(__classid(TadminLoginForm), &adminLoginForm); Application->CreateForm(__classid(TpasswordAdminForm), &passwordAdminForm); Application->CreateForm(__classid(TverifyErrorForm), &verifyErrorForm); Application->CreateForm(__classid(TMIBToolDirectoryDialog), &MIBToolDirectoryDialog); Application->Run(); Now when the CreateForm for the main Form (MIBdownloadForm) runs its constructor calls the MIBToolDirectoryDialog which is not create yet and gives me an error. If I move the CreateForm for MIBToolDirectoryDialog ahead of the CreateForm for the main form MIBdownloadForm then the constructor for main form seems to work correctly but then evidentily Application->Run thinks the first form create is the main form which is now the dialog and not the main form. so the dialog form runs again and closes the app if I close the dialog. The only way around this I can think of is to remove the dialog from the project list and make it a member of the main form. Some how this does seem to be a correct solution and wonder if it will correctly without any hidden problems. Is there a better way to do this. I also do not understand how the application closes. If I try to use the Close() function in the main form constructor it does not close the app. The app will still run the other CreateForm statements. This is a problem since another form uses some dynamic variables that are create and initialized in the main form constructor. If I cannot create these variables I want to quit the app but the then the other CreateForm statements run and give me an error when they try to access the members in the main form. Note that Application->Terminate() instead of Close() results in the same behavior. Any suggestions. I think I can use some boolean state variables and finally work around the problem but seems like there should be a simplier, more direct solution. Bill |