【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"的实例与参数列表匹配

相关推荐
老歌老听老掉牙6 小时前
案例 7:二维 Rosenbrock 函数最小值(香蕉函数)
c++·pso
Severus_black7 小时前
【C++初阶】Stack、Queue算法题大练兵!
c语言·c++·算法·stl
xiaoye-duck11 小时前
《C++ 项目:手写大模型接入 SDK》DataManager数据管理模块:SQLite持久化存储
开发语言·数据库·c++·sqlite
是main不是漫12 小时前
【C++——类和对象(上)】筑基篇:以封装奠定面向对象之基
c语言·开发语言·c++
小七在进步1 天前
string的使用(1)
c++·visual studio
白杨尚青1 天前
C++进阶篇(六):map 和 set 的模拟实现——用红黑树封装 mymap/myset(迭代器 + operator[])
开发语言·c++·迭代器·stl·set·map·红黑树
kloc1 天前
聊天室项目入口网关子服务的实现
linux·c++
csdn_aspnet1 天前
C++ 3个有序点的方向(Orientation of 3 ordered points)
c++·算法
小七在进步1 天前
string的使用(2)
c++
青少儿编程课堂1 天前
蓝桥杯·全国青少年信息素养大赛·电子学会Python/C++考级:折半搜索优化子集枚举(Meet in the Middle)解析
c++·python·算法·bfs·信息学竞赛