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!
Printable View
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!
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.
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-
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.
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