CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Guest

    Getting a pointer to CView

    Hi!

    I've had some problem (in MSVC++ 6) getting a pointer to the CView class from the CMainFrame? When I use the code below I get two error messages and I'm forced to close the application:

    CView* pView = GetActiveView();
    HWND hView = pView->m_hWnd;

    Is there anyone who knows how to fix this?

    Thanks in advance!

    /Tom


  2. #2
    Join Date
    May 1999
    Posts
    26

    Re: Getting a pointer to CView

    The pointer returned by GetActiveView() may not be valid. Maybe you are trying to get the pointer before the view is created. I'm not very sure this is the cause, but you can check it.


  3. #3
    Join Date
    May 1999
    Posts
    82

    Re: Getting a pointer to CView

    FYI: The GetActiveView() function will return NULL if you try to call it from the CMainFrame of a MDI application. If you need to call it for a MDI application you will need to first get the active child window and then call GetActiveView for that window like so...

    GetActiveFrame()->GetActiveView();

    Hope this helps


  4. #4
    Join Date
    Jul 1999
    Posts
    3

    Re: Getting a pointer to CView

    A pointer to View from Frame can be got by this code,
    CMyView* ptrView = ( CMyView*)AfxGetMainWnd();

    Try this, it may solve your problem

    Narayan Singh B.

    Singh

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured