comctl32: Fix emitting of NM_CUSTOMDRAW header notifications.
Emit NM_CUSTOMDRAW header notifications for all headers, not only ownerdrawn. Allow to change item text and background colors in an application's NM_CUSTOMDRAW handler.
This commit is contained in:
parent
f5ebb75f08
commit
1b9fc2a170
|
@ -166,6 +166,7 @@ HEADER_DrawItem (HWND hwnd, HDC hdc, INT iItem, BOOL bHotTrack)
|
|||
RECT r;
|
||||
INT oldBkMode, cxEdge = GetSystemMetrics(SM_CXEDGE);
|
||||
HTHEME theme = GetWindowTheme (hwnd);
|
||||
NMCUSTOMDRAW nmcd;
|
||||
|
||||
TRACE("DrawItem(iItem %d bHotTrack %d unicode flag %d)\n", iItem, bHotTrack, infoPtr->bUnicode);
|
||||
|
||||
|
@ -205,9 +206,9 @@ HEADER_DrawItem (HWND hwnd, HDC hdc, INT iItem, BOOL bHotTrack)
|
|||
r.left -= cxEdge;
|
||||
r.right += cxEdge;
|
||||
|
||||
if (phdi->fmt & HDF_OWNERDRAW) {
|
||||
DRAWITEMSTRUCT dis;
|
||||
NMCUSTOMDRAW nmcd;
|
||||
/* Set the colors before sending NM_CUSTOMDRAW so that it can change them */
|
||||
SetTextColor (hdc, (bHotTrack && !theme) ? COLOR_HIGHLIGHT : COLOR_BTNTEXT);
|
||||
SetBkColor(hdc, GetSysColor(COLOR_3DFACE));
|
||||
|
||||
nmcd.hdr.hwndFrom = hwnd;
|
||||
nmcd.hdr.idFrom = GetWindowLongPtrW (hwnd, GWLP_ID);
|
||||
|
@ -219,8 +220,10 @@ HEADER_DrawItem (HWND hwnd, HDC hdc, INT iItem, BOOL bHotTrack)
|
|||
nmcd.uItemState = phdi->bDown ? CDIS_SELECTED : 0;
|
||||
nmcd.lItemlParam = phdi->lParam;
|
||||
|
||||
SendMessageW (infoPtr->hwndNotify, WM_NOTIFY,
|
||||
(WPARAM)nmcd.hdr.idFrom, (LPARAM)&nmcd);
|
||||
SendMessageW (infoPtr->hwndNotify, WM_NOTIFY, nmcd.hdr.idFrom, (LPARAM)&nmcd);
|
||||
|
||||
if (phdi->fmt & HDF_OWNERDRAW) {
|
||||
DRAWITEMSTRUCT dis;
|
||||
|
||||
dis.CtlType = ODT_HEADER;
|
||||
dis.CtlID = GetWindowLongPtrW (hwnd, GWLP_ID);
|
||||
|
@ -249,6 +252,14 @@ HEADER_DrawItem (HWND hwnd, HDC hdc, INT iItem, BOOL bHotTrack)
|
|||
rw = r.right - r.left;
|
||||
rh = r.bottom - r.top;
|
||||
|
||||
if (theme == NULL) {
|
||||
HBRUSH hbr = CreateSolidBrush(GetBkColor(hdc));
|
||||
RECT rcBackground = r;
|
||||
|
||||
rcBackground.right -= cxEdge;
|
||||
FillRect(hdc, &rcBackground, hbr);
|
||||
DeleteObject(hbr);
|
||||
}
|
||||
if (phdi->fmt & HDF_STRING) {
|
||||
RECT textRect;
|
||||
|
||||
|
@ -344,7 +355,6 @@ HEADER_DrawItem (HWND hwnd, HDC hdc, INT iItem, BOOL bHotTrack)
|
|||
HDF_BITMAP_ON_RIGHT|HDF_IMAGE)))) /* no explicit format specified? */
|
||||
&& (phdi->pszText)) {
|
||||
oldBkMode = SetBkMode(hdc, TRANSPARENT);
|
||||
SetTextColor (hdc, (bHotTrack && !theme) ? COLOR_HIGHLIGHT : COLOR_BTNTEXT);
|
||||
r.left = tx;
|
||||
r.right = tx + tw;
|
||||
DrawTextW (hdc, phdi->pszText, -1,
|
||||
|
|
Loading…
Reference in New Issue