Solved

Exception while sizing splitter window

Posted on 2002-05-23
6
253 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 30

Expert Comment

by:Zoppo
Comment Utility
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
Comment Utility
Not working :((
0
 
LVL 30

Accepted Solution

by:
Zoppo earned 50 total points
Comment Utility
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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:karthik1979
Comment Utility
Cool! That worked. Thanks.
0
 

Author Comment

by:karthik1979
Comment Utility
Thats cool!
0
 
LVL 30

Expert Comment

by:Zoppo
Comment Utility
You're welcome.

have a nice day,

regards,

ZOPPO
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now