Click to See Complete Forum and Search --> : How to set the focus to a previous control?


Steve McNeese
April 21st, 1999, 12:44 PM
How can I determine what control on a view had focus before it is switched to a button that is clicked? I have buttons that are used to navigate through pictures. When they are clicked and have finished whatever they need to do, I want to set the focus to the control that previously had the focus before the button was clicked. Is this possible? Calling CWnd::Getfocus from the OnButton function return the control of the button. Maybe I could use the KillFocus message to set a CWnd * member of the view to the control that is loosing focus and then set the focus back to that CWnd * as the last step of the OnButton function. Any better ideas?

Thanks,

Steve

Steven M. McNeese
steven.mcneese@boeing.com

Safai Ma
April 21st, 1999, 04:51 PM
I think you can handle OnSetFocus (WM_SETFOCUS message) as it gives the CWnd object that loses input focus. This implies that you override (subclass) your buttons in order to handle this message. Hope this helps.