Solved

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

Posted on 2004-08-21
6
717 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now