Just add the resource header file.
#include "Resource.h"
Send message in MFC thread
1. Write the meaning first and accept it
#define WM_SET_FOCUS WM_USER+100
BEGIN_MESSAGE_MAP(CWriteSnDlg, CDialogEx)
//
ON_MESSAGE(WM_SET_FOCUS, OnSetFocus)
END_MESSAGE_MAP()
afx_msg LRESULT OnSetFocus(WPARAM wP, LPARAM lp);
LRESULT CWriteSnDlg::OnSetFocus(WPARAM wP, LPARAM lp)
{
UNREFERENCED_PARAMETER(wP);
UNREFERENCED_PARAMETER(lp);
GetDlgItem(IDC_EDIT1)->SetFocus();
return 0;
}
2. Send message
UINT WriteSNProc(LPVOID lParam){
CWriteSnDlg *pWnd = (CWriteSnDlg *)lParam;
PostMessage(*pWnd,WM_SET_FOCUS, NULL,NULL);
//SendMessage(*pWnd,WM_SET_FOCUS, NULL,NULL);
}
PostMessage(this,WM_SET_FOCUS, NULL,NULL);
Read More:
- Error c2065: ‘QAPP’: undeclared identifier [Solved]
- Error c2065: “gwl_wndproc”: undeclared identifier [How to Solve]
- [Solved] Vs2015 error c2065: undeclared identifier error (__func__)
- LINK : fatal error LNK1104: Cannot Open the File “mfc90ud.lib”
- QT Error: use of undeclared identifier [How to Solve]
- [Solved] Android Studio Error: Use of undeclared identifier ‘cv‘
- [Solved] error: ‘IEEE80211_BAND_2GHZ’ undeclared here (not in a function)
- Buffer I/O Error in /var/log/messages
- [Solved] Error ‘false‘ undeclared (first use in this function)
- Kafka error: ERROR There was an error in one of the threads during logs loading: java.lang.NumberFormatException: For input string: “derby” (kafka.log.LogManager)
- Failed to register bundle identifier. The app identifier “xxx” cannot be registered to your developm
- Using elementui El-dialog as a subcomponent to close an error
- Eslint Error:“Identifier xxx is not in camel case“
- [Solved] spring boot – JPA–H2 Error: H2 error: “Syntax error in SQL statement … expected identifier“
- Android studio does not prompt error messages [How to Solve]
- How to Solve Fatal error stdatomic in C/C++ Compilation
- [Solved] MATLAB and pycharm open error messages at the same time
- C Language error: two or more data types in declaration specifiers
- Sending ‘const NSString *’ to parameter of type ‘NSString *’ discards qualifiers [Solved]