/
// .h
/
#define MY_LOG_MSG (WM_USER+1001)
#define MY_ENABLE_BATCHSEND (WM_USER+1002)
#define MY_SEND_DATA (WM_USER+1003)
extern void Callback_ConnectionChanged(enet::conn_ptr cp, bool ok);
/
// .cpp
/
Cenet_testDlg *g_pMainWnd = 0;
/
/
void Callback_ConnectionChanged(enet::conn_ptr cp, bool ok)
//void Callback_ConnectionChanged(const string &id, bool ok)
{
g_pMainWnd->AddLog(boost::str(boost::format("%s is %S") % cp->id() % (ok ? "connected" : "left")));
}
/
/
ON_MESSAGE(MY_LOG_MSG, OnLog)
ON_MESSAGE(MY_ENABLE_BATCHSEND, OnSetBatchBtn)
ON_MESSAGE(MY_SEND_DATA, OnSendData)
/
/
void Cenet_testDlg::AddLog(const string &log)
{
CString *pStr = new CString(log.c_str());
PostMessage(MY_LOG_MSG, (WPARAM)pStr, 0);
}
/
/
LRESULT Cenet_testDlg::OnLog(WPARAM wParam, LPARAM lParam)
{
CString *pStr = (CString*)wParam;
m_lstLog.InsertString(0, pStr->GetBuffer());
delete pStr;
return 0;
}
asio-MFC integration
最新推荐文章于 2022-11-08 18:02:19 发布