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. How can I get a controls HWND ?

How can I get a controls HWND ?

Scheduled Pinned Locked Moved C / C++ / MFC
question
6 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Hi ! How can I get a controls HWND ?

    L W 4 Replies Last reply
    0
    • L Lost User

      Hi ! How can I get a controls HWND ?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      For example the ID of the dialog control is IDC_BUTTON2. CWnd *pWnd = GetDlgItem(IDC_BUTTON2); if (pWnd) { HWND hwnd = pWnd->m_hWnd; // hwnd is your handle to the control } I hope I could help you... Gregor Mitsch E-Mail: abacus-@gmx.de

      V 1 Reply Last reply
      0
      • L Lost User

        Hi ! How can I get a controls HWND ?

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        You need to say ... HWND hwnd = ((CastMainWindow*)AfxGetMainWnd)->NameOfControl;

        1 Reply Last reply
        0
        • L Lost User

          Hi ! How can I get a controls HWND ?

          W Offline
          W Offline
          Waleed Eissa
          wrote on last edited by
          #4

          Try using FindWindowEx

          1 Reply Last reply
          0
          • L Lost User

            Hi ! How can I get a controls HWND ?

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            --

            1 Reply Last reply
            0
            • L Lost User

              For example the ID of the dialog control is IDC_BUTTON2. CWnd *pWnd = GetDlgItem(IDC_BUTTON2); if (pWnd) { HWND hwnd = pWnd->m_hWnd; // hwnd is your handle to the control } I hope I could help you... Gregor Mitsch E-Mail: abacus-@gmx.de

              V Offline
              V Offline
              Vu Nguyen
              wrote on last edited by
              #6

              Hi Gregor Mitsch! do you know how to use this function bellow? I found it in the sdk, but fail to use it. Basically, I have 2 dialog. I need to change a value of an edit box on the second dialog, when a button on the first dialog is clicked. //here is the function prototype HWND GetDlgItem( HWND hDlg, // handle to dialog box int nIDDlgItem // control identifier ); Thank You Vu vucsuf

              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