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. Get HWND from HINSTANCE

Get HWND from HINSTANCE

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
6 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.
  • T Offline
    T Offline
    Tran Hoang Chuong
    wrote on last edited by
    #1

    Hi I have a HINSTANCE, I want to get HWND from it. Can you help me? Thanks for your reading. Tran Hoang Chuong

    A 1 Reply Last reply
    0
    • T Tran Hoang Chuong

      Hi I have a HINSTANCE, I want to get HWND from it. Can you help me? Thanks for your reading. Tran Hoang Chuong

      A Offline
      A Offline
      alex barylski
      wrote on last edited by
      #2

      HINSTANCE is an instance handle to an application and an application can have many or no windows. I don't see how you would retrieve one HWND from any HINSTANCE. If your using MFC then CWinThread::m_pMainWnd holds the pointer to the application main window and from here you could use EnumChildWindows() to get the others... Cheers! :) "An expert is someone who has made all the mistakes in his or her field" - Niels Bohr

      T 1 Reply Last reply
      0
      • A alex barylski

        HINSTANCE is an instance handle to an application and an application can have many or no windows. I don't see how you would retrieve one HWND from any HINSTANCE. If your using MFC then CWinThread::m_pMainWnd holds the pointer to the application main window and from here you could use EnumChildWindows() to get the others... Cheers! :) "An expert is someone who has made all the mistakes in his or her field" - Niels Bohr

        T Offline
        T Offline
        Tran Hoang Chuong
        wrote on last edited by
        #3

        Hi HockeyDude I forgot to tell more detail about my question. It means I have a HINSTANCE from a command ShellExecute(...) and I want to get CWnd of the application I have just exectuted. Thanks for your reply. Tran Hoang Chuong

        A 1 Reply Last reply
        0
        • T Tran Hoang Chuong

          Hi HockeyDude I forgot to tell more detail about my question. It means I have a HINSTANCE from a command ShellExecute(...) and I want to get CWnd of the application I have just exectuted. Thanks for your reply. Tran Hoang Chuong

          A Offline
          A Offline
          alex barylski
          wrote on last edited by
          #4

          I think the CWinThread is no good to you then. :) I don't know of any function which would return the window handle associated with an HINSTANCE. Except EnumChildWindows which only returns child windows of a parent. Can you use FindWindow()...? "An expert is someone who has made all the mistakes in his or her field" - Niels Bohr

          T 1 Reply Last reply
          0
          • A alex barylski

            I think the CWinThread is no good to you then. :) I don't know of any function which would return the window handle associated with an HINSTANCE. Except EnumChildWindows which only returns child windows of a parent. Can you use FindWindow()...? "An expert is someone who has made all the mistakes in his or her field" - Niels Bohr

            T Offline
            T Offline
            Tran Hoang Chuong
            wrote on last edited by
            #5

            Hi HockeyDude Thank you very much Tran Hoang Chuong

            A 1 Reply Last reply
            0
            • T Tran Hoang Chuong

              Hi HockeyDude Thank you very much Tran Hoang Chuong

              A Offline
              A Offline
              alex barylski
              wrote on last edited by
              #6

              if you figured it out that's all that matters "An expert is someone who has made all the mistakes in his or her field" - Niels Bohr

              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