开发者

Setting background color of Win32 dialog button (not owner-drawn)

Is it possible to set开发者_如何学C the background color of a dialog button in Win32 without using an owner-drawn button?

The following paints the background of every dialog item except the buttons (not owner-drawn):

case WM_CTLCOLOREDIT:
case WM_CTLCOLORSTATIC:
case WM_CTLCOLORBTN:

    HDC hdcStatic = (HDC)wParam;
    SetBkColor(hdcStatic, bgEditColor);    

    return (INT_PTR)bgBrushCurrent; // a red brush created earlier


It is quite explicit in the SDK docs for the message:

Buttons with the BS_PUSHBUTTON, BS_DEFPUSHBUTTON, or BS_PUSHLIKE styles do not use the returned brush. Buttons with these styles are always drawn with the default system colors. Drawing push buttons requires several different brushes-face, highlight, and shadow-but the WM_CTLCOLORBTN message allows only one brush to be returned. To provide a custom appearance for push buttons, use an owner-drawn button.

Most Windows programs nowadays use the visual style selected by the user. Recommended, add the required manifest.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜