|
-
April 4th, 2009, 05:27 AM
#1
How do I get a handle to CRUNTIMECLASS initiated classes?
Hello!
I am making an MDI application where each of the CMDIChildWnd windows contain 2 CScrollviews in a CSplitterWnd.
I have severe problems accessing the individual CScrollviews from the CMDIChildWnd window.
Basically my CMDIChildWnd contains 4 panes, where 2 are CSplitterWnd scroll views (see code below).
When the CScrollview classes attempt to find out who is their parent owner, then there is an assertion error and the app. crashes. I assume that this happens because the CScrollviews are
kicked off as CRUNTIMECLASS objects? (have no clue elsewise...) - I have tried to use methods GetParent, GetOwner, etc. nothing changes the situation....
I really need to get a pointer to my CSplitterWnd scroll views in so that the owner (and only the owner) CMDIChildWnd window can address them by choice. I am really suspicious about how CRUNTIMECLASS works, and maybe I need to get the pointer using completey different method calls.
What can I do?
Grateful if somebody knows what I do wrong - Please check my code below.
Best regards
Gustav
=========Part of my code ===========================================
-------------------------------------SETTING UP THE SCROLL VIEWS---------------------------------------------
1.
CCMDIChildWnd code that sets up the CCSplitterWnd scroll views:
______________________________________________________
IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWnd)
// CChildFrame construction/destruction
BOOL CChildFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/, CCreateContext* pContext)
{
if(!m_wndSplitter.CreateStatic(this,2,2)||
/* THESE 2 PANES DO NOT NEED TO ACCESS THEIR PARENT - SO NO PROBLEM HERE*/
!m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CCurrent_pane_view),CSize(this->ParentWidth,20),pContext)||
!m_wndSplitter.CreateView(0,1,RUNTIME_CLASS(CRef_pane_view),CSize(CSize(this->ParentWidth,20)),pContext)||
/*!!!!!!!!! THESE TWO PANES WILL BOTH CRASH ...*/
!m_wndSplitter.CreateView(1,0,RUNTIME_CLASS(CCurrentFileView),CSize(this->ParentWidth/2,0),pContext)||
!m_wndSplitter.CreateView(1,1,RUNTIME_CLASS(CReference_File_View),CSize(this->ParentWidth/2,0),pContext))
return FALSE;
return TRUE;
}
----------------------THE CSCROLLVIEW CLASS-------------------------------------------------------------------
2:
The CScrollView code that always crashes:
_________________________________
IMPLEMENT_DYNCREATE(CCurrentFileView, CScrollView)
CCurrentFileView::CCurrentFileView()
{
/* HERE WE GET AN ASSERTION ERROR EACH TIME! APPARENTLY MY CLASS HAS NO IDEA OF WHO OWNS IT? */
CWnd* ParentWnd=this->GetParent();
/* PROGRAM CRASHED NOW....*/
if(ParentWnd!=NULL)
{
ParentWnd->SendMessage(MSG_SET_REF_POINTER,NULL,NULL);
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|