Using SetFocus() in a push button.
-
Hey I have a C++ WIN32 app having a dialog with 5 buttons. Now i want to call the SetFocus() function to set the focus on each buttons. The focus does get set in a way, i.e., if i press the space key in key board, it will infact click the button to which the SetFocus() function was set. But visually it doesn't work. i.e., it doesn't draw a blue border on the button giving it a visual feel that the button has focus on it. Why is this happening? Is there a way to have SetFocus() draw the blue border along the button? If i open a windows folder on top of it, it will draw the blue border along the button that was called with SetFocus() function. Thanks in advance.
-
Hey I have a C++ WIN32 app having a dialog with 5 buttons. Now i want to call the SetFocus() function to set the focus on each buttons. The focus does get set in a way, i.e., if i press the space key in key board, it will infact click the button to which the SetFocus() function was set. But visually it doesn't work. i.e., it doesn't draw a blue border on the button giving it a visual feel that the button has focus on it. Why is this happening? Is there a way to have SetFocus() draw the blue border along the button? If i open a windows folder on top of it, it will draw the blue border along the button that was called with SetFocus() function. Thanks in advance.
May be you have to invalidate the button to enforce a redraw ...
-
May be you have to invalidate the button to enforce a redraw ...
-
May be you have to invalidate the button to enforce a redraw ...
that's a good question... who actually draws that, the button or button's parent window? maybe invalidate the parent window?
-
that's a good question... who actually draws that, the button or button's parent window? maybe invalidate the parent window?
AFAIK the window (and every control is a window by itself) draws itself until the style is owner-drawn. If you invalidate the parent window, this will draw itself and then force a redraw of EVERY of its child windows. (To minimize this effect there is a function InvalidateRegion) But my knowledge is from old WinAPI32 - may be something changed since then ...
modified on Thursday, March 17, 2011 3:36 PM
-
Ok, may be you must follow this by a call to UpdateWindow, 'cause InvalidateWindow simply raise a flag to send a WM_Paint message to the window if the message queue is empty ...
-
AFAIK the window (and every control is a window by itself) draws itself until the style is owner-drawn. If you invalidate the parent window, this will draw itself and then force a redraw of EVERY of its child windows. (To minimize this effect there is a function InvalidateRegion) But my knowledge is from old WinAPI32 - may be something changed since then ...
modified on Thursday, March 17, 2011 3:36 PM
i know every control is a window, but that's why i was asking who really draws the button "highlighting"? ...it would depend on how the framework implemented the highlighting, which i'm not really sure about... but if he says that dragging an explorer window over it does the trick, that has the same effect as invalidating the parent...
-
Hey I have a C++ WIN32 app having a dialog with 5 buttons. Now i want to call the SetFocus() function to set the focus on each buttons. The focus does get set in a way, i.e., if i press the space key in key board, it will infact click the button to which the SetFocus() function was set. But visually it doesn't work. i.e., it doesn't draw a blue border on the button giving it a visual feel that the button has focus on it. Why is this happening? Is there a way to have SetFocus() draw the blue border along the button? If i open a windows folder on top of it, it will draw the blue border along the button that was called with SetFocus() function. Thanks in advance.
Are
CDialog::SetDefID()
orCDialog::GotoDlgCtrl()
of any help?"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
-
Are
CDialog::SetDefID()
orCDialog::GotoDlgCtrl()
of any help?"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
-
Finally i got this working. What i did was, do a SetFocus(ParentWindow) and then do a SetFocus(ChildWindow) on this order and it worked just fine.
Seems that is what I replied to another question - is it that this button is the only editable control on the form ? 'Caus then, a SetFocus() will have no effect on painting, 'cause the focus didn't change really ...