Home > Software engineering >  MFC button no response?
MFC button no response?

Time:10-03

First click on the menu bar after the button in the pop-up dialog
The code is
 void CCAGDBSplineView: : Onchangeparm ()//click on modify the response function of the curve parameter 
{
//TODO: add the command handler code
CDialog=new * DLG CDialog;
DLG - & gt; Create (MAKEINTRESOURCE (IDD_DIALOG1));
DLG - & gt; ShowWindow (1);
}
//and then click the button in the dialog box have no reaction
Void CParamDialog: : OnBnClickedButton1 ()
{
//TODO: add the control notification handler code
MessageBox (L "1");
}

Code is a double click on the button and then set the generated
Beginning with MFC don't know where I went wrong

CodePudding user response:

DLG CYourDialog *=new CYourDialog;

CodePudding user response:

Has been changed to CParamDialog * DLG=CParamDialog; But still didn't respond

CodePudding user response:

Message
H
1 afx_msg void OnButton1 ();

The CPP

2 ON_BN_CLICKED (IDC_BUTTON1, OnButton1)
//}} AFX_MSG_MAP
END_MESSAGE_MAP ()

3 void CListCtrl3Dlg: : OnButton1 ()

CodePudding user response:

Reply: upstairs still didn't understand, can say specific point? Novice to understand

CodePudding user response:

Can use the class wizard, the response message,

CodePudding user response:

2 ON_BN_CLICKED (IDC_BUTTON1, OnButton1)
//}} AFX_MSG_MAP
END_MESSAGE_MAP ()

3 void CListCtrl3Dlg: : OnButton1 ()
This is to write a few words in the CPP? What is written specification, didn't understand, what role

CodePudding user response:

Use the class wizard, he will give you,

Add is above 3 points

CodePudding user response:

"Menu" View "" has a" ClassWizard "called" "class wizard" "

CodePudding user response:

Thank you for your reply, still do not understand, what is the third point, write in what function

CodePudding user response:

3 void CxxxxDlg: : OnButton1 () is the response function of the button,

2 ON_BN_CLICKED (IDC_BUTTON1, OnButton1 ) is a message response

1 afx_msg void OnButton1 () ; Is the definition in the h file,

CodePudding user response:

After I double click is automatically add
Void CParamDialog: : OnBnClickedButton1 ()
{
//TODO: add the control notification handler code.
MessageBox (L "1");
}

CodePudding user response:

You also need to add a command in automatically add this function? Write directly messagebox click button no response

CodePudding user response:

You double click on the button above 1, 2, 3 are automatically help you write the
You can only use in OnBnClickedButton1 write specific response content in the ()
Why have no reaction, and which button is for you?

CodePudding user response:

Now have reaction, stumbled to the dialog to add a class, button to have the response, don't know why

CodePudding user response:

1/f, not answer
CYourDialog =new * DLG CYourDialog;
CYourDialog is for you to create a class, or you after changing CYourDialog compile all you will pass!

CodePudding user response:

DLG CYourDialog *=new CYourDialog;

CodePudding user response:

Void CCAGDBSplineView: : Onchangeparm ()
{
CTestDlg * pDiffCMDDlg;
PDlg=new CTestDlg ();
PDlg - & gt; Create (IDD_DIALOG_TEST);
PDlg - & gt; ShowWindow (SW_SHOWNORMAL);
}

Void CParamDialog: : OnBnClickedButton1 ()
{
MessageBox (" 1 ", "Note", MB_OK | MB_ICONERROR);
}


CodePudding user response:

Quote: refer to 17th floor Janxionwang response:

Void CCAGDBSplineView: : Onchangeparm ()
{
PDlg CYourDlg *;
PDlg=new CYourDlg ();
PDlg - & gt; Create (IDD_DIALOG_TEST);
PDlg - & gt; ShowWindow (SW_SHOWNORMAL);
}

Void CParamDialog: : OnBnClickedButton1 ()
{
MessageBox (" 1 ", "Note", MB_OK | MB_ICONERROR);
}
  • Related