Discussion:
CWnd::SetFocus()
(too old to reply)
JD
2007-02-09 02:07:24 UTC
Permalink
Hi,

CWnd::SetFocus() is used to direct all subsequent keyboard input to this
window. Do you know which function is used to direct all subsequent
"mouse input" to the window? I have a combo box and an active control.
My combo box always gets the "mouse" focus even I apply
CWnd::SetFocus() to my active control. Do you know how to achieve this
purpose? Your help is much appeciated.

JD
Sarath
2007-02-09 02:35:01 UTC
Permalink
Take a look at this article

http://www.codeproject.com/dialog/dlgboxtricks.asp
--
-Sarath
Post by JD
Hi,
CWnd::SetFocus() is used to direct all subsequent keyboard input to this
window. Do you know which function is used to direct all subsequent
"mouse input" to the window? I have a combo box and an active control.
My combo box always gets the "mouse" focus even I apply
CWnd::SetFocus() to my active control. Do you know how to achieve this
purpose? Your help is much appeciated.
JD
j***@zeusedit.com
2007-02-09 02:44:42 UTC
Permalink
Post by JD
My combo box always gets the "mouse" focus even I apply
CWnd::SetFocus() to my active control.
What on earth is "mouse focus"?

If you click on a control or a window that control gets the
focus rectangle.

SetFocus is nothing more than a programmatic way of giving
the focus rectangle to a control or window.

Jussi Jumppanen
Author: Zeus for Windows IDE
http://www.zeusedit.com
JD
2007-02-09 03:06:59 UTC
Permalink
Hi jussij,

By "mouse focus", I meant that if you rotate the mouse middle button
(for scrolling), you should see pages scrolled in a list control (or a
grid active control), or see a selection change in a combo box. I
exactly wants to programmatically set the active control as active so
that user doesn't need to click it first as you described. Thanks.

JD
Post by j***@zeusedit.com
Post by JD
My combo box always gets the "mouse" focus even I apply
CWnd::SetFocus() to my active control.
What on earth is "mouse focus"?
If you click on a control or a window that control gets the
focus rectangle.
SetFocus is nothing more than a programmatic way of giving
the focus rectangle to a control or window.
Jussi Jumppanen
Author: Zeus for Windows IDE
http://www.zeusedit.com
Joseph M. Newcomer
2007-02-09 03:17:35 UTC
Permalink
Actually, when you click on a window, the reason it gets the focus is because the window
has a handler

void CWhatever::OnLButtonDown()
{
SetFocus();
return;
}

Note that DefWindowProc does not necessarily give focus to a window that has been clicked;
it only activates it if it is not activated. Thus you need the handler for child windows.
joe
Post by j***@zeusedit.com
Post by JD
My combo box always gets the "mouse" focus even I apply
CWnd::SetFocus() to my active control.
What on earth is "mouse focus"?
If you click on a control or a window that control gets the
focus rectangle.
SetFocus is nothing more than a programmatic way of giving
the focus rectangle to a control or window.
Jussi Jumppanen
Author: Zeus for Windows IDE
http://www.zeusedit.com
Joseph M. Newcomer [MVP]
email: ***@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
Joseph M. Newcomer
2007-02-09 03:14:01 UTC
Permalink
Mouse input, except for WM_MOUSEWHEEL messages, always goes to the window under the mouse.
WM_MOUSEWHEEL messages are sent to the window that has the focus.

What's an "active control"? Do you mean "ActiveX control" or do you mean "a control that
is enabled"?

A window can capture the mouse, in which case mouse input goes to the window that has the
capture, independent of which window it is over. The downside of this is that it means
that if a window has capture, you can't click into any other window, or the title bar,
etc., so mouse capture is only used during operations like dragging.
joe
Post by JD
Hi,
CWnd::SetFocus() is used to direct all subsequent keyboard input to this
window. Do you know which function is used to direct all subsequent
"mouse input" to the window? I have a combo box and an active control.
My combo box always gets the "mouse" focus even I apply
CWnd::SetFocus() to my active control. Do you know how to achieve this
purpose? Your help is much appeciated.
JD
Joseph M. Newcomer [MVP]
email: ***@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
JD
2007-02-09 20:21:44 UTC
Permalink
Hi Joseph,

I apologize for my typo. I did want to mean "activeX control", in
particularly ComopnentOne's grid control. Thanks.

JD
Post by Joseph M. Newcomer
Mouse input, except for WM_MOUSEWHEEL messages, always goes to the window under the mouse.
WM_MOUSEWHEEL messages are sent to the window that has the focus.
What's an "active control"? Do you mean "ActiveX control" or do you mean "a control that
is enabled"?
A window can capture the mouse, in which case mouse input goes to the window that has the
capture, independent of which window it is over. The downside of this is that it means
that if a window has capture, you can't click into any other window, or the title bar,
etc., so mouse capture is only used during operations like dragging.
joe
Post by JD
Hi,
CWnd::SetFocus() is used to direct all subsequent keyboard input to this
window. Do you know which function is used to direct all subsequent
"mouse input" to the window? I have a combo box and an active control.
My combo box always gets the "mouse" focus even I apply
CWnd::SetFocus() to my active control. Do you know how to achieve this
purpose? Your help is much appeciated.
JD
Joseph M. Newcomer [MVP]
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
Satish
2007-02-09 04:10:35 UTC
Permalink
Post by JD
Hi,
CWnd::SetFocus() is used to direct all subsequent keyboard input to this
window. Do you know which function is used to direct all subsequent
"mouse input" to the window? I have a combo box and an active control.
My combo box always gets the "mouse" focus even I apply
CWnd::SetFocus() to my active control. Do you know how to achieve this
purpose? Your help is much appeciated.
JD
Are you having these controls on Dialog. Active control is it activeX
control? What you return out of OnInitDialog also determines the
focus. Check http://msdn2.microsoft.com/fr-fr/library/fwz35s59(VS.80).aspx
Loading...