【MFC常用问题记录】

MFC 记录

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);

参考:

1.线程函数报错: 没有重载函数 "AfxBeginThread"的实例与参数列表匹配

相关推荐
夜悊4 小时前
C++代码示例:进制数简单生成工具
c++
郝学胜_神的一滴5 小时前
CMake 021: IF 条件判据详诠
c++·cmake
_wyt00119 小时前
洛谷 B3930 [GESP202312 五级] 烹饪问题 题解
c++·gesp
玖玥拾1 天前
C/C++ 数据结构(七)栈、容器适配器
c语言·数据结构·c++··容器适配器
один but you1 天前
constexpr函数
c++
凡人叶枫1 天前
Effective C++ 条款41:了解隐式接口和编译期多态
java·开发语言·c++·effective c++
凡人叶枫1 天前
Effective C++ 条款42:了解 typename 的双重意义
java·linux·服务器·c++
小胖xiaopangss1 天前
BRpc使用
c++·rpc
-森屿安年-1 天前
63. 不同路径 II
c++·算法·动态规划
chase_my_dream1 天前
Cartographer详细讲解
c++·人工智能·自动驾驶