CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 1999
    Location
    Johnson City, NY
    Posts
    43

    How do I get a pointer to my Main Frame class?

    How do I get a pointer to my main frame class. Specifically, I have a variable in my CMainFrm class that I want to set in my CView class. I need a pointer to my CMainFrame so I can type:
    pMainFrm->variable = 0;


    Right?

    Thanks..



  2. #2
    Join Date
    Sep 1999
    Location
    Europe / Austria / Innsbruck
    Posts
    442

    Re: How do I get a pointer to my Main Frame class?

    Use the function AfxGetMainWnd(). You must cast the return value to your actual mainwindow class. For example:

    ((CMainFrame*)AfxGetMainWnd())->variable = 0;






  3. #3
    Join Date
    Jun 1999
    Location
    Canada - Québec
    Posts
    273

    Re: How do I get a pointer to my Main Frame class?

    try like this :

    CMyFrame * frame;
    frame = (CMyFrame*)GetParent();
    frame->variable = 0;





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