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 the ID of the dialog item which own the focus?

How can I get the ID of the dialog item which own the focus?

Scheduled Pinned Locked Moved C / C++ / MFC
questiontutorial
3 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.
  • P Offline
    P Offline
    pantao551
    wrote on last edited by
    #1

    :confused: My program can not use the mouse, And all the operation will be done by the keyboard. But I do not know how to get the ID number of the item which has the keyboard focus. Thanks!

    T J 2 Replies Last reply
    0
    • P pantao551

      :confused: My program can not use the mouse, And all the operation will be done by the keyboard. But I do not know how to get the ID number of the item which has the keyboard focus. Thanks!

      T Offline
      T Offline
      ThatsAlok
      wrote on last edited by
      #2

      pantao551 wrote: item which has the keyboard focus. Use GetFocus() to find the Ctrl which currently under the Keyboard Focus. pantao551 wrote: how to get the ID number Pass the HWND or CWnd return from call of GetFocus to GetDlgCtrlID which will return the Numeric ID of Control!

      "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

      cheers, Alok Gupta

      1 Reply Last reply
      0
      • P pantao551

        :confused: My program can not use the mouse, And all the operation will be done by the keyboard. But I do not know how to get the ID number of the item which has the keyboard focus. Thanks!

        J Offline
        J Offline
        Jorgen Sigvardsson
        wrote on last edited by
        #3

        What Alok said, with the addition that you can use int id = ::GetWindowLong(::GetFocus(), GWL_ID); if you'd like to stay win32. -- Schni Schna Schnappi! Schnappi Schnappi Schnapp!

        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