Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CDocument & CMainFrame.

CDocument & CMainFrame.

Scheduled Pinned Locked Moved C / C++ / MFC
question
7 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mostafa_pasha
    wrote on last edited by
    #1

    Is that any way that call CMainFrame's function from my CDocument class? Best Regards. MJM.

    D 1 Reply Last reply
    0
    • M mostafa_pasha

      Is that any way that call CMainFrame's function from my CDocument class? Best Regards. MJM.

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      What's wrong with AfxGetMainWnd()?


      "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

      "Judge not by the eye but by the heart." - Native American Proverb

      M 1 Reply Last reply
      0
      • D David Crow

        What's wrong with AfxGetMainWnd()?


        "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

        "Judge not by the eye but by the heart." - Native American Proverb

        M Offline
        M Offline
        mostafa_pasha
        wrote on last edited by
        #3

        Do u mean i use AfxGetMainWnd() & then use PostMessage to handling that with CMainFrame class?

        D 1 Reply Last reply
        0
        • M mostafa_pasha

          Do u mean i use AfxGetMainWnd() & then use PostMessage to handling that with CMainFrame class?

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          You indicated that you wanted to "call CMainFrame's function from my CDocument class." AfxGetMainWnd() is used to get a pointer to the frame window object. With that, you can call whatever function you need.


          "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

          "Judge not by the eye but by the heart." - Native American Proverb

          M 1 Reply Last reply
          0
          • D David Crow

            You indicated that you wanted to "call CMainFrame's function from my CDocument class." AfxGetMainWnd() is used to get a pointer to the frame window object. With that, you can call whatever function you need.


            "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

            "Judge not by the eye but by the heart." - Native American Proverb

            M Offline
            M Offline
            mostafa_pasha
            wrote on last edited by
            #5

            But i can not access function that i declare in CMainFrame object! for example i wrote CreatePane function in CMainFrame object. i wanna call this function from CMyDocument ! i use AfxGetMainWnd but m_pMainWnd can not access CreatePane or CreatePane did not declare in FrameWnd object! best Regards. MJM.

            D 1 Reply Last reply
            0
            • M mostafa_pasha

              But i can not access function that i declare in CMainFrame object! for example i wrote CreatePane function in CMainFrame object. i wanna call this function from CMyDocument ! i use AfxGetMainWnd but m_pMainWnd can not access CreatePane or CreatePane did not declare in FrameWnd object! best Regards. MJM.

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              mostafa_pasha wrote:

              But i can not access function that i declare in CMainFrame object!

              Why not?

              mostafa_pasha wrote:

              but m_pMainWnd can not access CreatePane or

              Probably because you forgot to cast the return value from AfxGetMainWnd().


              "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

              "Judge not by the eye but by the heart." - Native American Proverb

              M 1 Reply Last reply
              0
              • D David Crow

                mostafa_pasha wrote:

                But i can not access function that i declare in CMainFrame object!

                Why not?

                mostafa_pasha wrote:

                but m_pMainWnd can not access CreatePane or

                Probably because you forgot to cast the return value from AfxGetMainWnd().


                "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

                "Judge not by the eye but by the heart." - Native American Proverb

                M Offline
                M Offline
                mostafa_pasha
                wrote on last edited by
                #7

                Thanks a lot , i forget casting! Best Regards. MJM.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups