It's really strange looking C++ for .NET... Try C# - it's same C++ but better. C++ are great (I program on it for many years), but in .NET C# is my choice!
AppDomain - complex subject, something like place where whole objects live. But, if you unload it - you unload all objects, including main form. So, you will need at least 2 domains (default + one more) and a lot of code that you don't need for this task.
Your app must looks like 2 steps: login and work. Login done at startup, then run main form if login completed successfully. Don't run main form from login, it's separate object.
I didnt understand your last sentence. In my login.h, i did an #include "mainProg.h", so after I have validated that the correct username and password has been entered, I will run those 4 lines of code I pasted earlier. Are you telling me thats a bad idea
I havent tried C# .NET yet :) Maybe some time soon hehe.
Ok, I agree with your method about loading the main form and calling the login form out first to verify. I guess I could do that with the onLoad form event in main :)
Before that Hide(), there's a MessageBox, so after I click OK on that MessageBox, the login.h form will be hidden, and then mainProg.h will be loaded after that, and the whole program will be unloaded from memory with Close().
If you want to free memory - it's not your task in .NET, it's GC work.
If you want to close/hide form - call Close().
If you want real unload - you must create app domain and unload it, but I don't think this is what you need.
For typical Login form - it's a dialog. When you validate user - set DialogResult = DialogResult.OK and form will close automatically. Call this form like this:
Yes, when your LoginForm complete work it must be closed, just like any other dialog. Your application is the place where you can call Login() and next call MainForm.Show(). Like this in C#:
Or you may choose different scenario - run main form, hide content, inside OnLoad event show Login and if it's ok - show content, if fails - close main form.
Definetely try C# - transition is not too hard and the source looks much cleaner here!
Unloading a form
ghazi
Argonautic
AppDomain - complex subject, something like place where whole objects live. But, if you unload it - you unload all objects, including main form. So, you will need at least 2 domains (default + one more) and a lot of code that you don't need for this task.
Your app must looks like 2 steps: login and work. Login done at startup, then run main form if login completed successfully. Don't run main form from login, it's separate object.
forteous
I didnt understand your last sentence. In my login.h, i did an #include "mainProg.h", so after I have validated that the correct username and password has been entered, I will run those 4 lines of code I pasted earlier. Are you telling me thats a bad idea
I havent tried C# .NET yet :) Maybe some time soon hehe.
Bob5461
RobertG1
Thanks for replying. I have an alternative, I'm not sure if its better or worse, what do you think :)
Hide();
mainProg ^mainprog = gcnew mainProg();
mainprog->ShowDialog();
this->Close();
Before that Hide(), there's a MessageBox, so after I click OK on that MessageBox, the login.h form will be hidden, and then mainProg.h will be loaded after that, and the whole program will be unloaded from memory with Close().
You mentioned app domain How's that done
Nate52
Hi!
What do you mean "unload"
If you want to free memory - it's not your task in .NET, it's GC work.
If you want to close/hide form - call Close().
If you want real unload - you must create app domain and unload it, but I don't think this is what you need.
For typical Login form - it's a dialog. When you validate user - set DialogResult = DialogResult.OK and form will close automatically. Call this form like this:
if(new LoginForm().ShowDialog()==DialogResult.OK)
{
}
Sorgavana
Yes, when your LoginForm complete work it must be closed, just like any other dialog. Your application is the place where you can call Login() and next call MainForm.Show(). Like this in C#:
class Program
{
}
Or you may choose different scenario - run main form, hide content, inside OnLoad event show Login and if it's ok - show content, if fails - close main form.
Definetely try C# - transition is not too hard and the source looks much cleaner here!