Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Bug in CXTSplitterWnd
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Bug in CXTSplitterWnd

 Post Reply Post Reply
Author
Message
SunMarc View Drop Down
Newbie
Newbie
Avatar

Joined: 19 October 2006
Location: France
Status: Offline
Points: 13
Post Options Post Options   Thanks (0) Thanks(0)   Quote SunMarc Quote  Post ReplyReply Direct Link To This Post Topic: Bug in CXTSplitterWnd
    Posted: 02 November 2006 at 5:25am
Hello,


I was using a CXTSplitterWnd in my App with
the XTP 9.7 and all worked fine.
I'm now using the 1030 and my App crashes if:

I hide the 1st row
I hide the 1st column
I show the 1st row
I show the 1st column => Assert in :

BOOL CWnd::ShowWindow(int nCmdShow)
{
    ASSERT(::IsWindow(m_hWnd) || (m_pCtrlSite != NULL));

    if (m_pCtrlSite == NULL)
        return ::ShowWindow(m_hWnd, nCmdShow);
    else
        return m_pCtrlSite->ShowWindow(nCmdShow);
}


I tried with the SplitterWindow sample and I get the same pb!!


The code has been modified in the CXTSplitterWnd::ShowRow()
method since the 9.7 version...  any idea?

Thanks.





Back to Top
SunMarc View Drop Down
Newbie
Newbie
Avatar

Joined: 19 October 2006
Location: France
Status: Offline
Points: 13
Post Options Post Options   Thanks (0) Thanks(0)   Quote SunMarc Quote  Post ReplyReply Direct Link To This Post Posted: 02 November 2006 at 5:42am
I tried to replace the CXTSplitterWnd::ShowRow() and CXTSplitterWnd::HideRow() methods in the XTP 1030
with the same methods in the XTP 9.7.
I recompiled XTP 1030 project and the pb is fixed...


If it can help, here is the 1030 and 9.7 code for these methods:

1030 :
====

void CXTSplitterWnd::ShowRow()
{
    ASSERT_VALID(this);
    if (m_nRows == m_nMaxRows && m_nHiddenRow == -1)
    {
        return;
    }
    ASSERT(m_nHiddenRow != -1);

    int nShowRow = m_nHiddenRow;
    m_nHiddenRow = -1;

    int cyNew = m_pRowInfo[m_nRows].nCurSize;
    m_nRows++;  // add a nRow

    ASSERT(m_nRows == m_nMaxRows);

    int nRow;

    // Show the hidden nRow
    int nCol;
    for (nCol = 0; nCol < m_nCols; ++nCol)
    {
        CWnd* pPaneShow = GetDlgItem(AFX_IDW_PANE_FIRST + m_nRows * 16 + nCol);
        ASSERT(pPaneShow != NULL);
        pPaneShow->ShowWindow(SW_SHOWNA);

        for (nRow = m_nRows - 2; nRow >= nShowRow; --nRow)
        {
            CWnd* pPane = GetPane(nRow, nCol);
            ASSERT(pPane != NULL);
            pPane->SetDlgCtrlID(IdFromRowCol(nRow + 1, nCol));
        }

        pPaneShow->SetDlgCtrlID(IdFromRowCol(nShowRow, nCol));
    }

    // new panes have been created -- recalculate layout
    for (nRow = nShowRow + 1; nRow < m_nRows; nRow++)
        m_pRowInfo[nRow].nIdealSize = m_pRowInfo[nRow - 1].nCurSize;

    m_pRowInfo[nShowRow].nIdealSize = cyNew;
    RecalcLayout();
}

void CXTSplitterWnd::HideRow(int nRowHide)
{
    ASSERT_VALID(this);
    if (m_nHiddenRow != -1)
    {
        // return if the requested one is hidden
        if (m_nHiddenRow == nRowHide)
        {
            return;
        }
        ShowRow();
    }
    ASSERT(m_nRows > 1);
    ASSERT(nRowHide < m_nRows);
    ASSERT(m_nHiddenRow == -1);
    m_nHiddenRow = nRowHide;

    int nActiveRow, nActiveCol;

    // if the nRow has an active window -- change it
    if (GetActivePane(&nActiveRow, &nActiveCol) != NULL)
    {
        if (nActiveRow == nRowHide)
        {
            if (++nActiveRow >= m_nRows)
                nActiveRow = 0;
            SetActivePane(nActiveRow, nActiveCol);
        }
    }

    // hide all nRow panes.
    int nCol;
    for (nCol = 0; nCol < m_nCols; ++nCol)
    {
        CWnd* pPaneHide = GetPane(nRowHide, nCol);
        ASSERT(pPaneHide != NULL);

        pPaneHide->ShowWindow(SW_HIDE);
        pPaneHide->SetDlgCtrlID(AFX_IDW_PANE_FIRST + m_nRows * 16 + nCol);

        int nRow;
        for (nRow = nRowHide + 1; nRow < m_nRows; ++nRow)
        {
            CWnd* pPane = GetPane(nRow, nCol);
            ASSERT(pPane != NULL);

            pPane->SetDlgCtrlID(IdFromRowCol(nRow-1, nCol));
        }
    }

    m_nRows--;
    m_pRowInfo[m_nRows].nCurSize = m_pRowInfo[nRowHide].nCurSize;
    RecalcLayout();
}


9.7 :
===

void CXTSplitterWnd::ShowRow()
{
    ASSERT_VALID( this );
    if ( m_nRows == m_nMaxRows && m_nHiddenRow == -1)
    {
        return;
    }
    ASSERT( m_nHiddenRow != -1 );

    int nShowRow = m_nHiddenRow;
    m_nHiddenRow = -1;

    int cyNew = m_pRowInfo[m_nRows].nCurSize;
    m_nRows++;  // add a nRow

    ASSERT( m_nRows == m_nMaxRows );

    int nRow;

    // Show the hidden nRow
    int nCol;
    for ( nCol = 0; nCol < m_nCols; ++nCol )
    {
        CWnd* pPaneShow = GetDlgItem( AFX_IDW_PANE_FIRST + nCol * 16 + m_nRows );
        ASSERT( pPaneShow != NULL );
        pPaneShow->ShowWindow( SW_SHOWNA );

        for ( nRow = m_nRows - 2; nRow >= nShowRow; --nRow )
        {
            CWnd* pPane = GetPane( nRow, nCol );
            ASSERT( pPane != NULL );
            pPane->SetDlgCtrlID( IdFromRowCol( nRow + 1, nCol ));
        }

        pPaneShow->SetDlgCtrlID( IdFromRowCol( nShowRow, nCol ));
    }

    // new panes have been created -- recalculate layout
    for ( nRow = nShowRow+1; nRow < m_nRows; nRow++ )
        m_pRowInfo[nRow].nIdealSize = m_pRowInfo[nRow - 1].nCurSize;

    m_pRowInfo[nShowRow].nIdealSize = cyNew;
    RecalcLayout();
}

void CXTSplitterWnd::HideRow(int nRowHide)
{
    ASSERT_VALID( this );
    if (m_nHiddenRow != -1)
    {
        // return if the requested one is hidden
        if (m_nHiddenRow == nRowHide)
        {
            return;
        }
        ShowRow();
    }
    ASSERT( m_nRows > 1 );
    ASSERT( nRowHide < m_nRows );
    ASSERT( m_nHiddenRow == -1 );
    m_nHiddenRow = nRowHide;

    int nActiveRow, nActiveCol;

    // if the nRow has an active window -- change it
    if( GetActivePane( &nActiveRow, &nActiveCol ) != NULL )
    {
        if( nActiveRow == nRowHide )
        {
            if( ++nActiveRow >= m_nRows )
                nActiveRow = 0;
            SetActivePane( nActiveRow, nActiveCol );
        }
    }

    // hide all nRow panes.
    int nCol;
    for ( nCol = 0; nCol < m_nCols; ++nCol )
    {
        CWnd* pPaneHide = GetPane( nRowHide, nCol );
        ASSERT( pPaneHide != NULL );

        pPaneHide->ShowWindow( SW_HIDE );
        pPaneHide->SetDlgCtrlID( AFX_IDW_PANE_FIRST + nCol * 16 + m_nRows );

        int nRow;
        for ( nRow = nRowHide+1; nRow < m_nRows; ++nRow )
        {
            CWnd* pPane = GetPane( nRow, nCol );
            ASSERT( pPane != NULL );

            pPane->SetDlgCtrlID( IdFromRowCol( nRow-1, nCol ));
        }
    }

    m_nRows--;
    m_pRowInfo[m_nRows].nCurSize = m_pRowInfo[nRowHide].nCurSize;
    RecalcLayout();
}




Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.063 seconds.