ActiveX и View - возможно ли такое?
От: DrMom  
Дата: 13.10.03 07:04
Оценка:
Я пытаюсь создавать на основе класса CView активыксовый контрол. Делаю это так:


BOOL CInclViewView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext) 
{
    return CWnd::CreateControl(CLSID_XXX, lpszWindowName, dwStyle, rect, pParentWnd, nID);
}

Все вроде здесь проходит правильно, но вот здесь:


BOOL CSplitterWnd::CreateView(int row, int col,
    CRuntimeClass* pViewClass, SIZE sizeInit, CCreateContext* pContext)
{
#ifdef _DEBUG
    ASSERT_VALID(this);
    ASSERT(row >= 0 && row < m_nRows);
    ASSERT(col >= 0 && col < m_nCols);
    ASSERT(pViewClass != NULL);
    ASSERT(pViewClass->IsDerivedFrom(RUNTIME_CLASS(CWnd)));
    ASSERT(AfxIsValidAddress(pViewClass, sizeof(CRuntimeClass), FALSE));

    if (GetDlgItem(IdFromRowCol(row, col)) != NULL)
    {
        TRACE2("Error: CreateView - pane already exists for row %d, col %d.\n",
            row, col);
        ASSERT(FALSE);
        return FALSE;
    }
#endif

    // set the initial size for that pane
    m_pColInfo[col].nIdealSize = sizeInit.cx;
    m_pRowInfo[row].nIdealSize = sizeInit.cy;

    BOOL bSendInitialUpdate = FALSE;

    CCreateContext contextT;
    if (pContext == NULL)
    {
        // if no context specified, generate one from the currently selected
        //  client if possible
        CView* pOldView = (CView*)GetActivePane();
        if (pOldView != NULL && pOldView->IsKindOf(RUNTIME_CLASS(CView)))
        {
            // set info about last pane
            ASSERT(contextT.m_pCurrentFrame == NULL);
            contextT.m_pLastView = pOldView;
            contextT.m_pCurrentDoc = pOldView->GetDocument();
            if (contextT.m_pCurrentDoc != NULL)
                contextT.m_pNewDocTemplate =
                  contextT.m_pCurrentDoc->GetDocTemplate();
        }
        pContext = &contextT;
        bSendInitialUpdate = TRUE;
    }

    CWnd* pWnd;
    TRY
    {
        pWnd = (CWnd*)pViewClass->CreateObject();
        if (pWnd == NULL)
            AfxThrowMemoryException();
    }
    CATCH_ALL(e)
    {
        TRACE0("Out of memory creating a splitter pane.\n");
        // Note: DELETE_EXCEPTION(e) not required
        return FALSE;
    }
    END_CATCH_ALL

    ASSERT_KINDOF(CWnd, pWnd);
    ASSERT(pWnd->m_hWnd == NULL);       // not yet created

    DWORD dwStyle = AFX_WS_DEFAULT_VIEW;
    if (afxData.bWin4)
        dwStyle &= ~WS_BORDER;

    // Create with the right size (wrong position)
    CRect rect(CPoint(0,0), sizeInit);
    if (!pWnd->Create(NULL, NULL, dwStyle,
        rect, this, IdFromRowCol(row, col), pContext))
    {
        TRACE0("Warning: couldn't create client pane for splitter.\n");
            // pWnd will be cleaned up by PostNcDestroy
        return FALSE;
    }
    ASSERT((int)_AfxGetDlgCtrlID(pWnd->m_hWnd) == IdFromRowCol(row, col));

    // send initial notification message
    if (bSendInitialUpdate)
        pWnd->SendMessage(WM_INITIALUPDATE);

    return TRUE;
}


происходит асерт. Что это за ф-ция _AfxGetDlgCtrlID и с чем ее едят? И ваще почему все не работает? Может это просто не может работать?
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.