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

相关推荐
AA陈超5 小时前
ASC学习笔记0014:手动添加一个新的属性集
c++·笔记·学习·ue5
Run_Teenage5 小时前
C++:智能指针的使用及其原理
开发语言·c++·算法
Mr_WangAndy7 小时前
C++_chapter15_C++重要知识点_auto,function,bind,decltype
c++·decltype·bind·function·可调用对象
万象.8 小时前
QT基础及对象树的认识
c++·qt
小张成长计划..10 小时前
【C++】2:cin和cout的介绍和使用,函数的缺省参数
c++
再卷也是菜10 小时前
C++篇(17)哈希拓展学习
c++·哈希
“愿你如星辰如月”10 小时前
Linux:进程间通信
linux·运维·服务器·c++·操作系统
灵晔君11 小时前
C++标准模板库(STL)——list的模拟实现
c++·list
Justinyh12 小时前
1、CUDA 编程基础
c++·人工智能
white-persist13 小时前
差异功能定位解析:C语言与C++(区别在哪里?)
java·c语言·开发语言·网络·c++·安全·信息可视化