Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

C++ Builder 6 - Controlling the main form

Hi,

Can anybody tell me how to control the main form. I want to make the main form appear depending on a check that i am going to make. For example when running the exe, i need to check first if the username and password is already present in the Registry. If it is present then i wont show the login. If the login is not correct, i shouldn't get the main form but the login again.In which event of the main form should i do this check so as to make the main form appear depending on the result of this check?
[523 byte] By [rowin] at [2007-11-11 7:52:41]
# 1 Re: C++ Builder 6 - Controlling the main form
The password form should be the "main" form as it is what will be shown first. That form's init will check the registry and call the (user's form?) if it matches or after the password is correct.

To fix it now, you might have your init of your main form set itself to (visible = false) and spawn the password form. The password form will check registry, and when everything checks out somehow tell the main form to be visible again.
jonnin at 2007-11-11 21:01:52 >
# 2 Re: C++ Builder 6 - Controlling the main form
I can't have the password form be the main since it wo't appear everytime but only for the first time. The username and password will then be saved in the registry and the password form won't be shown again.
rowin at 2007-11-11 21:02:48 >
# 3 Re: C++ Builder 6 - Controlling the main form
Is the password form the one that checks the registry (form may not be displayed while it checks the registry, but does it do the work?)
If so, then it should be the "main" form and spawn the "user form" (on successful password). This seems to me to be the easiest from a coding standpoint.

If not, then your "main" form is the user form and it should hide itself (on init), check the registry(still in on init), decide to display the password form or not, pass data back from the password form (valid to unhide (bool)), and then unhide the main form (exit on-init and proceed).

does that make sense? Both approaches should work fine. Message passing is a little extra code, and the user form being the "starting point" makes it more complicated.
jonnin at 2007-11-11 21:03:47 >
# 4 Re: C++ Builder 6 - Controlling the main form
Ok.
thanks a lot for the help
rowin at 2007-11-11 21:04:46 >
# 5 Re: C++ Builder 6 - Controlling the main form
Mm nice
I've just joined but this forum already seems to be useful for me
Thanks

P.S.: C++ rules :P
DakDarie at 2007-11-11 21:05:56 >