我从CSocket只能派生类CMySocket
以下是重载的函数
void CMySocket::OnReceive(int nErrorCode) 
{
// TODO: Add your specialized code here and/or call the base class
CSampleclientDlg *m_pDlg=(CSampleclientDlg *)AfxGetMainWnd();   //可以正常获得对话框句柄
m_pDlg->DealReceive();

CSocket::OnReceive(nErrorCode);
}void CMySocket::OnClose(int nErrorCode) 
{
// TODO: Add your specialized code here and/or call the base class
CSampleclientDlg *m_pDlg=(CSampleclientDlg *)AfxGetMainWnd();     //获得的对话框句柄是0;
m_pDlg->GetDlgItem(IDC_CONNECTSERVER)->EnableWindow(FALSE);      //程序自动关闭
AfxMessageBox("连接中断");
CSocket::OnClose(nErrorCode);
}
我的程序主窗口是对话框为基础的,IDC_CONNECTSERVER是按钮ID这个程序早时可以啊,不知怎么会出现这种情况