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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. AfxGetMainWnd() from a Worker Thread

AfxGetMainWnd() from a Worker Thread

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
5 Posts 3 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.
  • G Offline
    G Offline
    Giles
    wrote on last edited by
    #1

    I nned to be able to get the main frame window from a worker thread with no GUI component. AfxGetMainWnd() get the main window for the current thread - the worker thread and so returns null. Any ideas on how to get the MainFrame from the primary thread? Thanks, Giles

    M N 2 Replies Last reply
    0
    • G Giles

      I nned to be able to get the main frame window from a worker thread with no GUI component. AfxGetMainWnd() get the main window for the current thread - the worker thread and so returns null. Any ideas on how to get the MainFrame from the primary thread? Thanks, Giles

      M Offline
      M Offline
      Morozov Alexey
      wrote on last edited by
      #2

      Pass HWND of MainFrame through thread parameters and then create CWnd object by CWnd::FromHandle(HWND) function in workeer thread

      G 1 Reply Last reply
      0
      • G Giles

        I nned to be able to get the main frame window from a worker thread with no GUI component. AfxGetMainWnd() get the main window for the current thread - the worker thread and so returns null. Any ideas on how to get the MainFrame from the primary thread? Thanks, Giles

        N Offline
        N Offline
        Nish Nishant
        wrote on last edited by
        #3

        Try AfxGetApp( )->m_pMainWnd Nish Bow wow wow, Yippee yo yippee yay, My miniputt high, Is now 30 yay.

        G 1 Reply Last reply
        0
        • N Nish Nishant

          Try AfxGetApp( )->m_pMainWnd Nish Bow wow wow, Yippee yo yippee yay, My miniputt high, Is now 30 yay.

          G Offline
          G Offline
          Giles
          wrote on last edited by
          #4

          Thanks Nish, will check it out. Giles

          1 Reply Last reply
          0
          • M Morozov Alexey

            Pass HWND of MainFrame through thread parameters and then create CWnd object by CWnd::FromHandle(HWND) function in workeer thread

            G Offline
            G Offline
            Giles
            wrote on last edited by
            #5

            I thought of passing the handle, but was not sure if it would be okay from another thread. Despite that, I am updainting another window, but need to be able to get at the promary thread so I can attach to the Frane Window, and them the Status Bar. Thanks, Giles

            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