感谢您使用微软产品。您所描述的问题可能是由于您在CWinApp中调用GetPaneView()的位置不对,如果调用GetPaneView()时,主窗体尚未创建,即OnCreateClient()函数尚未执行,您就不能得到View的指针。
OnCreateClient()函数是在CMainFrame::OnCreate()函数中调用的,该OnCreate()函数由CWinApp::InitInstance()中的ProcessShellCommand()激活,请确定您在调用CMainFrame::GetPaneView()之前已经执行了ProcessShellCommand()。如仍有问题,请具体说明调用CMainFrame::GetPaneView()的位置或给出相关代码。关于OnCreateClient()与ProcessShellCommand()的详细功能与调用关系,请参考
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcemfc/htm/cframwnd_24.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcemfc/htm/cwinapp_29.asp- 微软全球技术中心 VC技术支持本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利。具体事项可参见使用条款(http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。为了为您创建更好的讨论环境,请参加我们的用户满意度调查(http://support.microsoft.com/directory/worldwide/zh-cn/community/survey.asp?key=(S,49854782))。
OnCreateClient()函数是在CMainFrame::OnCreate()函数中调用的,该OnCreate()函数由CWinApp::InitInstance()中的ProcessShellCommand()激活,请确定您在调用CMainFrame::GetPaneView()之前已经执行了ProcessShellCommand()。如仍有问题,请具体说明调用CMainFrame::GetPaneView()的位置或给出相关代码。关于OnCreateClient()与ProcessShellCommand()的详细功能与调用关系,请参考
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcemfc/htm/cframwnd_24.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcemfc/htm/cwinapp_29.asp- 微软全球技术中心 VC技术支持本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利。具体事项可参见使用条款(http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。为了为您创建更好的讨论环境,请参加我们的用户满意度调查(http://support.microsoft.com/directory/worldwide/zh-cn/community/survey.asp?key=(S,49854782))。
主窗体是肯定已经创建了
void CFiveGameApp::AddOnlineUser(CData* pData)
{
CMainFrame* pMainWnd=(CMainFrame *) GetMainWnd(); COnlineList* pOnline =(COnlineList *) pMainWnd->GetPaneView(0,0); CUserOnline pUserOnline;
CopyDataBuf(&pUserOnline,pData);
pUserOnline.GetFromBuf();
UserOnline user;
user.Name = pUserOnline.username;
CString tempID;
tempID.Format("%d",pUserOnline.MyId);
user.ID = tempID;
for(int i=0; i<=pUser.GetUpperBound(); i++)
{
if(strcmp(pUser.GetAt(i).ID, user.ID)==0)
return;
else
continue;
}
pUser.Add(user);
pOnline->RefreshView();
}