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. Kill Focus/Next Action

Kill Focus/Next Action

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

    I have a situation with an edit box when the user types in an existing code, data is displayed in subsequent fields. If they type in a new number, I clear the data in the subsequent fields. The populating/clearing of the subsequent fields is triggered in the KillFocus callback of the edit box. The problem is, there are pushbuttons, like Save, Close, which now will clear the data, since moving focus out of the edit box by pressing the Close button invokes the KillFocus callback. Is there a way in the KillFocus callback to know that a press of one of the pushbuttons is in the message queue so I can process this case differently? Thanks in advance, Bob

    J 1 Reply Last reply
    0
    • M moobob

      I have a situation with an edit box when the user types in an existing code, data is displayed in subsequent fields. If they type in a new number, I clear the data in the subsequent fields. The populating/clearing of the subsequent fields is triggered in the KillFocus callback of the edit box. The problem is, there are pushbuttons, like Save, Close, which now will clear the data, since moving focus out of the edit box by pressing the Close button invokes the KillFocus callback. Is there a way in the KillFocus callback to know that a press of one of the pushbuttons is in the message queue so I can process this case differently? Thanks in advance, Bob

      J Offline
      J Offline
      Joaquin M Lopez Munoz
      wrote on last edited by
      #2

      OnKillFocus provides also the CWnd to be given the focus. You can check whether this corresponds to one of your special buttons. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

      M 1 Reply Last reply
      0
      • J Joaquin M Lopez Munoz

        OnKillFocus provides also the CWnd to be given the focus. You can check whether this corresponds to one of your special buttons. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

        M Offline
        M Offline
        moobob
        wrote on last edited by
        #3

        I tried to do this, but I don't understand what is happening. When tabbing off of the Edit box, CWnd is a value of 12b89c, CWnd hWnd is 180bd4. If I press one of the 3 pushbuttons, the values are 12b748 and 180bd4 respectively. None of these values match the CWnd value I get returned when calling GetDlgItem(PushButtonId) for each of the pushbuttons. So how do I match the CWnd value I get in the callback with the pushbuttons? Thanks, Bob

        J 1 Reply Last reply
        0
        • M moobob

          I tried to do this, but I don't understand what is happening. When tabbing off of the Edit box, CWnd is a value of 12b89c, CWnd hWnd is 180bd4. If I press one of the 3 pushbuttons, the values are 12b748 and 180bd4 respectively. None of these values match the CWnd value I get returned when calling GetDlgItem(PushButtonId) for each of the pushbuttons. So how do I match the CWnd value I get in the callback with the pushbuttons? Thanks, Bob

          J Offline
          J Offline
          Joaquin M Lopez Munoz
          wrote on last edited by
          #4

          Oh well, I've tried in a small test app, and the CWnd passed to OnKillFocus seems to be that of the parent dialog. So I'm afraid this approach does not work. Sorry. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

          M 1 Reply Last reply
          0
          • J Joaquin M Lopez Munoz

            Oh well, I've tried in a small test app, and the CWnd passed to OnKillFocus seems to be that of the parent dialog. So I'm afraid this approach does not work. Sorry. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

            M Offline
            M Offline
            moobob
            wrote on last edited by
            #5

            OK, that explains what I was seeing. Is there anyway to get the ID of the control that is about to receive focus when in the OnKillFocus? Thanks, Bob

            J 1 Reply Last reply
            0
            • M moobob

              OK, that explains what I was seeing. Is there anyway to get the ID of the control that is about to receive focus when in the OnKillFocus? Thanks, Bob

              J Offline
              J Offline
              James R Twine
              wrote on last edited by
              #6

              Have you tried seeing what GetFocus(...) and GetNextDlgTabItem(...) return?    Also, remember that if you call any functions that return a CWnd object, like GetFocus(...), you will be getting a temporary CWnd (actually a CTempWnd) object unless you have already "bound" a class to the control in question.  What that means that when in doubt, compare the value of the m_hWnd member to see if you have a certain control.    Peace! -=- James. "Fat people are hard to kidnap." (Try Check Favorites Sometime!)

              M 1 Reply Last reply
              0
              • J James R Twine

                Have you tried seeing what GetFocus(...) and GetNextDlgTabItem(...) return?    Also, remember that if you call any functions that return a CWnd object, like GetFocus(...), you will be getting a temporary CWnd (actually a CTempWnd) object unless you have already "bound" a class to the control in question.  What that means that when in doubt, compare the value of the m_hWnd member to see if you have a certain control.    Peace! -=- James. "Fat people are hard to kidnap." (Try Check Favorites Sometime!)

                M Offline
                M Offline
                moobob
                wrote on last edited by
                #7

                GetFocus() does the trick, Thanks! Bob

                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