Jump to content
  • Advertisement
Sign in to follow this  
Episode6

CSplitterWnd CreateStatic() fails

This topic is 4796 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, I've never posted here, but I've found a lot of articles and forum threads that have helped me a lot in the past, so I figured this is probably the best place to look for help. I'm trying to make a level editor using MFC and some Render Engine. I got it all working nicely, I split my mainForm into 3 Panes, and I split the middle Pane into another 4. I created those panes with these lines of code
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
mMainSplitter.CreateStatic(this, 1, 3);
mMainSplitter.CreateView(0, 0, RUNTIME_CLASS(EditorBrowserPanel), CSize(width,height), pContext);
mViewSplitter.CreateStatic(&mMainSplitter, 2, 2, WS_CHILD | WS_VISIBLE, mMainSplitter.IdFromRowCol(0, 1));
mViewSplitter.CreateView(0, 0, RUNTIME_CLASS(CTimeEDView), CSize(width, height), pContext);
mViewSplitter.CreateView(0, 1, RUNTIME_CLASS(CTimeEDView), CSize(width, height), pContext);
mViewSplitter.CreateView(1, 0, RUNTIME_CLASS(CTimeEDView), CSize(width, height), pContext);
mViewSplitter.CreateView(1, 1, RUNTIME_CLASS(CTimeEDView), CSize(width, height), pContext);
mMainSplitter.CreateView(0, 2, RUNTIME_CLASS(EditorBrowserMenu), CSize(width,height), pContext);
}

I managed to get 3 orthographic views and 1 perspective view working perfectly, by supplying the HWND of the 4 Panes to the Render Engine. After that I decided to do it a little different. Instead of having CTimeEDView as a runtime class for the 4 viewports, I wanted to have another CFormView (EditorView), which would split it into a smaller menu (EditorViewMenu) and the old CTimeEDView. So here's the code I wrote that would be the new runtime class for the 4 windows, to split the form into panes.
BOOL EditorView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwstyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
{
	if ( !mSplitter.CreateStatic(pParentWnd, 2, 1, dwstyle, nID))
	{
		MessageBox( "1.1 Error setting up splitter frames!", "Init Error!", MB_OK | MB_ICONERROR );
		return FALSE;
	}

	CRect cr;
	GetClientRect(&cr);

	if ( !mSplitter.CreateView(0, 0, RUNTIME_CLASS(EditorViewMenu), CSize(rect.right - rect.left, EDITOR_VIEW_MENU), pContext) )
	{
		MessageBox( "2.1 Error setting up splitter frames!", "Init Error!", MB_OK | MB_ICONERROR );
		return FALSE;
	}

	if ( !mSplitter.CreateView(1, 0, RUNTIME_CLASS(CTimeEDView), CSize(rect.right - rect.left, ((rect.bottom-rect.top) - EDITOR_VIEW_MENU)), pContext) )
	{
		MessageBox( "3.1 Error setting up splitter frames!", "Init Error!", MB_OK | MB_ICONERROR );
		return FALSE;
	}

	return CFormView::Create(lpszClassName, lpszWindowName, dwstyle, rect, pParentWnd, nID, pContext);
}

The first problem I encountered, was finding the right function to put this in. Since CFormView doesn't have a message "OnCreateClient", I used Create() instead. I don't know if I did the right thing here, but at least it supplied me with the correct parameters. Next up was mSplitter.CreateStatic(pParentWnd, 2, 1, dwstyle, nID) I thought I should supply "this" as a parent for the Splitter, but it returned 0 when I tried that (it gave me the message box), so I used pParentWnd, which did seem to work. nID was also a complete mystery to me, so I don't know if I did the right thing there. I also made sure that the classes were dynamically created (whatever that may mean), so there are no errors there. Well it compiles correctly, but when I run it, I get this thrown at me
---------------------------
Microsoft Visual C++ Debug Library
---------------------------
Debug Assertion Failed!

Program: C:\Cplusplus\ogrenew\Samples\Common\bin\Debug\Time\TimeED.exe
File: f:\vs70builds\3077\vc\MFCATL\ship\atlmfc\include\afxwin2.inl
Line: 282

For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.

(Press Retry to debug the application)
---------------------------
Abort   Retry   Ignore   
---------------------------

and when I debug, it will point towards this line as the cause of it.
	if ( !mSplitter.CreateStatic(pParentWnd, 2, 1, dwstyle, nID))
On an (unimportant) sidenote, I wrote the CFormView derived classes like I wrote the ones that did work
	EditorMenuPanel();
	virtual ~EditorMenuPanel();
	
	virtual void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint);
	virtual void DoDataExchange(CDataExchange* pDX);

	DECLARE_DYNCREATE(EditorMenuPanel)
	DECLARE_MESSAGE_MAP()

    #ifdef _DEBUG
	  virtual void AssertValid() const;
	  virtual void Dump(CDumpContext& dc) const;
    #endif

Can anybody help me with this? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
never mind, I read some threads about it being impossible to implement a CSplitterWnd inside a CFormView;

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!