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

Thread: MFC pointers

  1. #1
    Join Date
    Jun 1999
    Posts
    1

    MFC pointers

    Hello

    I need to get a pointer to the View Class of an SDI app. for use within a global function written in the App class.

    Thanks very much in advance.



  2. #2
    Join Date
    May 1999
    Location
    Atlanta, GA, USA
    Posts
    443

    Re: MFC pointers

    Hi.

    I often use this syntax.

    ((CView*)(AfxGetMainWnd()))->public member funciton or variable of CView.

    Also, you can change the cast like CMainWin(from CFrameWnd) or CWinApp.
    There may be a mistake of brace.

    HTH.
    -Masaaki Onishi-






  3. #3
    Join Date
    Apr 1999
    Location
    Malaysia
    Posts
    224

    Re: MFC pointers

    Masaaki is right, but you have to take care the view class name,
    for example

    #include "CYourView.h"
    .....
    ....
    //View class pointer and variable
    CFrameWnd* pFrame=(CFrameWnd*)AfxGetMainWnd();
    CYourView* pView=(CYourView*)pFrame->GetActiveView();
    ...
    ...
    then you get the pointer of your view class..
    just point to any member variable of member function you want..
    ...
    pView->m_variable = 123;
    ..
    ..
    HTH

    Hello World!!!

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