?
Solved

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

Posted on 2004-08-21
6
Medium Priority
?
743 Views
Last Modified: 2013-11-20
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.
0
Comment
Question by:shean85
5 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 1000 total points
ID: 11862552
You can do this only from non-static function:

CMyView * GetView();    // without static keyword

What are you trying to do?

0
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 11863205
AfxGetMainWnd() should return the main window of the app (which should be the frame window or is this an MDIChildFrame?)
0
 

Author Comment

by:shean85
ID: 11866001
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
 
LVL 7

Expert Comment

by:vijay_visana
ID: 11867391
You can not call non-static function from static function
0
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 11867598
Why does GetView need to be static?
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
In this post we will learn different types of Android Layout and some basics of an Android App.
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 quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses

839 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