Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Exception while sizing splitter window

Posted on 2002-05-23
6
Medium Priority
?
268 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

604 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