?
Solved

Exception while sizing splitter window

Posted on 2002-05-23
6
Medium Priority
?
267 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 200 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

Question has a verified solution.

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

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses

762 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