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. When to draw the focus rectangle

When to draw the focus rectangle

Scheduled Pinned Locked Moved C / C++ / MFC
c++graphicsalgorithmsquestion
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.
  • R Offline
    R Offline
    Ron Waller
    wrote on last edited by
    #1

    How do you know when you are supposed to draw the focus on a control? I'm referring to controls on dialog boxes. At first when you click on a control with the mouse, the control doesn't draw the focus rectangle. It only draws it once you start navigating the dialog with the keyboard. I'd like to be able to find out from within the control using its hWnd. (I'm trying to skin Win98-style buttons in VC++ 6.0 to give them a WinXP look by overriding drawing messages [WM_PAINT, BM_SETSEL, etc.] in the button's windows-class wnd proc. I've got everything done so far, except this, and I've spent hours searching MSDN and the internet trying to find it.)

    R M 2 Replies Last reply
    0
    • R Ron Waller

      How do you know when you are supposed to draw the focus on a control? I'm referring to controls on dialog boxes. At first when you click on a control with the mouse, the control doesn't draw the focus rectangle. It only draws it once you start navigating the dialog with the keyboard. I'd like to be able to find out from within the control using its hWnd. (I'm trying to skin Win98-style buttons in VC++ 6.0 to give them a WinXP look by overriding drawing messages [WM_PAINT, BM_SETSEL, etc.] in the button's windows-class wnd proc. I've got everything done so far, except this, and I've spent hours searching MSDN and the internet trying to find it.)

      R Offline
      R Offline
      Ravi Bhavnani
      wrote on last edited by
      #2

      The DRAWITEMSTRUCT passed to OnDrawItem() contains this information. Specifically, the itemState member, whose ODS_FOCUS bit indicates the item has focus. You may also want to check the ODS_SELECTED bit to render the control appropriately. See this[^] MSDN article. Alternatively, you could call GetFocus() to determine if the control has focus, although the preferred way is to check the DRAWITEMSTRUCT. /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

      1 Reply Last reply
      0
      • R Ron Waller

        How do you know when you are supposed to draw the focus on a control? I'm referring to controls on dialog boxes. At first when you click on a control with the mouse, the control doesn't draw the focus rectangle. It only draws it once you start navigating the dialog with the keyboard. I'd like to be able to find out from within the control using its hWnd. (I'm trying to skin Win98-style buttons in VC++ 6.0 to give them a WinXP look by overriding drawing messages [WM_PAINT, BM_SETSEL, etc.] in the button's windows-class wnd proc. I've got everything done so far, except this, and I've spent hours searching MSDN and the internet trying to find it.)

        M Offline
        M Offline
        Michael Dunn
        wrote on last edited by
        #3

        Send the dialog or button a WM_QUERYUISTATE message and test the return value for the UISF_HIDEFOCUS and UISF_HIDEACCEL flags. --Mike-- LINKS~! Ericahist updated! | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ Strange things are afoot at the U+004B U+20DD

        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