static void draw_bitmap_button(PCONTROL pCtrl, HDC hdc, DWORD dwStyle, RECT *prcText) { if (BUTTON_DATA(pCtrl)) { int x = prcText->left; int y = prcText->top; int w = RECTWP (prcText); int h = RECTHP (prcText); PBITMAP bmp = (PBITMAP)(BUTTON_DATA(pCtrl)); RECT prcClient; GetClientRect ((HWND)pCtrl, &prcClient); if (dwStyle & BS_REALSIZEIMAGE) { x += (w - bmp->bmWidth) >> 1; y += (h - bmp->bmHeight) >> 1; w = h = 0; if (bmp->bmWidth > RECTW(prcClient)){ x = prcClient.top + BTN_WIDTH_BORDER; y = prcClient.left + BTN_WIDTH_BORDER; w = RECTW(prcClient) - 2*BTN_WIDTH_BORDER-1; } if (bmp->bmHeight > RECTH(prcClient)){ x = prcClient.top + BTN_WIDTH_BORDER; y = prcClient.left + BTN_WIDTH_BORDER; h = RECTH(prcClient) - 2*BTN_WIDTH_BORDER-1; } } else {
static void btnPaintContent (PCONTROL pCtrl, HDC hdc, DWORD dwStyle, RECT* prcText) { switch (dwStyle & BS_CONTENTMASK) { case BS_TEXT: case BS_LEFTTEXT: { UINT uFormat; if (dwStyle & BS_MULTLINE) uFormat = DT_WORDBREAK; else uFormat = DT_SINGLELINE; if ((dwStyle & BS_TYPEMASK) == BS_PUSHBUTTON || (dwStyle & BS_TYPEMASK) == BS_DEFPUSHBUTTON || (dwStyle & BS_PUSHLIKE)) uFormat |= DT_CENTER | DT_VCENTER; else { uFormat = DT_TOP | DT_LEFT; if ((dwStyle & BS_ALIGNMASK) == BS_LEFT) uFormat = DT_WORDBREAK | DT_LEFT; else if ((dwStyle & BS_ALIGNMASK) == BS_RIGHT) uFormat = DT_WORDBREAK | DT_RIGHT; else if ((dwStyle & BS_ALIGNMASK) == BS_CENTER) uFormat = DT_WORDBREAK | DT_CENTER; if ((dwStyle & BS_ALIGNMASK) == BS_TOP) uFormat = DT_SINGLELINE | DT_TOP; else if ((dwStyle & BS_ALIGNMASK) == BS_BOTTOM) uFormat = DT_SINGLELINE | DT_BOTTOM; else if ((dwStyle & BS_ALIGNMASK) == BS_VCENTER) uFormat = DT_SINGLELINE | DT_VCENTER; } SetBkColor (hdc, GetWindowBkColor ((HWND)pCtrl)); if (dwStyle & WS_DISABLED) { RECT rc = *prcText; SetBkMode (hdc, BM_TRANSPARENT); SetTextColor (hdc, PIXEL_lightwhite); OffsetRect (prcText, 2, 2); DrawText (hdc, pCtrl->spCaption, -1, prcText, uFormat); SetTextColor (hdc, PIXEL_darkgray); DrawText (hdc, pCtrl->spCaption, -1, &rc, uFormat); } else { SetBkMode (hdc, BM_TRANSPARENT); SetTextColor (hdc, PIXEL_black); OffsetRect (prcText, 1, 1); DrawText (hdc, pCtrl->spCaption, -1, prcText, uFormat); } } break; case BS_BITMAP: if (BUTTON_DATA(pCtrl)) { int x = prcText->left; int y = prcText->top; int w = RECTWP (prcText); int h = RECTHP (prcText); PBITMAP bmp = (PBITMAP)(BUTTON_DATA(pCtrl)); if (dwStyle & BS_REALSIZEIMAGE) { x += (w - bmp->bmWidth) >> 1; y += (h - bmp->bmHeight) >> 1; w = h = 0; } FillBoxWithBitmap (hdc, x, y, w, h, bmp); } break; case BS_ICON: if (BUTTON_DATA(pCtrl)) { int x = prcText->left; int y = prcText->top; int w = RECTWP (prcText); int h = RECTHP (prcText); HICON icon = (HICON)(BUTTON_DATA(pCtrl)); if (dwStyle & BS_REALSIZEIMAGE) { int iconw, iconh; GetIconSize (icon, &iconw, &iconh); x += (w - iconw) >> 1; y += (h - iconh) >> 1; w = h = 0; } DrawIcon (hdc, x, y, w, h, icon); }