Processing NM_CUSTOMDRAW on a pushbutton - but Windows still draws the text

718 Views Asked by At

I'm experimenting with using NM_CUSTOMDRAW instead of WM_DRAWITEM for bitmap buttons in my win32 app. The WM_DRAWITEM stuff works fine - except that it doesn't work under WINE with a desktop theme enabled (for some reason, with a theme enabled, WINE only sends WM_DRAWITEM when you click a pushbutton).

Anyway, I tried removing the BS_OWNERDRAW from the OK button below - leaving the others alone. To test processing the WM_NOTIFY, I just copy the fields I need from the NMCUSTOMDRAW struct to a DRAWITEMSTRUCT and pass that to my existing WM_DRAWITEM handler. The button draws fine, but then Windows draws the OK text over mine (my text is shifted to make room for the checkmark). I've pasted the code below. I thought that if I returned CDRF_SKIPDEFAULT in response to all NM_CUSTOMDRAW notifications, Windows wouldn't try to draw anything. There's obviously something else I need to do...

enter image description here

    case WM_NOTIFY:
    // Only intrested in NM_CUSTOMDRAW messages here.
    nmh = (LPNMHDR) lParam;
    if (nmh->code != NM_CUSTOMDRAW)
        break;
    // Only interested in CDDS_PREPAINT.
    lpNMC = (LPNMCUSTOMDRAW) lParam;
    if (lpNMC->dwDrawStage != CDDS_PREPAINT)
        return(CDRF_SKIPDEFAULT);

    // Copy fields we need from NMCUSTOMDRAW to a DRAWITEMSTRUCT.
    memset(&dis, 0, sizeof(dis));
    dis.hwndItem = nmh->hwndFrom;
    dis.hDC = lpNMC->hdc;
    dis.rcItem = lpNMC->rc;
    if (lpNMC->uItemState & CDIS_FOCUS)
        dis.itemState |= ODS_FOCUS;
    if (lpNMC->uItemState & CDIS_SELECTED)
        dis.itemState |= ODS_SELECTED;
    if (lpNMC->uItemState & CDIS_DEFAULT)
        dis.itemState |= ODS_DEFAULT;
    if (lpNMC->uItemState & CDIS_DISABLED)
        dis.itemState |= ODS_DISABLED;
    DrawBitmapButtonOnWindowsDialog(wParam, (LPARAM) &dis, -1);
    return(CDRF_SKIPDEFAULT);

case WM_DRAWITEM:
    DrawBitmapButtonOnWindowsDialog(wParam, lParam, -1);
    break;
0

There are 0 best solutions below