龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > 软件开发 > VC开发 >

VC中单文档框架删除菜单的调试经历(2)

时间:2009-12-30 15:42来源:未知 作者:admin 点击:
分享到:
下一步进入OnCreateClient,代码如下: BOOL CFrameWnd::OnCreateClient(LPCREATESTRUCT, CCreateContext* pContext) { // default create client will create a view if asked for it if (pContext != NU
 下一步进入OnCreateClient,代码如下:

BOOL CFrameWnd::OnCreateClient(LPCREATESTRUCT, CCreateContext* pContext)
{
    // default create client will create a view if asked for it
    if (pContext != NULL && pContext->m_pNewViewClass != NULL)
    {
        if (CreateView(pContext, AFX_IDW_PANE_FIRST) == NULL)
            return FALSE;
    }
    return TRUE;
}  进入CreateView,代码如下:CWnd* CFrameWnd::CreateView(CCreateContext* pContext, UINT nID)
{
    ASSERT(m_hWnd != NULL);
    ASSERT(::IsWindow(m_hWnd));
    ENSURE_ARG(pContext != NULL);
    ENSURE_ARG(pContext->m_pNewViewClass != NULL);

    // Note: can be a CWnd with PostNcDestroy self cleanup
    CWnd* pView = (CWnd*)pContext->m_pNewViewClass->CreateObject();
    if (pView == NULL)
    {
        TRACE(traceAppMsg, 0, "Warning: Dynamic create of view type %hs failed. ",
            pContext->m_pNewViewClass->m_lpszClassName);
        return NULL;
    }
    ASSERT_KINDOF(CWnd, pView);

    // views are always created with a border!
    if (!pView->Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
        CRect(0,0,0,0), this, nID, pContext))
    {
        TRACE(traceAppMsg, 0, "Warning: could not create view for frame. ");
        return NULL;        // can't continue without a view
    }

    if (pView->GetExStyle() & WS_EX_CLIENTEDGE)
    {
        // remove the 3d style from the frame, since the view is
        //  providing it.
        // make sure to recalc the non-client area
        ModifyStyleEx(WS_EX_CLIENTEDGE, 0, SWP_FRAMECHANGED);
    }
    return pView;
}  进入 if (!pView->Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,CRect(0,0,0,0), this, nID, pContext)),代码如下:BOOL CWnd::Create(LPCTSTR lpszClassName,
    LPCTSTR lpszWindowName, DWORD dwStyle,
    const RECT& rect,
    CWnd* pParentWnd, UINT nID,
    CCreateContext* pContext)
{
    // can't use for desktop or pop-up windows (use CreateEx instead)
    ASSERT(pParentWnd != NULL);
    ASSERT((dwStyle & WS_POPUP) == 0);

    return CreateEx(0, lpszClassName, lpszWindowName,
        dwStyle | WS_CHILD,
        rect.left, rect.top,
        rect.right - rect.left, rect.bottom - rect.top,
        pParentWnd->GetSafeHwnd(), (HMENU)(UINT_PTR)nID, (LPVOID)pContext);
}

精彩图集

赞助商链接