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

相关推荐
·present·10 小时前
CSAPP(lecture 4_01)
c语言·c++
FPGA小迷弟10 小时前
用 Claude Code 重构遗留系统:从评估到落地的完整实践指南
c++·python·ai·plotly·django·ai编程·claude
程序员-King.10 小时前
【ROS1】Noetic 开发工作流程与常用命令
c++·ubuntu·ros
云深麋鹿10 小时前
C++ | 基于红黑树实现mymap与myset
开发语言·c++
傲世仙尊12 小时前
string增删查改-insert-erase-replace与find加substr组合技
c++
·present·13 小时前
CSAPP(lecture 3)
c++
别动我齐刘海14 小时前
机器人 C++ / 系统联调补强2——异常处理、Protobuf
linux·c++·人工智能·学习·算法·机器学习·机器人
basketball61614 小时前
C++ 中字符串与常见类型的转换总结
开发语言·c++
等我调个Bug14 小时前
C++智能指针通俗讲解
开发语言·c++
kyle~16 小时前
时间同步 --- PTP 与 Scheduled Action Command
c++·数码相机·机器人·传感器