生成时间戳字符串
SYSTEMTIME st;
CString strDate, strTime;
GetLocalTime(&st);
strDate.Format("%4d%2d%2d%.2d%2d%.2d", st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);
//时间戳
CString filename;
filename.Format("%s", strDate);
调用文件窗口,获取文件路径
CFileDialog file(true, _T(".xml"), NULL, OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, _T("xml file (*.xml)|*.xml||"), this);
if (file.DoModal() != IDOK) return; CString m_path = file.GetPathName();
char* filepath = (LPSTR)(LPCTSTR)m_path;//cstring转char*
临界区上锁、线程间通讯通过全局变量
定义全局变量 CCriticalSection critical_section;
critical_section.Lock();
int g_threadStatus = 1; //全局变量,通过外部循环不断访问 同步方式
critical_section.Unlock();
关闭窗口 、mfc自定义消息待添加。
SendMessage(WM_CLOSE);
ChangPassWordDlg *dlg;
dlg = new ChangPassWordDlg(this);
dlg->DoModal(); //模态
mfc 简单创建线程 简单明了、很直白
https://blog.csdn.net/qq_32716885/article/details/79721972
mfc 重写键盘 enter
BOOL CDoorToolDlg::PreTranslateMessage(MSG * pMsg)
{
//判断是否为键盘消息
if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_ESCAPE)
return TRUE;
//判断是否按下键盘Enter键
if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN)
{
OnBnClickedBtconnect();
return TRUE;
}
return CDialog::PreTranslateMessage(pMsg);
}