完全参考:https://blog.csdn.net/xsckernel/article/details/51438442#setpanetext-的崩溃问题

分别打开主控和小马的IOCPServer.cpp,搜索chOpt,修改至

unsigned long chOpt;
     *((char *)&chOpt)   = 1;

打开主控端MainFrm.cpp,搜索NotifyProc,替换成

void CALLBACK CMainFrame::NotifyProc(LPVOID lpParam, ClientContext *pContext, UINT nCode)
{
    //减少无效消息
    if (pContext == NULL || pContext->m_DeCompressionBuffer.GetBufferLen() <= 0)
        return;
    
    CMainFrame* pFrame = (CMainFrame*)lpParam;
    pFrame->PostMessage(WM_UPDATE_MAINFRAME, (WPARAM)nCode, (LPARAM)pContext);
    //CJlib库不能在工作线程操作UI
    return;
    
    
    try
	{
		CMainFrame* pFrame = (CMainFrame*) lpParam;
		CString str;
		// 对g_pConnectView 进行初始化
		g_pConnectView = (CGh0stView *)((CGh0stApp *)AfxGetApp())->m_pConnectView;

		// g_pConnectView还没创建,这情况不会发生
		if (((CGh0stApp *)AfxGetApp())->m_pConnectView == NULL)
			return;

		g_pConnectView->m_iocpServer = m_iocpServer;
		str.Format(_T("发送: %.2f kb/s 接收: %.2f kb/s"), (float)m_iocpServer->m_nSendKbps / 1024, (float)m_iocpServer->m_nRecvKbps / 1024);
        //g_pFrame->m_wndStatusBar.SetPaneText(1, str);


		switch (nCode)
		{
		case NC_CLIENT_CONNECT:
			break;
		case NC_CLIENT_DISCONNECT:
			g_pConnectView->PostMessage(WM_REMOVEFROMLIST, 0, (LPARAM)pContext);
			break;
		case NC_TRANSMIT:
			break;
		case NC_RECEIVE:
			ProcessReceive(pContext);
			break;
		case NC_RECEIVE_COMPLETE:
			ProcessReceiveComplete(pContext);
			break;
		}
	}catch(...){}
}

//added by zhangyl
LRESULT CMainFrame::NotifyProc2(WPARAM wParam, LPARAM lParam)
{
    ClientContext* pContext = (ClientContext *)lParam;
    UINT nCode = (UINT)wParam;

    try
    {
        //CMainFrame* pFrame = (CMainFrame*)lpParam;
        CString str;
        // 对g_pConnectView 进行初始化
        g_pConnectView = (CGh0stView *)((CGh0stApp *)AfxGetApp())->m_pConnectView;

        // g_pConnectView还没创建,这情况不会发生
        if (((CGh0stApp *)AfxGetApp())->m_pConnectView == NULL)
            return 0;

        g_pConnectView->m_iocpServer = m_iocpServer;
        str.Format(_T("发送: %.2f kb/s 接收: %.2f kb/s"), (float)m_iocpServer->m_nSendKbps / 1024, (float)m_iocpServer->m_nRecvKbps / 1024);
        m_wndStatusBar.SetPaneText(1, str);


        switch (nCode)
        {
        case NC_CLIENT_CONNECT:
            break;
        case NC_CLIENT_DISCONNECT:
            g_pConnectView->PostMessage(WM_REMOVEFROMLIST, 0, (LPARAM)pContext);
            break;
        case NC_TRANSMIT:
            break;
        case NC_RECEIVE:
            ProcessReceive(pContext);
            break;
        case NC_RECEIVE_COMPLETE:
            ProcessReceiveComplete(pContext);
            break;
        }
    }
    catch (...){}

    return 1;
}
LRESULT CMainFrame::OnWorkThreadMsg(WPARAM wParam, LPARAM lParam)
{
    NotifyProc(this, (ClientContext *)lParam, (UINT)wParam);
	
    return 0;
}

在41行添加

ON_MESSAGE(WM_WORKTHREAD_MSG, OnWorkThreadMsg)                 //工作线程消息
ON_MESSAGE(WM_UPDATE_MAINFRAME, NotifyProc2)                 //工作线程消息

打开MainFrm.h,在79行添加

    afx_msg LRESULT OnWorkThreadMsg(WPARAM wParam, LPARAM lParam);
    afx_msg LRESULT NotifyProc2(WPARAM wParam, LPARAM lParam);

在14行添加

#define WM_WORKTHREAD_MSG   WM_USER + 0x0001
#define WM_UPDATE_MAINFRAME WM_USER + 0x0002

说点什么
支持Markdown语法
在"枭关初恋1.7修复(上)"已有1条评论
Loading...