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. MFC Question : (From where AFxWinMain gets CwinApp object) [modified]

MFC Question : (From where AFxWinMain gets CwinApp object) [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
c++question
3 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.
  • J Offline
    J Offline
    jk chan
    wrote on last edited by
    #1

    Dear all, Anybody knows from where AfxWinMain gets the CWinApp global object pointer ? When i looked the MFC source file (winmain.cpp) i can see the following lines. nt AFXAPI AfxWinMain(..../*params*/) { int nReturnCode = -1; CWinThread* pThread = AfxGetThread(); CWinApp* pApp = AfxGetApp(); } Surely AfxGetApp() returns that global object. me again looked the AfxGetApp function , it is calling a AfxGetModuleState state function and this function returns the CWinApp object. AfxGetModuleState gets this value from CThreadLocal class's object. My question is How MFC getting the pointer of my CWinApp derived class object. Share your ideas please.. -- modified at 0:51 Friday 5th January, 2007

    If u can Dream... U can do it

    S 1 Reply Last reply
    0
    • J jk chan

      Dear all, Anybody knows from where AfxWinMain gets the CWinApp global object pointer ? When i looked the MFC source file (winmain.cpp) i can see the following lines. nt AFXAPI AfxWinMain(..../*params*/) { int nReturnCode = -1; CWinThread* pThread = AfxGetThread(); CWinApp* pApp = AfxGetApp(); } Surely AfxGetApp() returns that global object. me again looked the AfxGetApp function , it is calling a AfxGetModuleState state function and this function returns the CWinApp object. AfxGetModuleState gets this value from CThreadLocal class's object. My question is How MFC getting the pointer of my CWinApp derived class object. Share your ideas please.. -- modified at 0:51 Friday 5th January, 2007

      If u can Dream... U can do it

      S Offline
      S Offline
      Stephen Hewitt
      wrote on last edited by
      #2

      The following line is from CWinApp::CWinApp: pModuleState->m_pCurrentWinApp = this; That's how it gets the app.

      Steve

      J 1 Reply Last reply
      0
      • S Stephen Hewitt

        The following line is from CWinApp::CWinApp: pModuleState->m_pCurrentWinApp = this; That's how it gets the app.

        Steve

        J Offline
        J Offline
        jk chan
        wrote on last edited by
        #3

        Thanks Steve.:-D .

        If u can Dream... U can do it

        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