欢迎访问:常州市武进区嘉泽中心小学网站 !今天是:
栏目列表
您现在的位置是:首页>>教师>>计算机技术>>程序设计>>杂项>>文章内容
请教:调试时出现的问题
发布时间:2008-11-20   点击:   来源:本站原创   录入者:佚名
 

问题类如下:

class CUserFrame : public CMDIChildWnd

调用函数如下,实现功能是只能生成一个子框架和视图:

void CDatamartApp::OnUserManagement()
{
 extern CUserFrame * bUserManagement;
 if(!bUserManagement)
 {
  CMainFrame* pFrame = STATIC_DOWNCAST(CMainFrame, m_pMainWnd);
  bUserManagement=(CUserFrame *)pFrame->CreateNewChild(RUNTIME_CLASS(CUserFrame), IDR_MAINFRAME, m_hMDIMenu, m_hMDIAccel);
 }
 else
 {
  bUserManagement->SendMessage(WM_SETFOCUS);
 }
   
}

程序运行后,只要调用OnUserManagement(),跟踪器就出现:

Warnning:  no shared menu/acceltable for MDI Child window.

经过追踪,发现问题是winmdi.cpp中以下函数(红色部分)导致的:

BOOL CMDIChildWnd::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle,
  CWnd* pParentWnd, CCreateContext* pContext)
{
 // only do this once
 ASSERT_VALID_IDR(nIDResource);
 ASSERT(m_nIDHelp == 0 || m_nIDHelp == nIDResource);

 m_nIDHelp = nIDResource;    // ID for help context (+HID_BASE_RESOURCE)

 // parent must be MDI Frame (or NULL for default)
 ASSERT(pParentWnd == NULL || pParentWnd->IsKindOf(RUNTIME_CLASS(CMDIFrameWnd)));
 // will be a child of MDIClient
 ASSERT(!(dwDefaultStyle & WS_POPUP));
 dwDefaultStyle |= WS_CHILD;

 // if available - get MDI child menus from doc template
 CMultiDocTemplate* pTemplate;
 if (pContext != NULL &&
  (pTemplate = (CMultiDocTemplate*)pContext->m_pNewDocTemplate) != NULL)
 {
  ASSERT_KINDOF(CMultiDocTemplate, pTemplate);
  // get shared menu from doc template
  m_hMenuShared = pTemplate->m_hMenuShared;
  m_hAccelTable = pTemplate->m_hAccelTable;
 }
 else
 {
  TRACE(traceAppMsg, 0, "Warning: no shared menu/acceltable for MDI Child window.\n");
   // if this happens, programmer must load these manually
 }

 CString strFullString, strTitle;
 if (strFullString.LoadString(nIDResource))
  AfxExtractSubString(strTitle, strFullString, 0);    // first sub-string

 ASSERT(m_hWnd == NULL);
 if (!Create(GetIconWndClass(dwDefaultStyle, nIDResource),
   strTitle, dwDefaultStyle, rectDefault,
   (CMDIFrameWnd*)pParentWnd, pContext))
 {
  return FALSE;   // will self destruct on failure normally
 }

 // it worked !
 return TRUE;
}

请问怎么会这样?


附件:
    关闭窗口
    打印文档
    账号登录
    保持登录 忘记密码?
    账号与武进教师培训平台同步