MFC 记录
- [MFC的edit control控件显示](#MFC的edit control控件显示)
- 线程函数使用
MFC的edit control控件显示
1.控件添加变量M_edit后:
cpp
CString str;
int x = 10;
str.Format(_T("%d"),x);
M_edit.SetWindowText(str)
2.控件ID为IDC_EDIT1:
cpp
CString str;
int x = 10;
str.Format(_T("%d"),x);
SetDlgItemText(IDC_EDIT1,str);
线程函数使用
采用afxBeginThread():
cpp
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的类中定义的全局变量
//调用
cpp
AfxBeginThread(ThreadSHOW, (LPVOID)this);
参考: