Send a message to the parent form, here only send wm_notify message, the other message is the same
To set a program that sends messages in a function in a control
First, define a dedicated structure for the WM_NOTIFY message.
123456; // here is the message of the difference code nm.hwndfrom = m_hwnd; // This is the HWND handle of the control Nm.idfrom = GetDlgCtrlID (); // This is the ID of the resulting dialog box
cwnd* pWnd; = GetParent (); Gets the parent form window if (pWnd! = NULL) { pWnd->sendmessage (wm_notify, Nm.idfrom , (LPARAM) &nm); Send a message to the parent form }
This allows the message to be sent to the parent form.
In the code of the parent form, only the WM_NOTIFY message needs to be processed, that is, the virtual function that implements the On_notify
BOOL cmycontroldlg::onnotify (WPARAM WPARAM, LPARAM LPARAM, lresult* pResult) { if (UINT) WPARAM = = idc_custom2) { AfxMessageBox (_t (" success ")); } return cdialogex::onnotify (WParam, LParam, PResult);}
Idc_custom2 This is an ID number that any resource will have
Can be found in the following way
C + + Custom control controls send a corresponding message to the parent form