During my 20 years or so writing Win32 programs, I always relied on SetFocus
to focus a control. However, I always noticed a weird behavior on push buttons regarding the BS_DEFPUSHBUTTON
style, which was never right. In fact, I remember one of the past WinLamb incarnations which I implemented some trick involving changing the button style when setting the focus.
Anyway, now I found out how to properly set the focus on a control, and it does not involve SetFocus
, but rather the WM_NEXTDLGCTL
message:
SendMessage(hParent, WM_NEXTDLGCTL, (WPARAM)hButton, MAKELPARAM(TRUE, 0));
And the push button magically sets its own style correctly.
No comments:
Post a Comment