/*---------------------------------------------------- paint "Desktop User Pane" window of XP Start Menu -----------------------------------------------------*/ void OnPaintUserPaneXP(HWND hwnd, HDC hdc) { RECT rc; COLORREF col; HBRUSH hbr; int wClient, hClient; GetClientRect(hwnd, &rc); wClient = rc.right; hClient = rc.bottom; col = m_colMenu; if(col & 0x80000000) col = GetSysColor(col & 0x00ffffff); hbr = CreateSolidBrush(col); FillRect(hdc, &rc, hbr); DeleteObject(hbr); if(m_hbmpMenu) { int x, y; int wbmp, hbmp; GetBmpSize(m_hbmpMenu, &wbmp, &hbmp); for(y = 0; y < hClient; y += hbmp) { for(x = 0; x < wClient; x += wbmp) { BitBlt(hdc, x, y, wbmp, hbmp, m_hdcMemMenu, 0, 0, SRCCOPY); if(!m_bTile) break; } if(!m_bTile) break; } } }
void KDrawFrame::Draw(CDCHandle& dc, CRect rct, COLORREF clrBk) { CBrush brush; brush.CreateSolidBrush(clrBk); HBRUSH hOldBrush = dc.SelectBrush(brush); // 绘制背景 dc.Rectangle(&rct); int left, top, right, botton; CSize size = GetBmpSize(m_bmpLeftTop); left = size.cx; top = size.cy; size = GetBmpSize(m_bmpRightBotton); right = size.cx; botton = size.cy; CDC hTmpDC; hTmpDC.CreateCompatibleDC(dc); HBITMAP bOldbmp = hTmpDC.SelectBitmap(m_bmpLeftTop); dc.BitBlt(0, 0, left, top, hTmpDC, 0, 0, SRCCOPY); size = GetBmpSize(m_bmpTopBoder); hTmpDC.SelectBitmap(m_bmpTopBoder); dc.StretchBlt(left, 0, rct.right-right, top, hTmpDC, 0, 0, size.cx, size.cy, SRCCOPY); hTmpDC.SelectBitmap(m_bmpRightTop); dc.BitBlt(rct.right-right, 0, rct.right, top, hTmpDC, 0, 0, SRCCOPY); size = GetBmpSize(m_bmpLeftBoder); hTmpDC.SelectBitmap(m_bmpLeftBoder); dc.StretchBlt(0, top, left, rct.bottom-botton-top, hTmpDC, 0, 0, size.cx, size.cy, SRCCOPY); size = GetBmpSize(m_bmpRightBoder); hTmpDC.SelectBitmap(m_bmpRightBoder); dc.StretchBlt(rct.right-right, top, right, rct.bottom-botton-top, hTmpDC, 0, 0, size.cx, size.cy, SRCCOPY); hTmpDC.SelectBitmap(m_bmpLeftBotton); dc.BitBlt(0, rct.bottom-botton, left, botton, hTmpDC, 0, 0, SRCCOPY); size = GetBmpSize(m_bmpBottonBoder); hTmpDC.SelectBitmap(m_bmpBottonBoder); dc.StretchBlt(left, rct.bottom-botton, rct.right-right, botton, hTmpDC, 0, 0, size.cx, size.cy, SRCCOPY); hTmpDC.SelectBitmap(m_bmpRightBotton); dc.BitBlt(rct.right-right, rct.bottom-botton, rct.right, botton, hTmpDC, 0, 0, SRCCOPY); hTmpDC.SelectBitmap(bOldbmp); dc.SelectBrush(hOldBrush); }
void RingDockSite::SetBgBmp(HBITMAP hbm,BOOL bSetOrg/*=FALSE*/) { if(hbm) { HBRUSH hBrush = m_Background.hBrush; GetBmpSize(hbm,(SIZE*)&m_Background); m_Background.hBrush = CreatePatternBrush(hbm); m_Background.bSetOrg = bSetOrg; if(m_Background.bNeedDelete) { UpdateAllSiteBkg(hBrush); DeleteObject(hBrush); } m_Background.bNeedDelete = FALSE; UpdateBkg(); } else SetBgColor(GetSysColor(COLOR_BTNFACE)); }
/*------------------------------------------------ owner-drawn start menu (Win95 without IE 4) called in taskbar.c --------------------------------------------------*/ BOOL OnDrawItemStartMenu(HWND hwnd, DRAWITEMSTRUCT* pdis) { HDC hdc, hdcMem; HBITMAP hbmpMem; RECT rcBox, rcItem; HBRUSH hbr; if(!m_bStartMenu) return FALSE; if(!IsStartMenu((HMENU)pdis->hwndItem)) return FALSE; hdc = pdis->hDC; CopyRect(&rcItem, &(pdis->rcItem)); GetClipBox(hdc, &rcBox); // menu size // offscreen DC and BMP hdcMem = CreateCompatibleDC(hdc); hbmpMem = CreateCompatibleBitmap(hdc, rcBox.right, rcBox.bottom); SelectObject(hdcMem, hbmpMem); hbr = GetSysColorBrush(COLOR_MENU); FillRect(hdcMem, &rcBox, hbr); SelectObject(hdcMem, (HFONT)GetCurrentObject(hdc, OBJ_FONT)); // background and text color if(pdis->itemState & ODS_FOCUS) { SetTextColor(hdcMem, GetSysColor(COLOR_HIGHLIGHTTEXT)); SetBkColor(hdcMem, GetSysColor(COLOR_HIGHLIGHT)); } else { SetTextColor(hdcMem, GetSysColor(COLOR_MENUTEXT)); SetBkColor(hdcMem, GetSysColor(COLOR_MENU)); } // default drawing pdis->hDC = hdcMem; // width of "Windows95" rcItem.right = pdis->rcItem.left; if(rcItem.right > 0) { COLORREF col; if(!m_bTile) { col = m_colMenu; if(col & 0x80000000) col = GetSysColor(col & 0x00ffffff); hbr = CreateSolidBrush(col); FillRect(hdcMem, &rcItem, hbr); DeleteObject(hbr); } if(m_hdcMemMenu && m_hbmpMenu) { int i, j; int wbmp, hbmp; GetBmpSize(m_hbmpMenu, &wbmp, &hbmp); for(i = 0; ; i++) { int y, ysrc, h, x, w; for(j = 0; ; j++) { y = rcBox.bottom - ((i + 1) * hbmp); ysrc = 0; h = hbmp; if(y < 0) { y = 0; ysrc = ((i + 1) * hbmp) - rcBox.bottom; h -= ysrc; } x = j * wbmp; w = wbmp; if(x + w > rcItem.right) { w -= ((j + 1) * wbmp) - rcItem.right; } if(w > 0 && h > 0) BitBlt(hdcMem, x, y, w, h, m_hdcMemMenu, 0, ysrc, SRCCOPY); if(!m_bTile || w < wbmp) break; } if(!m_bTile || y == 0) break; } } } BitBlt(hdc, 0, rcItem.top, pdis->rcItem.right, rcItem.bottom - rcItem.top, hdcMem, 0, rcItem.top, SRCCOPY); pdis->hDC = hdc; DeleteDC(hdcMem); DeleteObject(hbmpMem); return TRUE; }