'CWnd::GetParentFrame' : illegal call of non-static member function

I'm creating Frame and View at Run Time, and I have static method where I'm trying to get pointer to my Mainframe

CMyView * CMyView::GetView()
{      
          CMainFrame* pFrame = (CMainFrame*)GetParentFrame(); //here I got an error (error C2352: 'CWnd::GetParentFrame' : illegal call of non-static member function)
         CMyView *pView = (CMyView *)pFrame->m_pSplitterWnd->GetPane(0,0);
        return (CMyView *) pView;
}
header file
static CMyView * GetView();

But I got an error "illegal call of non-static member function" .
Please help me how can I get a pointer to my Frame inside(or outside)  of this method??


Please help.
Thank you.
shean85Asked:
Who is Participating?
 
AlexFMConnect With a Mentor Commented:
You can do this only from non-static function:

CMyView * GetView();    // without static keyword

What are you trying to do?

0
 
AndyAinscowFreelance programmer / ConsultantCommented:
AfxGetMainWnd() should return the main window of the app (which should be the frame window or is this an MDIChildFrame?)
0
 
shean85Author Commented:
What are you trying to do?

I have dialog base App, when I click on some button I'm creating new window Frame and View.
In View class I have GetView to get pointer to my View(view with splitter):
CMyView * CMyView::GetView()
{    
        // This is way how I can get a pointer to my view
        CMyView *pView = (CMyView *)pFrame->m_pSplitterWnd->GetPane(0,0);
        return (CMyView *) pView;
}

GetView has to be Static function.
 The quastion how to get pointer to my Frame ???
I wonted to use CMainFrame* pFrame = (CMainFrame*)GetParentFrame(); , but it doesn't work in static function:(


0
 
vijay_visanaCommented:
You can not call non-static function from static function
0
 
AndyAinscowFreelance programmer / ConsultantCommented:
Why does GetView need to be static?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.