Solved

Exception while sizing splitter window

Posted on 2002-05-23
6
260 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 

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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

809 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