Solved

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

Posted on 2004-08-21
6
738 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

691 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