Click here to Skip to main content
15,913,090 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Linking the dialog and its class Pin
BaldwinMartin29-Nov-03 19:42
BaldwinMartin29-Nov-03 19:42 
GeneralRe: Linking the dialog and its class Pin
JWood29-Nov-03 19:46
JWood29-Nov-03 19:46 
GeneralRe: Linking the dialog and its class Pin
J.B.29-Nov-03 19:53
J.B.29-Nov-03 19:53 
GeneralAfxConnectionAdvice undeclared identifier Pin
Prakash Nadar29-Nov-03 18:26
Prakash Nadar29-Nov-03 18:26 
GeneralColoring slider Pin
georgiek5029-Nov-03 17:50
georgiek5029-Nov-03 17:50 
GeneralRe: Coloring slider Pin
BaldwinMartin29-Nov-03 19:44
BaldwinMartin29-Nov-03 19:44 
GeneralAddin Dialogs Pin
N.Byarley29-Nov-03 17:42
N.Byarley29-Nov-03 17:42 
GeneralRe: Addin Dialogs Pin
BaldwinMartin29-Nov-03 18:51
BaldwinMartin29-Nov-03 18:51 
Hi OK bring up your project and click on the resource view tab.
Expand the resources +
right click on the dialog folder
select insert dialog
right click on the dialog and select properties
Name the dialog something like IDD_MYDIALOG
right click on the dialog and select class wizard
Add a class dlg appears
select create a new class
call the new class something like CMyDialog
Alway start your classes with the capital C (it does not have to be this way but it will help later)
Select the base class as CDialog
select OK

If your project is a sdi or mdi select mainframe or view class
If you project is a dialog select the maindlg class

Select the cpp of the main class and at the top among the other #include statements insert the following

#include "MyDialog.h"

Note with left the C off the include statement.

Now put a button on your main dialog and right click and change the properties to IDC_MYBUTTON

double click on the button and add a handler
it will look like this

void MyMainClass::OnMybutton()
{
// TODO: Add your control notification handler code here

}


now add the follow code to the OnMyButton handler

CMyDialog dlg;
if(dlg.DoModal() == IDOK){
AfxMessageBox("We are back in the main class and you selected OK in the child dialog MyDialog");
}


So the button handler should look like this

void MyMainClass::OnMybutton()
{
CMyDialog dlg;
if(dlg.DoModal() == IDOK){
AfxMessageBox("We are back in the main class and you selected OK in the child dialog MyDialog");
}
}

compile and run

So what you have done is:
1. insert a new resource MyDialog
2. created a new class based on CDialog
3. Added a include statement to the class you wish to call the dialog from
4. added a button
5. created a handler for the button
6. added the code to call the button
7. returned to the calling class.

good luck and keep up the good work!




Best Wishes and Happy Holiday's,
ez_way
GeneralRe: Addin Dialogs Pin
Scozturk29-Nov-03 22:53
professionalScozturk29-Nov-03 22:53 
Questionpassing variable argument list to another function? Pin
nm_11429-Nov-03 17:28
nm_11429-Nov-03 17:28 
AnswerRe: passing variable argument list to another function? Pin
BaldwinMartin29-Nov-03 19:40
BaldwinMartin29-Nov-03 19:40 
GeneralRe: passing variable argument list to another function? Pin
nm_11429-Nov-03 20:13
nm_11429-Nov-03 20:13 
AnswerRe: passing variable argument list to another function? Pin
cmk29-Nov-03 20:30
cmk29-Nov-03 20:30 
GeneralRe: passing variable argument list to another function? Pin
nm_11430-Nov-03 11:20
nm_11430-Nov-03 11:20 
GeneralAppending 2 RTF Strings together Pin
Zero_divide_129-Nov-03 16:41
Zero_divide_129-Nov-03 16:41 
GeneralRe: Appending 2 RTF Strings together Pin
JWood29-Nov-03 18:07
JWood29-Nov-03 18:07 
GeneralRe: Appending 2 RTF Strings together Pin
Zero_divide_11-Dec-03 5:43
Zero_divide_11-Dec-03 5:43 
GeneralrichEdit hook Pin
Anonymous29-Nov-03 16:37
Anonymous29-Nov-03 16:37 
GeneralConversion, string to int Pin
__Cerb29-Nov-03 16:33
__Cerb29-Nov-03 16:33 
GeneralRe: Conversion, string to int Pin
JWood29-Nov-03 18:10
JWood29-Nov-03 18:10 
GeneralRe: Conversion, string to int Pin
Michael Dunn29-Nov-03 19:45
sitebuilderMichael Dunn29-Nov-03 19:45 
GeneralRe: Conversion, string to int Pin
BaldwinMartin29-Nov-03 20:07
BaldwinMartin29-Nov-03 20:07 
GeneralRe: Conversion, string to int Pin
Scozturk29-Nov-03 22:58
professionalScozturk29-Nov-03 22:58 
GeneralRe: Conversion, string to int Pin
Ian Darling29-Nov-03 23:33
Ian Darling29-Nov-03 23:33 
QuestionHow to release a GDI+ object? Pin
YanBin29-Nov-03 16:04
YanBin29-Nov-03 16:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.