GIDForums  

Go Back   GIDForums > Computer Programming Forums > MS Visual C++ / MFC Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 03-Apr-2006, 16:08
adnanshafique adnanshafique is offline
New Member
 
Join Date: Apr 2006
Posts: 1
adnanshafique is on a distinguished road
Exclamation

Unhandle Exception in CSplitterWnd


Hi,

I need some help in MFC splitter windows. I create an user interface (GUI) which is look like new outloook application. I create a splitter window which have 3 panes, like the shape below.

+-----+-------------+
| | |
| | |
| 1 | 2 |
| | |
+-----| |
| 3 | |
+-----+-------------+


I place some buttons on pane 3 and when i click on button i switch views of pane 1 and pane 2 to some different views. Below is the code that i place in different modules of application:

CPP / C++ / C Code:
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
    // SIZE OF CLIENT AREA
    CRect clientRect;
    GetClientRect(&clientRect);    
    int Col1Width = clientRect.Width()/4;
    int Col2Width = clientRect.Width() - Col1Width;
    /*===========================================
    SPLIT CLIENT AREA INTO 2 SEPARATE COLUMNS
    ============================================*/
    VERIFY (
        m_wndSpltForCols.CreateStatic (
            this, 
            1,        // NUMBER OF ROWS
            2        // NUMBER OF COLUMNS
        )
    );
    /*=======================================
        VIEW FOR 2ND COLUMN 
    ========================================*/
    VERIFY (    
        m_wndSpltForCols.CreateView (0,    // ROW POSITION
        1,                // COLUMN POSITION            
        RUNTIME_CLASS(CSplitFrame),    // VIEW CLASS FOR PANE
        CSize(Col2Width, clientRect.Height()),    // SIZE OF PANE 
        pContext                //
        )
    );
    /*=======================================
    SPLITTING 1ST COLUMNS INTO 2 COLUMNS
    ========================================*/
    VERIFY (
        m_wndSpltForRows.CreateStatic (
            &m_wndSpltForCols,            // PARENT OBJECT 
            2,                    // NUMBER OF ROWS
            1,                    // NUMBER OF COLUMNS
            WS_CHILD|WS_VISIBLE,            // STYLES
            m_wndSpltForCols.IdFromRowCol(0,0)    // WHICH COLUMN IS TO BE SPLITTED
        )
    );
    /*=======================================
    VIEW FOR FIRST ROW - CONTAINS CTreeCtrl 
    ========================================*/
    VERIFY     (
        m_wndSpltForRows.CreateView (
            0,
            0,             
            RUNTIME_CLASS(CNavOptionsView),
            CSize(10,10), 
            pContext
        )
    );
    /*=============================================
    VIEW FOR SECOND ROW - MAIN NAVIGATION BUTTONS
    ===============================================*/
    VERIFY (
        m_wndSpltForRows.CreateView (
            1,
            0,             
            RUNTIME_CLASS(CNavigateView),
            CSize(10,10), 
            pContext
        )
    );        
    m_wndSpltForCols.RecalcLayout();
    //SPLITTER WINDOW INITIALIZATION FLAG
    m_isWndSpltsInitialize = true;
    return true;    
}
 
 
The actual problem that i face in below function....By logic i think it fails but below function works 100% when i run application in Debug mode but when i run it in Release mode...application popups an Unhandle Exception.
 
 
bool CSagsDoc::SwitchToView(CView* pOldViewClass, CRuntimeClass* pNewViewClass)
{    
 
    if (pOldViewClass->IsKindOf(pNewViewClass)) return TRUE;
 
    CFrameWnd* pMainWnd = (CFrameWnd*)AfxGetMainWnd();    
 
    CEnhSplitterWnd* pSplitter = (CEnhSplitterWnd *)pOldViewClass->GetParent();
 
    int row = 0, col= 0;
    ASSERT(pSplitter->IsChildPane(pOldViewClass, &row, &col));
 
    CRect viewrect;
    pOldViewClass->GetWindowRect(&viewrect);
 
    // DELETEING PANE VIEW
    m_bAutoDelete = FALSE;                
    pOldViewClass->DestroyWindow();        
    m_bAutoDelete = TRUE;                
 
 
    CCreateContext context;
    context.m_pNewViewClass        = pNewViewClass;
    context.m_pCurrentDoc        = this;
 
    if (!pSplitter->CreateView(row, col, pNewViewClass, viewrect.Size(),&context))
        return false;    
 
    // Set active
    CView* pNewView = (CView *)pSplitter->GetPane(row, col);
    if (pNewView)
    {
        pNewView->GetParentFrame()->RecalcLayout();
    }
 
    // EXCEPTION In Release Version
    if (pSplitter)
    {
        pSplitter->GetParentFrame()->SetActiveView(pNewView);    /** EXCEPTION OCCUR HERE **/        
        pSplitter->SetActivePane(row, col);
        pSplitter->RecalcLayout();        
 
    }    
 
    pNewView->OnInitialUpdate();
    pNewView->SendMessage(WM_PAINT);
    pNewView->SendMessage(WM_SIZE);    
    return true;
}


and last i am new in MFC world and feel lot of confusion and conflicts about MFC i spend more then 6 months in MFC but i still not satisfied with my MFC skills. if someone knows best MFC or any other related book please refer to me.

thanks
Adnan
Last edited by LuciWiz : 04-Apr-2006 at 02:07. Reason: Please insert your C++ code between [c++] & [/c++] tags
 
 

Recent GIDBlogToyota - 2009 May Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Opinion on my code and a c++ class question FlipNode C++ Forum 7 07-Feb-2006 09:15
Unable to catch exception in native code QED C++ Forum 1 25-Jan-2006 14:12
C++ Copy Constructor & Exception issues greymalkin C++ Forum 3 05-Oct-2005 22:36
begginer::problems with exception if13121 C++ Forum 0 04-Mar-2005 05:40
Floating point exception error (Note-long post) crystalattice C++ Forum 16 11-Sep-2004 08:37

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 04:26.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.