Different on hover visual state for BS_OWNERDRAW buttons
I have a BS_OWNERDRAW button created with:
HWND hwndClose = CreateWindow(WC_BUTTON, _T(""),
BS_PUSHBUTTON | BS_OWNERDRAW | WS_CHILD | WS_VISIBLE,
0, 0, 16, 16, win->hwndTocBox, (HMENU)IDC_TOC_CLOSE, ghinst, NULL);
I want to draw it differently when cursor is over the button. I was expecting to get WM_DRAWITEM message every time cursor enters/leaves my button but that doesn't seem to be the case. I only get it once even though standard windows button clearly have different开发者_如何学Python visual state in the on hover case.
Is it possible to easily get windows to send WM_DRAWITEM when on hover state changes, without doing tedious things like subclassing the button window and manually handling WM_MOUSEMOVE/WM_MOUSELEAVE messages?
This is a side-effect of ownerdraw. The visual hover effect you get on a 'regular' button is actually only present when its visual style is enabled. However, any control that has its ownerdraw style turned on will not get the visual style. This is appcompat behavior, it cannot be disabled. You'll have to do this the hard way.
精彩评论