Click to See Complete Forum and Search --> : Which control has the focus?
Patrick Beland
March 31st, 1999, 12:46 PM
I want to know which control has the focus on my dialog box.
I'm searching something like the Form.ActiveControl property in VB (return a reference to the active control).
Thanks!
Kevin Delgado
March 31st, 1999, 01:11 PM
CWnd has a static member GetFocus() which will return a CWnd* of the window that has current focus, or NULL if there isn't one. Give that a try.
Masaaki Onishi
March 31st, 1999, 01:35 PM
Hi.
I'm just curious about how you want to know it by pushing button?
If so, this approach is easy because GetFocus triggar by message handler.
However, if you want to know it always withouh pushing button showing
"Show which the control is focusing now", this approach seems to be a little
diffcult.
Regards.
-Masaaki Onishi-
Patrick Beland
March 31st, 1999, 09:41 PM
My dialog has 30 textbox and 1 push button.
What I wanna do is copy the content of the active textbox into all the other textbox when the button is clicked.
By using CWnd::GetFocus() I get near the expected result but when called in the click event the CWnd * returned is the button itself.
I'll continue to work on it, thanks for your answers.
Rudolf
March 31st, 1999, 11:32 PM
Hi Patrick,
Your textboxes have a SETFOCUS message .You could try something like this:
dialog class member YourTextBox * m_pTextboxWithInputFocus
YourTextBox::OnSetFocus(...)
{
m_pYourDialog->m_pTextBoxWithInputFocus = this;
}
So You always know which of Your textboxes was the last one with input focus...
Hope this helps,
Rudolf
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.