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;
|
RECT r;
|
||||||
INT oldBkMode, cxEdge = GetSystemMetrics(SM_CXEDGE);
|
INT oldBkMode, cxEdge = GetSystemMetrics(SM_CXEDGE);
|
||||||
HTHEME theme = GetWindowTheme (hwnd);
|
HTHEME theme = GetWindowTheme (hwnd);
|
||||||
|
NMCUSTOMDRAW nmcd;
|
||||||
|
|
||||||
TRACE("DrawItem(iItem %d bHotTrack %d unicode flag %d)\n", iItem, bHotTrack, infoPtr->bUnicode);
|
TRACE("DrawItem(iItem %d bHotTrack %d unicode flag %d)\n", iItem, bHotTrack, infoPtr->bUnicode);
|
||||||
|
|
||||||
|
@ -205,22 +206,24 @@ HEADER_DrawItem (HWND hwnd, HDC hdc, INT iItem, BOOL bHotTrack)
|
||||||
r.left -= cxEdge;
|
r.left -= cxEdge;
|
||||||
r.right += cxEdge;
|
r.right += cxEdge;
|
||||||
|
|
||||||
|
/* 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);
|
||||||
|
nmcd.hdr.code = NM_CUSTOMDRAW;
|
||||||
|
nmcd.dwDrawStage = CDDS_PREPAINT | CDDS_ITEM | CDDS_ITEMPOSTERASE;
|
||||||
|
nmcd.hdc = hdc;
|
||||||
|
nmcd.dwItemSpec = iItem;
|
||||||
|
nmcd.rc = r;
|
||||||
|
nmcd.uItemState = phdi->bDown ? CDIS_SELECTED : 0;
|
||||||
|
nmcd.lItemlParam = phdi->lParam;
|
||||||
|
|
||||||
|
SendMessageW (infoPtr->hwndNotify, WM_NOTIFY, nmcd.hdr.idFrom, (LPARAM)&nmcd);
|
||||||
|
|
||||||
if (phdi->fmt & HDF_OWNERDRAW) {
|
if (phdi->fmt & HDF_OWNERDRAW) {
|
||||||
DRAWITEMSTRUCT dis;
|
DRAWITEMSTRUCT dis;
|
||||||
NMCUSTOMDRAW nmcd;
|
|
||||||
|
|
||||||
nmcd.hdr.hwndFrom = hwnd;
|
|
||||||
nmcd.hdr.idFrom = GetWindowLongPtrW (hwnd, GWLP_ID);
|
|
||||||
nmcd.hdr.code = NM_CUSTOMDRAW;
|
|
||||||
nmcd.dwDrawStage = CDDS_PREPAINT | CDDS_ITEM | CDDS_ITEMPOSTERASE;
|
|
||||||
nmcd.hdc = hdc;
|
|
||||||
nmcd.dwItemSpec = iItem;
|
|
||||||
nmcd.rc = r;
|
|
||||||
nmcd.uItemState = phdi->bDown ? CDIS_SELECTED : 0;
|
|
||||||
nmcd.lItemlParam = phdi->lParam;
|
|
||||||
|
|
||||||
SendMessageW (infoPtr->hwndNotify, WM_NOTIFY,
|
|
||||||
(WPARAM)nmcd.hdr.idFrom, (LPARAM)&nmcd);
|
|
||||||
|
|
||||||
dis.CtlType = ODT_HEADER;
|
dis.CtlType = ODT_HEADER;
|
||||||
dis.CtlID = GetWindowLongPtrW (hwnd, GWLP_ID);
|
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;
|
rw = r.right - r.left;
|
||||||
rh = r.bottom - r.top;
|
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) {
|
if (phdi->fmt & HDF_STRING) {
|
||||||
RECT textRect;
|
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? */
|
HDF_BITMAP_ON_RIGHT|HDF_IMAGE)))) /* no explicit format specified? */
|
||||||
&& (phdi->pszText)) {
|
&& (phdi->pszText)) {
|
||||||
oldBkMode = SetBkMode(hdc, TRANSPARENT);
|
oldBkMode = SetBkMode(hdc, TRANSPARENT);
|
||||||
SetTextColor (hdc, (bHotTrack && !theme) ? COLOR_HIGHLIGHT : COLOR_BTNTEXT);
|
|
||||||
r.left = tx;
|
r.left = tx;
|
||||||
r.right = tx + tw;
|
r.right = tx + tw;
|
||||||
DrawTextW (hdc, phdi->pszText, -1,
|
DrawTextW (hdc, phdi->pszText, -1,
|
||||||
|
|
Loading…
Reference in New Issue