![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
MFC
花一样的阿衰
不思进取的底层码农
展开
-
win线程互斥
使用WaitForSingleObject实现,线程1和线程2之间互斥,仅能运行一个线程。如下代码在VS2019 MFC下运行,static BOOL g_NeedCacncel = FALSE;HANDLE g_Mutex = NULL;// OnInitDialog中调用initvoid CWinThreadTestDlg::init() { g_Mutex = CreateMutex(NULL, false, NULL);}// close时候调用uninitvoid CWinTh原创 2022-05-18 17:00:37 · 176 阅读 · 1 评论 -
实现CString不定参Log输出函数
函数实现void LogMsg(CString pstrFormat, ...){ CString sFormat = pstrFormat; if (sFormat.Right(1) != _T("\n")) { sFormat += _T("\n"); } TCHAR szBuffer[2048] = { 0 }; va_list argList; va_start(argList, pstrFormat); int iRet = _vstprintf(szBuffer, sFor原创 2021-04-29 14:36:06 · 112 阅读 · 0 评论 -
Visual Studio pre-build/post-build修改文件内容
目的是在编译前时候需要将vendor_custom.h中的内容进行修改,在编译完成后再将vendor_custom.h恢复为修改前的。vendor_custom.h文件原内容如下#define VENDOR_SUPPORT_PAYMENT 1#define VENDOR_AUTHTOKEN_HMAC 1需要修改为#define VENDOR_SUPPORT_PAYMENT 0#define VENDOR_AUTHTOKEN_HMAC 0步骤 1:VS中增加pre-build/post-bu原创 2021-03-24 11:45:02 · 1109 阅读 · 0 评论 -
MFC中将Cstring转化为char *
void Cstring2Char(CString src, char* dst){ DWORD dwMinSize; dwMinSize = WideCharToMultiByte(CP_ACP, NULL, src, -1, NULL, 0, NULL, FALSE); char * pp = new char[dwMinSize]; WideCharToMultiByte(CP_O...原创 2020-03-19 10:14:37 · 846 阅读 · 0 评论 -
MFC多控件使用一个处理函数
三个按钮控件IDC_BUTTON_0、IDC_BUTTON_1、IDC_BUTTON_2的处理函数都是OnBnClickedButtonFunc。BEGIN_MESSAGE_MAP(CCalculatorDlg, CDialog) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() //}}AFX_MSG_MAP ON_BN_C...原创 2020-03-17 16:55:10 · 542 阅读 · 0 评论