Click here to Skip to main content
15,879,095 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a simple visual c++ windows forms application, at the moment there is only one form in this project say the form is FormA, i want to add another form FormB to the current project.

Now it is required that there is a button titled as "Show FormB" on FormA.
Upon clicking this button the FormB should be visible to the user and
FormA should be disabled,
Next when the user closes the FormB, FormA should be available to the user again,
On FormB there is also some interaction with Sql-Lite database.

Any ideas/solutions will be welcomed warmly.


Thanks

[Edit] question rearranged for readability by Jibesh[/Edit]
Posted
Updated 8-Feb-13 12:48pm
v2
Comments
Matthew Faithfull 8-Feb-13 7:35am    
You might want to clarify whether these 'forms' are .Net WinForms or MFC FormViews or completely custom Windows types you've written from scratch because the answer will depend heavily on what your 'forms' are.
Zia Ullah Khan 8-Feb-13 7:37am    
the forms are .Net WinForms
Matthew Faithfull 8-Feb-13 7:49am    
Ok that's not my bag but others will now be able to help more easily. You might even want to add C# to your tag list as .Net people who monitor that list may be more likely to know even if you're implementation is in C++/CLI.
Zia Ullah Khan 8-Feb-13 7:42am    
the forms are .Net WinForms
Argonia 8-Feb-13 8:36am    
Check the handler for the button click event and see if the member of the second CDialog [derived] class (assuming you mean dialog with form)calls DoModal()

This is a really bad idea. It looks like you want to show some sequence of forms, one at a time, like with a wizard. It can be something else. In any case, use only one form, just replace its content.

It the simplest form of it, it would be having a set of instanced of Panel filling the whole form and populated with controls you initially planned to have on each form. So a panel will represent a form content. Show only one form at a time, hide all others. Moving from one form to another one (for example, "Next") will be just hiding a visible panel and showing another one. You can design any more complex scenario.

—SA
 
Share this answer
 
It's not that tough to follow the steps you explained into code.

If you are displaying your FormB as Modal dialog { Form.ShowDialog() } from FormA,

just make the FormA.Visible = false;
Display Your FormB using ShowDialog
when you are done with Form
then call FormA.Visible = true;

There are other ways you can manage this UI behaviour. Its up to you and to choose whats best for you.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900