Solved

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

Posted on 2004-08-21
6
729 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
6 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 250 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 44

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 44

Expert Comment

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

Featured Post

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Best tools for Backup and restore of Wordpress site 6 57
while loop over for loop 7 102
zeroMAx challenge 20 100
mapAB Challlenge 35 144
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

770 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