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

相关推荐
休息一下接着来15 分钟前
C++ 固定容量环形队列实现
c++·算法
wxin_VXbishe2 小时前
springboot新能源车充电站管理系统小程序-计算机毕业设计源码29213
java·c++·spring boot·python·spring·django·php
05候补工程师3 小时前
【408 从零到一】线性表逻辑特征、存储结构对比与 C/C++ 动态内存分配避坑指南
c语言·开发语言·数据结构·c++·考研
怕什么真理无穷3 小时前
C++面试5_ TCP 粘包2(工业级)
开发语言·c++·tcp/ip
努力努力再努力wz4 小时前
【MySQL 进阶系列】拒绝滥用root:从 mysql.user 到权限校验,带你彻底理解用户管理与授权机制!
android·c语言·开发语言·数据结构·数据库·c++·mysql
雪度娃娃4 小时前
基于TCP的网络词典
网络·c++·tcp/ip·c#
春蕾夏荷_7282977254 小时前
2、c++ acl tcp服务器客户端简单实例-服务器端(1)
服务器·c++·tcp/ip
墨染千千秋4 小时前
C++if判断的使用全解
c++
雪度娃娃5 小时前
设计模式——单例模式
开发语言·c++·设计模式
Lenyiin5 小时前
《LeetCode 顺序刷题》61 - 70
java·c++·python·算法·leetcode·lenyiin