|
发表于 2020-3-20 14:58:00
|
显示全部楼层
在 WM_DISPLAY_COMDATA 消息的响应函数中用完了别忘记释放 pMsg!
- void DisplayState(HWND hWnd, CString Msg)
- {
- CTime CurTime = CTime::GetCurrentTime();;
- CString strTime = "";
- strTime.Format("%02d-%02d %02d:%02d:%02d: ", CurTime.GetMonth(), CurTime.GetDay(), CurTime.GetHour(), CurTime.GetMinute(), CurTime.GetSecond());
- Msg = strTime + Msg;
- UINT nMsgLen = Msg.GetLength();
- TCHAR* pMsg = new TCHAR[nMsgLen + 1];
- ZeroMemory(pMsg, (nMsgLen + 1) * sizeof(TCHAR));
- _tcscpy(pMsg, (LPCTSTR)Msg);
- SendMessage(hWnd, WM_DISPLAY_COMDATA, 0, (LPARAM)pMsg);
- }
复制代码
|
|