我从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这个程序早时可以啊,不知怎么会出现这种情况
以下是重载的函数
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这个程序早时可以啊,不知怎么会出现这种情况
解决方案 »
- 列表框的自绘
- 如何得知系统需要关机,先完成我的任务后再继续操作???
- 谁有 c++ 2005入门经典 中文版 的啊
- 如何在on print( )函数中实现打印折线图
- 我很穷,可是老婆要5000旅游,怎么办?
- 附件-画图程序的窗口为何高度拉到一定的程度就拉不上去了?目的何在
- 大家都进来帮我看段程序啊!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- 如何自定义消息啊???能给些代码解释一下么?
- 人脸识别提取特征脸中的负数值如何处理?
- nafxcw.lib和uafxcw.lib的冲突 debug正确而release链接错误
- 如何隐藏Resizing风格的对话框的边框,又能使它能够鼠标拖动改变大小?
- Atl实现一个窗口的问题,不知道怎么定位,请高手看看
好奇怪
用AfxGetApp()->m_pMainWnd试试
CSampleclientDlg *m_pDlg=(CSampleclientDlg *)(AfxGetApp()->m_pMainWnd);
CSampleclientDlg *m_pDlg=(CSampleclientDlg *)AfxGetMainWnd(); //可以正常获得对话框句柄
m_pDlg->DealReceive(); 你不能把dlg声明称成员函数么