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. CButton Killfocus

CButton Killfocus

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

    How do you get the killfocus for a CButton. There is a ON_BN_KILLFOCUS but that never comes. In the class wizard there is no option for killfocus. scott

    M A 2 Replies Last reply
    0
    • G Gilfrog

      How do you get the killfocus for a CButton. There is a ON_BN_KILLFOCUS but that never comes. In the class wizard there is no option for killfocus. scott

      M Offline
      M Offline
      Mike Upton
      wrote on last edited by
      #2

      Just a guess, but according to the platform SDK, buttons must have the BS_NOTIFY style set if you want them to send BN_KILLFOCUS. Does your button have that style set?


      "We are the knights who say Ni" (The Knights Who Say Ni)

      1 Reply Last reply
      0
      • G Gilfrog

        How do you get the killfocus for a CButton. There is a ON_BN_KILLFOCUS but that never comes. In the class wizard there is no option for killfocus. scott

        A Offline
        A Offline
        Alvaro Mendez
        wrote on last edited by
        #3

        You probably can't get the KillFocus message because it doesn't propagate up to the button's parent window. So you need to derive your own class from CButton and then you can add a message handler for WM_KILLFOCUS. Regards, Alvaro


        All you need in this life is ignorance and confidence, and then success is sure. -- Mark Twain

        M 1 Reply Last reply
        0
        • A Alvaro Mendez

          You probably can't get the KillFocus message because it doesn't propagate up to the button's parent window. So you need to derive your own class from CButton and then you can add a message handler for WM_KILLFOCUS. Regards, Alvaro


          All you need in this life is ignorance and confidence, and then success is sure. -- Mark Twain

          M Offline
          M Offline
          Mike Upton
          wrote on last edited by
          #4

          WM_KILLFOCUS doesn't propagate up, but the button does send BN_KILLFOCUS to its parent window (if its BS_NOTIFY style is set) - so handling the BN_KILLFOCUS notification in the parent should work.


          "We are the knights who say Ni" (The Knights Who Say Ni)

          A G 2 Replies Last reply
          0
          • M Mike Upton

            WM_KILLFOCUS doesn't propagate up, but the button does send BN_KILLFOCUS to its parent window (if its BS_NOTIFY style is set) - so handling the BN_KILLFOCUS notification in the parent should work.


            "We are the knights who say Ni" (The Knights Who Say Ni)

            A Offline
            A Offline
            Alvaro Mendez
            wrote on last edited by
            #5

            Cool, so he just needs to handle the WM_NOTIFY message on the parent and check for BN_KILLFOCUS along with the proper ID for the button. Thanks for the info. Regards, Alvaro


            All you need in this life is ignorance and confidence, and then success is sure. -- Mark Twain

            1 Reply Last reply
            0
            • M Mike Upton

              WM_KILLFOCUS doesn't propagate up, but the button does send BN_KILLFOCUS to its parent window (if its BS_NOTIFY style is set) - so handling the BN_KILLFOCUS notification in the parent should work.


              "We are the knights who say Ni" (The Knights Who Say Ni)

              G Offline
              G Offline
              Gilfrog
              wrote on last edited by
              #6

              that works, thanks Scott

              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