We help IT Professionals succeed at work.

illegal vtable pointer

appleby
appleby asked
on
I am using a splitter window within an MDIChildWnd. When I try to grab ahold of the right pane I get an assertion error.

I'm creating the splitter window and two panes like this:

BOOL CEsvFrame::OnCreateClient( LPCREATESTRUCT /*lpcs*/, CCreateContext* pContext)
{
   // create splitter window
   if (!m_wndSplitter.CreateStatic(this, 1, 2))
      return FALSE;

   if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CEsvcSbView), CSize(200, 100), pContext) || !m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CEsvcItemView), CSize(200, 100), pContext))
   {
      m_wndSplitter.DestroyWindow();
      return FALSE;
   }

the assert is happening from the CSplitterWnd::GetPane() function.

CWnd* pWnd = m_wndSplitter.GetPane(0, 1);

This is the error message:

TRACE0("ASSERT_VALID fails with illegal vtable pointer.\n");


Any ideas what could be causing this?
Comment
Watch Question

AxterSenior Software Engineer

Commented:
Did you try
m_wndSplitter.GetPane(1, 1);

or

m_wndSplitter.GetPane(0, 0);

You need to check if it's a zero based index.
If it is zero base, then you need to start with zero's, if it's a one-based index, you need to start with 1's

Author

Commented:
Neither of those work.  I'm not sure whether it is zero or one based, all I know is it has 1 row and 2 columns, but either way one of the above should have worked.

AxterSenior Software Engineer

Commented:
Can you post the file that has the code?

Author

Commented:
Not really.
> illegal vtable pointer

This is a really nasty problem that is probably caused by something overwriting m_wndSplitter before the above code is even reached.

I suggest you put ASSERT_VALID(m_wndSplitter) throughout the code.  Eg at the start of OnCreateClient, at the end of the constructor.  Perhaps also override Create, PrecreateWindow, OnMDIActivate and add it in there too.

Author

Commented:
I have found that it depends on which window is active when I try to access the pointer.  If a child of the right pane is active I can access the right pane.  This works fine since I can just set all info I need when that window is active and grab it later without trying to access the actual window again.

Author

Commented:
I'm deleting this question since I found my own solution.
Commented:
this question will be placed in PAQ.  

Regards,
ComTech
CS Admin @ EE

Explore More ContentExplore courses, solutions, and other research materials related to this topic.