Ask: Problems in debugging

xiaoxiao2021-03-06  57

The problem is as follows:

Class Cuserframe: public cmdichildwnd

The call function is as follows, and the implementation function can only generate a sub-frame and a view:

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 {buser manufacture-> sendMessage (wm_setfocus);}}

After the program is running, as long as the onuseragement (), the tracker appears:

Warnning: No Shared Menu / Acceltable for MDI CHILD WINDOW.

After tracking, the problem is that the following functions (red part) in 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;}

How can this be?

转载请注明原文地址:https://www.9cbs.com/read-118646.html

New Post(0)