Solved

Exception while sizing splitter window

Posted on 2002-05-23
6
263 Views
Last Modified: 2013-11-20
I am creating horizondal splitter window like this.

     if(!m_wndSplitter.CreateStatic(this, 2, 1))
     {
          TRACE(_T("Failed to CreateStaticSplitter\n"));
          return FALSE;
     }
     
     if(!m_wndSplitter.CreateView(0, 0,
          RUNTIME_CLASS(CView1), CSize(0, 0), pContext))
     {
          TRACE(_T("Failed to create third pane\n"));
          return FALSE;
     }

     // CResultView must be the last in the creation process.
     // There can be only one CRichEditDoc per CRichEditView
     if(!m_wndSplitter.CreateView(1, 0,
          RUNTIME_CLASS(CView2), CSize(0, 0), pContext))
     {
          TRACE(_T("Failed to create first pane\n"));
          return FALSE;
     }
     return TRUE;
--
The following is the code in the onsize event
--
          CRect rect;
          GetClientRect(&rect);          
          int i = rect.Height();
          m_wndSplitter.SetRowInfo(0, rect.Height()/2, 0);
          CMDIChildWnd::OnSize(nType, cx, cy);    

An unhandled exception occurs in the SetRowInfo line. Please help
0
Comment
Question by:karthik1979
  • 3
  • 3
6 Comments
 
LVL 31

Expert Comment

by:Zoppo
ID: 7029192
Hi karthik1979,

a problem with OnSize is often that it is called during
creation of the frame window before everything else is
created completely.

You should somehow check if the creation of the splitter
and the view is completed, either by using a flag which
you set after the view is created or by use of ::IsWindow,
i.e.

if ( m_wndSplitter.m_hWnd != NULL && ::IsWindow( m_wndSplitter.m_hWnd )
{
 m_wndSplitter.SetRowInfo(...);
}

hope that helps,

ZOPPO
0
 

Author Comment

by:karthik1979
ID: 7031500
Not working :((
0
 
LVL 31

Accepted Solution

by:
Zoppo earned 50 total points
ID: 7031516
hmm ... maybe this handler even is called while creation
of the splitter before the row/cols are allocated.

Maybe best would be to use a flag like:

// add a flag to the CChildFrame header
...
   BOOL m_bInitialized;
...
// and set it to FALSE in CChildFrame::CChildFrame(...)

// then in OnCreate simply set it to TRUE after everything
// is ok
  if(!m_wndSplitter.CreateStatic(this, 2, 1))
    {
         TRACE(_T("Failed to CreateStaticSplitter\n"));
         return FALSE;
    }
     
    if(!m_wndSplitter.CreateView(0, 0,
         RUNTIME_CLASS(CView1), CSize(0, 0), pContext))
    {
         TRACE(_T("Failed to create third pane\n"));
         return FALSE;
    }

    // CResultView must be the last in the creation process.
    // There can be only one CRichEditDoc per CRichEditView
    if(!m_wndSplitter.CreateView(1, 0,
         RUNTIME_CLASS(CView2), CSize(0, 0), pContext))
    {
         TRACE(_T("Failed to create first pane\n"));
         return FALSE;
    }

// here!!!
    m_bInitialized = TRUE;

    return TRUE;

// and in OnSize something like:

if ( m_bInitialized )
{
 CRect rect;
 GetClientRect(&rect);          
 int i = rect.Height();
 m_wndSplitter.SetRowInfo(0, rect.Height()/2, 0);
}
CMDIChildWnd::OnSize(nType, cx, cy);    


hope that helps,

ZOPPO
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:karthik1979
ID: 7034166
Cool! That worked. Thanks.
0
 

Author Comment

by:karthik1979
ID: 7034168
Thats cool!
0
 
LVL 31

Expert Comment

by:Zoppo
ID: 7036591
You're welcome.

have a nice day,

regards,

ZOPPO
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question