MFC 记录
- MFC的edit control控件显示
- 1.控件添加变量M_edit后:
- 2.控件ID为IDC_EDIT1:
- 线程函数使用
MFC的edit control控件显示
1.控件添加变量M_edit后:
CString str;
int x = 10;
str.Format(_T("%d"),x);
M_edit.SetWindowText(str)
2.控件ID为IDC_EDIT1:
CString str;
int x = 10;
str.Format(_T("%d"),x);
SetDlgItemText(IDC_EDIT1,str);
线程函数使用
采用afxBeginThread():
UINT __cdecl ThreadSHOW(LPVOID lParam);//声明UINT __cdecl ThreadSHOW(LPVOID lParam)//定义
{CMFCApplication1Dlg* pDlg = (CMFCApplication1Dlg*)pParam;CString str_num;for (;;){if (pDlg->show_flag){str_num.Format(_T("%d"), pDlg->int_num++);pDlg->SetDlgItemText(IDC_EDIT1, str_num);}if (pDlg->thread_stop_flag){return 0;}}
}
//show_flag、int_num、thread_stop_flag都是在mfc的类中定义的全局变量
//调用
AfxBeginThread(ThreadSHOW, (LPVOID)this);
参考:
1.线程函数报错: 没有重载函数 "AfxBeginThread"的实例与参数列表匹配