Page 1 of 1
how can i show/hide/load/unload a form in VC++?
Posted: Sat Jul 19, 2003 6:34 pm
by Scarberry
how can i show/hide/load/unload a form in VC++?
thanks
Re:how can i show/hide/load/unload a form in VC++?
Posted: Mon Jul 21, 2003 2:22 pm
by anubis
I thought that forms came with Visual Basic only!
Are you talking about dialogs(as called in VC++) that u call as forms in VB?? ???
Re:how can i show/hide/load/unload a form in VC++?
Posted: Mon Jul 21, 2003 7:33 pm
by scarberry
lol I start w/ QBasic then moved to VB so i guess the term Forms just stuck. in fact i thought the dialogs were called forms in VC++. lol o well and yes that is what i was talking about can u help?
Re:how can i show/hide/load/unload a form in VC++?
Posted: Tue Jul 22, 2003 7:30 am
by anubis
Ok, Dialogs or Forms r one of the simpest things to program in VC++.
Take any existing or create a new workspace in VC++(can be anything really doesnot matter), then use the menu option Insert->Insert Resource, give it any name u want but it doesnot take spaces. There u will see the dialog option. Click it. Now in the Nearby workspace bar having <-class-><-res-><-fileview->tabs .click on the res tab and then click on the Dialogs. Here u will see the dialog u have made. Click it and see the different properties it has. U can insert different controls and componenets u want on the dialog.
Before we go further first i would like to know whether u r using MFC or simple Win 32 for your code??? That is important cos we have to code the dialogs in the application.
Re:how can i show/hide/load/unload a form in VC++?
Posted: Tue Jul 22, 2003 11:28 pm
by scarberry
im using MFC and i know how to add forms to a project and such but its loading them and showing them from code. in VB it would be "form.show". thats the sort of thing i want.
thanks
Re:how can i show/hide/load/unload a form in VC++?
Posted: Wed Jul 23, 2003 8:10 am
by bkilgore
If you want to bring up a dialog box and have it stay there until it is closed (with ok/cancel/X, etc), you want to call the DoModal function. So if MFC created a dialog class for you called CMyDialog, you would do the following:
Code: Select all
CMyDialog dlg; /* Create an instance of the dialog */
dlg.DoModal(); /* Bring up the dialog as a modal window */
the DoModal function block (doesn't return) until after the dialog is closed, as this is what a modal window does.
If you want to bring up the dialog asynchronously and be able to control it after it's created from the code that opened it, you will have to call the Create() member function. THis is a little harder to use, so you probably want to look up the details on msdn at
http://msdn.microsoft.com/library/
Basically you create the dialog and then you can interact with it through some of its member functions. For instance, to hide the dialog after creating it, you can call ShowWindow(SW_HIDE) to hide it and ShowWindow(SW_SHOW) to show it again. Look through the msdn information on CDialog classes and CWnd classes for more information.
Re:how can i show/hide/load/unload a form in VC++?
Posted: Wed Jul 23, 2003 4:08 pm
by scarberry
ah thank you