void CSkinComboBox::OnPaint() { CPaintDC dc(this); CRect rcClient; GetClientRect(&rcClient); CMemoryDC MemDC(&dc,rcClient); CRect rcArrow; HRGN hRgn2 = NULL; if (m_lpArrowImgN != NULL && !m_lpArrowImgN->IsNull()) { int cxIcon = m_nArrowWidth; int cyIcon = m_lpArrowImgN->GetHeight(); CalcCenterRect(rcClient, cxIcon, cyIcon, rcArrow); rcArrow.right = rcClient.right - 2; rcArrow.left = rcArrow.right - cxIcon; } DrawParentWndBg(GetSafeHwnd(),MemDC->GetSafeHdc()); if (m_bHover) { if (m_lpBgImgH != NULL && !m_lpBgImgH->IsNull()) { m_lpBgImgH->Draw(&MemDC, rcClient); } else { if (m_lpBgImgN != NULL && !m_lpBgImgN->IsNull()) m_lpBgImgN->Draw(&MemDC, rcClient); } } else { if (m_lpBgImgN != NULL && !m_lpBgImgN->IsNull()) m_lpBgImgN->Draw(&MemDC, rcClient); } if (m_bArrowPress) { if (m_lpArrowImgP != NULL && !m_lpArrowImgP->IsNull()) m_lpArrowImgP->Draw(&MemDC, rcArrow); } else if (m_bArrowHover) { if (m_lpArrowImgH != NULL && !m_lpArrowImgH->IsNull()) m_lpArrowImgH->Draw(&MemDC, rcArrow); } else { if (m_lpArrowImgN != NULL && !m_lpArrowImgN->IsNull()) m_lpArrowImgN->Draw(&MemDC, rcArrow); } //绘制边框 m_SkinComboBoxList.DrawListFrame(); }
void CSkinListBox::OnNcPaint() { //如果资源没有就是不想绘制边框了 if ( m_pBackImgN == NULL ) { __super::OnNcPaint(); return; } CRect rcWindow; GetWindowRect(&rcWindow); CRect rcClient; GetClientRect(&rcClient); ClientToScreen(&rcClient); rcClient.OffsetRect(-rcWindow.left, -rcWindow.top); rcWindow.OffsetRect(-rcWindow.left, -rcWindow.top); CDC *pWindowDC = GetWindowDC(); CMemoryDC MemDC(pWindowDC,rcWindow); DrawParentWndBg(GetSafeHwnd(),MemDC.GetSafeHdc()); if (m_pBackImgN != NULL && !m_pBackImgN->IsNull()) m_pBackImgN->Draw(&MemDC, rcWindow); pWindowDC->BitBlt(rcWindow.left,rcWindow.top,rcWindow.Width(),rcWindow.Height(),&MemDC,0,0,SRCCOPY); ReleaseDC(pWindowDC); }
void CSkinStatic::OnPaint(CDCHandle dc) { CPaintDC PaintDC(m_hWnd); CRect rcClient; GetClientRect(&rcClient); CMemoryDC MemDC(PaintDC.m_hDC, rcClient); Draw(MemDC.m_hDC); }
void CMyEdit::OnNcPaint() { CRect rcWindow; GetWindowRect(&rcWindow); CRect rcClient; GetClientRect(&rcClient); ClientToScreen(&rcClient); rcClient.OffsetRect(-rcWindow.left, -rcWindow.top); rcWindow.OffsetRect(-rcWindow.left, -rcWindow.top); CDC *pWindowDC = GetWindowDC(); CMemoryDC MemDC(pWindowDC,rcWindow); CRect rcIcon; if (m_pIconImg != NULL && !m_pIconImg->IsNull()) { int cxIcon = m_pIconImg->GetWidth(); int cyIcon = m_pIconImg->GetHeight(); CalcCenterRect(rcWindow, cxIcon, cyIcon, rcIcon); rcIcon.right = rcWindow.right - 2; rcIcon.left = rcIcon.right - cxIcon; } DrawParentWndBg(GetSafeHwnd(),MemDC.GetSafeHdc()); if (m_bHover) { if (m_pBackImgH != NULL && !m_pBackImgH->IsNull()) { m_pBackImgH->Draw(&MemDC, rcWindow); } else { if (m_pBackImgN != NULL && !m_pBackImgN->IsNull()) m_pBackImgN->Draw(&MemDC, rcWindow); } } else { if (m_pBackImgN != NULL && !m_pBackImgN->IsNull()) m_pBackImgN->Draw(&MemDC, rcWindow); } if (m_pIconImg != NULL && !m_pIconImg->IsNull()) m_pIconImg->Draw(&MemDC, rcIcon); pWindowDC->BitBlt(rcWindow.left,rcWindow.top,rcWindow.Width(),rcWindow.Height(),&MemDC,0,0,SRCCOPY); ReleaseDC(pWindowDC); }
void CChildView::OnPaint() { CPaintDC dc(this); // device context for painting // TODO: Add your message handler code here // Do not call CWnd::OnPaint() for painting messages CMemDC MemDC(dc, this); TextOut(MemDC.GetDC().m_hDC, 0, 0, _T("Hello! World"), 12); }
void CFHDragWnd::OnPaint() { CPaintDC dc(this); if(m_pFlatHeaderCtrl->m_bDoubleBuffer) { CMemDC MemDC(&dc); OnDraw(&MemDC); } else OnDraw(&dc); }
void CEasySkinSliderCtrl::OnPaint() { CPaintDC dc(this); // device context for painting CRect rcClient; GetClientRect(&rcClient); CMemoryDC MemDC(&dc, rcClient); //绘制背景 DrawParentWndBg(GetSafeHwnd(),MemDC->GetSafeHdc()); //绘制轨迹 if ( !IsWindowEnabled() ) { if (m_pDisImg != NULL && !m_pDisImg->IsNull()) { m_pDisImg->DrawImage(&MemDC,0,0); } } else { if (m_pBackImg != NULL && !m_pBackImg->IsNull()) { m_pBackImg->DrawImage(&MemDC,0,0); } } //绘制痕迹 if (m_pTraceImg != NULL && !m_pTraceImg->IsNull()) { m_pTraceImg->Draw(&MemDC,CRect(0, 0,m_rcThumRect.left,m_pTraceImg->GetHeight())); } //绘制滑块 if (m_pThumImg != NULL && !m_pThumImg->IsNull()) { m_pThumImg->DrawImage(&MemDC,m_rcThumRect.left, m_rcThumRect.top); } //绘制按钮 if (m_pBtImg != NULL && !m_pBtImg->IsNull()) { if( m_bPress ) m_pBtImg->DrawImage(&MemDC,m_rcThumRect.left, m_rcThumRect.top,m_szThum.cx,m_szThum.cy,m_szThum.cx*2,0); else if ( m_bHover ) m_pBtImg->DrawImage(&MemDC,m_rcThumRect.left, m_rcThumRect.top,m_szThum.cx,m_szThum.cy,m_szThum.cx,0); else m_pBtImg->DrawImage(&MemDC,m_rcThumRect.left, m_rcThumRect.top,m_szThum.cx,m_szThum.cy,0,0); } }
void CTreeListColumnDropWnd::OnPaint() { CPaintDC dc(this); // device context for painting if( m_pTreeListCtrl->GetState( TLS_OFFSCREENBUFFER ) ) { CTreeListDC MemDC(&dc); DrawWnd(&MemDC); } else { DrawWnd(&dc); } }
void CSkinListBox::OnNcPaint() { CRect rcWindow; GetWindowRect(&rcWindow); rcWindow.OffsetRect(-rcWindow.left, -rcWindow.top); CWindowDC dc(this); CMemoryDC MemDC(&dc,rcWindow); if (m_pBackImgN != NULL && !m_pBackImgN->IsNull()) m_pBackImgN->Draw(&MemDC, rcWindow); }
void CFaceCtrl::OnPaint(CDCHandle dc) { CPaintDC PaintDC(m_hWnd); CRect rcClient; GetClientRect(&rcClient); CMemoryDC MemDC(PaintDC.m_hDC, rcClient); MemDC.FillSolidRect(&rcClient, m_clrBg); DrawLine(MemDC.m_hDC); CRect rcItem, rcImage; int nRow = 0, nCol = 0; int nLeft = 0, nTop = 0; for (int i = 0; i < (int)m_arrImage.size(); i++) { rcItem = CRect(nLeft, nTop, nLeft+m_nItemWidth, nTop+m_nItemHeight); CGifImage * lpImage = m_arrImage[i]; if (lpImage != NULL) { CalcCenterRect(rcItem, lpImage->GetWidth(), lpImage->GetHeight(), rcImage); lpImage->Draw(MemDC.m_hDC, rcImage, 0); } if (m_nHoverIndex == i) DrawFocusBorder(MemDC.m_hDC, rcItem); nLeft += m_nItemWidth; nCol++; if (nCol >= m_nCol) { nCol = 0; nRow++; if (nRow > m_nRow) break; nLeft = 0; nTop += m_nItemHeight; } } if (m_nHoverIndex != -1) DrawZoomImage(MemDC.m_hDC); }
void CGridDocs::OnPaint() { if(!bCanReDraw) { bCanReDraw = FALSE; } if(bCanReDraw) { CPaintDC dc(this); if (m_bDoubleBuffer) { CMemDC MemDC(&dc); OnDraw(&MemDC); } else OnDraw(&dc); } }
void CSkinToolBar::OnPaint() { CPaintDC dc(this); // device context for painting CRect rcClient; GetClientRect(&rcClient); CMemoryDC MemDC(&dc, rcClient); DrawParentWndBg(GetSafeHwnd(),MemDC.m_hDC); if ( CHECK_IMAGE(m_lpBgImg) ) m_lpBgImg->Draw(&MemDC, rcClient); for (int i = 0; i < (int)m_arrItems.size(); i++) { DrawItem(&MemDC, i); } }
void CxStatic::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { ASSERT(lpDrawItemStruct != NULL); CBitmap bmp; CBitmap* pOldBitmap = NULL; CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC); CRect rect = lpDrawItemStruct->rcItem; //Double Buffering - Modify MemDC for transparent background but doesn't work // because I have to invalidate parent when SetWindowText - Need to find a fix!!! pDC->SetBkColor(m_rgbBkgnd); CMemDC MemDC(pDC, &rect, m_bTransparentBk); // PAINT SOLID BACKGROUND IF NO BITMAP if ( !m_bBitmap){ if ( !m_bTransparentBk ){ if (m_fillmode == Normal) MemDC.FillRect(&rect, m_pBrush); else DrawGradientFill(&MemDC, &rect, m_fillmode); } } else{// DISPLAY BACKGROUND BITMAP DrawBitmap(&MemDC, &rect); } // TEXT RENDERING CFont* pOldFont = MemDC.SelectObject( &m_font ); COLORREF rgbText = MemDC.SetTextColor(m_rgbText); DrawText(&MemDC, &rect, m_strText); // Restore DC's State MemDC.SelectObject(pOldFont); MemDC.SetTextColor(rgbText); }
void CLegendWnd::OnPaint() { CPaintDC dc(this); // device context for painting CRect rect; GetClientRect(&rect); CMemDC MemDC(&dc, rect); MemDC.FillSolidRect(&rect, ::GetSysColor(COLOR_BTNFACE)); //---------------------------------------------------- CDC dcBmp; dcBmp.CreateCompatibleDC(&dc); CBitmap* pOldBmp = dcBmp.SelectObject(&m_bmpLegend); //draw all legend int nX=0, nY=0; LegendMap::iterator it; for(it=m_legendMap.begin(); it!=m_legendMap.end(); it++) { int nXOffset = 0; switch(it->second.sel_state) { case SS_NORMAL: break; case SS_HORVER: MemDC.FillSolidRect(nX, nY, nLegendWidth+2, nLegendHeight+2, ::GetSysColor(COLOR_ACTIVECAPTION)); break; case SS_SELECT: MemDC.Draw3dRect(nX, nY, nLegendWidth+2, nLegendHeight+2, GetSysColor(COLOR_BTNSHADOW ), GetSysColor(COLOR_BTNHIGHLIGHT)); break; } switch(it->second.state) { case LS_DIE: nXOffset = 0; break; case LS_LIVE_0: nXOffset = 9; break; case LS_LIVE_1: nXOffset = 18; break; case LS_FAULT: nXOffset = 27; break; } MemDC.BitBlt(nX+1, nY+1, nLegendWidth, nLegendHeight, &dcBmp, nXOffset, 0, SRCCOPY); nX += nLegendWidth+2; if(nX + nLegendWidth+2 >= rect.Width()) { nY += nLegendHeight+2; nX = 0; } } dcBmp.SelectObject(pOldBmp); //---------------------------------------------------- }
// Sends the bitmap extracted from the View window to a printer of your choice // This function provides a useful reference for printing bitmaps in general void CDoc::Print() { // Get the dimensions of the View window CRect rcView = GetView().GetClientRect(); int Width = rcView.Width(); int Height = rcView.Height(); // Copy the bitmap from the View window CClientDC ViewDC(GetView()); CMemDC MemDC(ViewDC); CBitmap bmView; bmView.CreateCompatibleBitmap(ViewDC, Width, Height); MemDC.SelectObject(bmView); MemDC.BitBlt(0, 0, Width, Height, ViewDC, 0, 0, SRCCOPY); CPrintDialog PrintDlg; try { // Bring up a dialog to choose the printer if (PrintDlg.DoModal(GetView()) == IDOK) // throws exception if there is no default printer { // Zero and then initialize the members of a DOCINFO structure. DOCINFO di; memset(&di, 0, sizeof(DOCINFO)); di.cbSize = sizeof(DOCINFO); di.lpszDocName = _T("Scribble Printout"); di.lpszOutput = (LPTSTR)NULL; di.lpszDatatype = (LPTSTR)NULL; di.fwType = 0; // Begin a print job by calling the StartDoc function. CDC dcPrint = PrintDlg.GetPrinterDC(); if (SP_ERROR == StartDoc(dcPrint, &di)) throw CUserException(_T("Failed to start print job")); // Inform the driver that the application is about to begin sending data. if (0 > StartPage(dcPrint)) throw CUserException(_T("StartPage failed")); BITMAPINFOHEADER bi; ZeroMemory(&bi, sizeof(BITMAPINFOHEADER)); bi.biSize = sizeof(BITMAPINFOHEADER); bi.biHeight = Height; bi.biWidth = Width; bi.biPlanes = 1; bi.biBitCount = 24; bi.biCompression = BI_RGB; // Note: BITMAPINFO and BITMAPINFOHEADER are the same for 24 bit bitmaps // Get the size of the image data MemDC.GetDIBits(bmView, 0, Height, NULL, reinterpret_cast<BITMAPINFO*>(&bi), DIB_RGB_COLORS); // Retrieve the image data std::vector<byte> vBits(bi.biSizeImage, 0); // a vector to hold the byte array byte* pByteArray = &vBits.front(); MemDC.GetDIBits(bmView, 0, Height, pByteArray, reinterpret_cast<BITMAPINFO*>(&bi), DIB_RGB_COLORS); // Determine the scaling factors required to print the bitmap and retain its original proportions. float fLogPelsX1 = (float)ViewDC.GetDeviceCaps(LOGPIXELSX); float fLogPelsY1 = (float)ViewDC.GetDeviceCaps(LOGPIXELSY); float fLogPelsX2 = (float)GetDeviceCaps(dcPrint, LOGPIXELSX); float fLogPelsY2 = (float)GetDeviceCaps(dcPrint, LOGPIXELSY); float fScaleX = MAX(fLogPelsX1, fLogPelsX2) / MIN(fLogPelsX1, fLogPelsX2); float fScaleY = MAX(fLogPelsY1, fLogPelsY2) / MIN(fLogPelsY1, fLogPelsY2); // Compute the coordinates of the upper left corner of the centered bitmap. int cWidthPels = GetDeviceCaps(dcPrint, HORZRES); int xLeft = ((cWidthPels / 2) - ((int)(((float)Width) * fScaleX)) / 2); int cHeightPels = GetDeviceCaps(dcPrint, VERTRES); int yTop = ((cHeightPels / 2) - ((int)(((float)Height) * fScaleY)) / 2); // Use StretchDIBits to scale the bitmap and maintain its original proportions if (GDI_ERROR == (UINT)StretchDIBits(dcPrint, xLeft, yTop, (int)((float)Width * fScaleX), (int)((float)Height * fScaleY), 0, 0, Width, Height, pByteArray, reinterpret_cast<BITMAPINFO*>(&bi), DIB_RGB_COLORS, SRCCOPY)) { throw CUserException(_T("Failed to resize image for printing")); } // Inform the driver that the page is finished. if (0 > EndPage(dcPrint)) throw CUserException(_T("EndPage failed")); // Inform the driver that document has ended. if (0 > EndDoc(dcPrint)) throw CUserException(_T("EndDoc failed")); } } catch (const CException& e) { // Display a message box indicating why printing failed. CString strMsg = CString(e.GetText()) + CString("\n") + e.GetErrorString(); CString strType = CString(e.what()); ::MessageBox(NULL, strMsg, strType, MB_ICONWARNING); } }
void CSkinDialog::OnPaint(CDCHandle dc) { CPaintDC PaintDC(m_hWnd); CRect rcClient; GetClientRect(&rcClient); int cx = 0, cy = 0; if (m_hMemBmp != NULL) { BITMAP bmpInfo = {0}; ::GetObject(m_hMemBmp, sizeof(BITMAP), &bmpInfo); cx = bmpInfo.bmWidth; cy = bmpInfo.bmHeight; } if (rcClient.Width() != cx || rcClient.Height() != cy) { if (m_hMemDC != NULL && m_hMemBmp != NULL) { ::SelectObject(m_hMemDC, m_hOldBmp); ::DeleteObject(m_hMemBmp); } m_hMemBmp = ::CreateCompatibleBitmap(PaintDC.m_hDC, rcClient.Width(), rcClient.Height()); m_hOldBmp = (HBITMAP)::SelectObject(m_hMemDC, m_hMemBmp); } CDCHandle MemDC(m_hMemDC); if (m_lpBgImg != NULL && !m_lpBgImg->IsNull()) // 填充背景图片 { m_lpBgImg->Draw2(MemDC.m_hDC, rcClient); } else // 填充背景颜色 { MemDC.FillSolidRect(&rcClient, m_clrBg); } if (m_lpTitleBarBgImg != NULL && !m_lpTitleBarBgImg->IsNull()) // 填充标题栏背景图片 { m_lpTitleBarBgImg->Draw2(MemDC.m_hDC, m_rcTitleBar); } // HPEN hPen = ::CreatePen(PS_SOLID | PS_INSIDEFRAME, 1, RGB(62, 114, 132)); // HPEN hOldPen = MemDC.SelectPen(hPen); // HBRUSH hOldBrush = MemDC.SelectBrush((HBRUSH)::GetStockObject(NULL_BRUSH)); // MemDC.RoundRect(rcClient.left, rcClient.top, // rcClient.right, rcClient.bottom, 4, 4); // MemDC.SelectPen(hOldPen); // MemDC.SelectBrush(hOldBrush); // ::DeleteObject(hPen); if (m_bHasMinBtn) // 绘制最小化按钮 { if (m_bMinBtnPress) { if (m_lpMinSysBtnImgD != NULL && !m_lpMinSysBtnImgD->IsNull()) m_lpMinSysBtnImgD->Draw(MemDC.m_hDC, m_rcMinBtn); } else if(m_bMinBtnHover) { if (m_lpMinSysBtnImgH != NULL && !m_lpMinSysBtnImgH->IsNull()) m_lpMinSysBtnImgH->Draw(MemDC.m_hDC, m_rcMinBtn); } else { if (m_lpMinSysBtnImgN != NULL && !m_lpMinSysBtnImgN->IsNull()) m_lpMinSysBtnImgN->Draw(MemDC.m_hDC, m_rcMinBtn); } } if (m_bHasMaxBtn) // 绘制最大化按钮 { if (IsZoomed()) // 窗口最大化标志 { if (m_bMaxBtnPress) { if (m_lpRestoreSysBtnImgD != NULL && !m_lpRestoreSysBtnImgD->IsNull()) m_lpRestoreSysBtnImgD->Draw(MemDC.m_hDC, m_rcMaxBtn); } else if(m_bMaxBtnHover) { if (m_lpRestoreSysBtnImgH != NULL && !m_lpRestoreSysBtnImgH->IsNull()) m_lpRestoreSysBtnImgH->Draw(MemDC.m_hDC, m_rcMaxBtn); } else { if (m_lpRestoreSysBtnImgN != NULL && !m_lpRestoreSysBtnImgN->IsNull()) m_lpRestoreSysBtnImgN->Draw(MemDC.m_hDC, m_rcMaxBtn); } } else { if (m_bMaxBtnPress) { if (m_lpMaxSysBtnImgD != NULL && !m_lpMaxSysBtnImgD->IsNull()) m_lpMaxSysBtnImgD->Draw(MemDC.m_hDC, m_rcMaxBtn); } else if(m_bMaxBtnHover) { if (m_lpMaxSysBtnImgH != NULL && !m_lpMaxSysBtnImgH->IsNull()) m_lpMaxSysBtnImgH->Draw(MemDC.m_hDC, m_rcMaxBtn); } else { if (m_lpMaxSysBtnImgN != NULL && !m_lpMaxSysBtnImgN->IsNull()) m_lpMaxSysBtnImgN->Draw(MemDC.m_hDC, m_rcMaxBtn); } } } if (m_bHasCloseBtn) // 绘制关闭按钮 { if (m_bCloseBtnPress) { if (m_lpCloseSysBtnImgD != NULL && !m_lpCloseSysBtnImgD->IsNull()) m_lpCloseSysBtnImgD->Draw(MemDC.m_hDC, m_rcCloseBtn); } else if(m_bCloseBtnHover) { if (m_lpCloseSysBtnImgH != NULL && !m_lpCloseSysBtnImgH->IsNull()) m_lpCloseSysBtnImgH->Draw(MemDC.m_hDC, m_rcCloseBtn); } else { if (m_lpCloseSysBtnImgN != NULL && !m_lpCloseSysBtnImgN->IsNull()) m_lpCloseSysBtnImgN->Draw(MemDC.m_hDC, m_rcCloseBtn); } } int nTitleTextLen = m_strTitleText.GetLength(); if (nTitleTextLen > 0) { //DrawEclosionText(MemDC.m_hDC, m_strTitleText, _T("微软雅黑"), 12); CRect rcText(m_rcTitleBar); rcText.left += 8; NONCLIENTMETRICS nif; //创建标题栏字体对象 nif.cbSize = sizeof(nif); ::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &nif, 0); HFONT hFont = ::CreateFontIndirect(&nif.lfSmCaptionFont); int nMode = ::SetBkMode(MemDC.m_hDC, TRANSPARENT); HFONT hOldFont = (HFONT)::SelectObject(MemDC.m_hDC, hFont); ::DrawText(MemDC.m_hDC, m_strTitleText, nTitleTextLen, &rcText, DT_SINGLELINE | DT_LEFT | DT_VCENTER | DT_END_ELLIPSIS); ::SelectObject(MemDC.m_hDC, hOldFont); ::SetBkMode(MemDC.m_hDC, nMode); ::DeleteObject(hFont); } ::BitBlt(PaintDC.m_hDC, 0, 0, rcClient.Width(), rcClient.Height(), m_hMemDC, 0, 0, SRCCOPY); }
void CSkinPictureBox::OnPaint(CDCHandle dc) { CPaintDC PaintDC(m_hWnd); CRect rcClient; GetClientRect(&rcClient); CMemoryDC MemDC(PaintDC.m_hDC, rcClient); if (m_bTransparent) DrawParentWndBg(MemDC.m_hDC); int nMode = ::SetStretchBltMode(MemDC.m_hDC, HALFTONE); if (m_lpImage != NULL && !m_lpImage->IsNull()) { if (DRAW_MODE_CENTER == m_nDrawMode) { int cx = m_lpImage->GetWidth(); int cy = m_lpImage->GetHeight(); CRect rcCenter; CalcCenterRect(rcClient, cx, cy, rcCenter); m_lpImage->Draw(MemDC.m_hDC, rcCenter); } else if (DRAW_MODE_STRETCH == m_nDrawMode) { m_lpImage->Draw(MemDC.m_hDC, rcClient); } } else if (m_lpGifImage != NULL) { if (DRAW_MODE_CENTER == m_nDrawMode) { int cx = m_lpGifImage->GetWidth(); int cy = m_lpGifImage->GetHeight(); CRect rcCenter; CalcCenterRect(rcClient, cx, cy, rcCenter); m_lpGifImage->Draw(MemDC.m_hDC, rcCenter); } else if (DRAW_MODE_STRETCH == m_nDrawMode) { m_lpGifImage->Draw(MemDC.m_hDC, rcClient); } } ::SetStretchBltMode(MemDC.m_hDC, nMode); if (m_bPress) // 鼠标左键按下状态 { if (m_lpBgImgD != NULL && !m_lpBgImgD->IsNull()) m_lpBgImgD->Draw(MemDC.m_hDC, rcClient); } else if (m_bHover) // 鼠标悬停状态 { if (m_lpBgImgH != NULL && !m_lpBgImgH->IsNull()) m_lpBgImgH->Draw(MemDC.m_hDC, rcClient); } else // 普通状态 { if (m_lpBgImgN != NULL && !m_lpBgImgN->IsNull()) m_lpBgImgN->Draw(MemDC.m_hDC, rcClient); } }
void CSkinSliderCtrl::OnPaint() { CPaintDC dc(this); // device context for painting CRect rcClient; GetClientRect(&rcClient); CMemoryDC MemDC(&dc, rcClient); //绘制背景 DrawParentWndBg(GetSafeHwnd(),MemDC->GetSafeHdc()); // [3/9/2016 Dingshuai] if (m_pBackImg != NULL && !m_pBackImg->IsNull()) { m_pBackImg->DrawImage(&MemDC,0,0,rcClient.Width(),rcClient.Height()); } //绘制轨迹 if ( !IsWindowEnabled() ) { if (m_pDisImg != NULL && !m_pDisImg->IsNull()) { m_pDisImg->DrawImage(&MemDC,0,0); } } else { if (m_pBackImg != NULL && !m_pBackImg->IsNull()) { m_pBackImg->DrawImage(&MemDC,0,0); } } //绘制痕迹 if (m_pTraceImg != NULL && !m_pTraceImg->IsNull()) { m_pTraceImg->DrawImage/*DrawExtrude*/(&MemDC,CRect(0, 0,m_rcThumRect.left,m_pTraceImg->GetHeight())); } if (m_bLoopArrow) { //绘制A,B点 if (m_pAImg != NULL && !m_pAImg->IsNull()) { m_pAImg->DrawImage(&MemDC,m_nArrowLeftPos , -1); } if (m_pBImg != NULL && !m_pBImg->IsNull()) { m_pBImg->DrawImage(&MemDC,m_nArrowRightPos, 0); } } //绘制滑块 if (m_pThumImg != NULL && !m_pThumImg->IsNull()) { m_pThumImg->DrawImage(&MemDC,m_rcThumRect.left, m_rcThumRect.top); } //绘制按钮 if (m_pBtImg != NULL && !m_pBtImg->IsNull()) { if( m_bPress ) m_pBtImg->DrawImage(&MemDC,m_rcThumRect.left, m_rcThumRect.top,m_szThum.cx,m_szThum.cy,m_szThum.cx*2,0,m_pBtImg->GetWidth()/3,m_pBtImg->GetHeight()); else if ( m_bHover ) m_pBtImg->DrawImage(&MemDC,m_rcThumRect.left, m_rcThumRect.top,m_szThum.cx,m_szThum.cy,m_szThum.cx,0,m_pBtImg->GetWidth()/3,m_pBtImg->GetHeight()); else m_pBtImg->DrawImage(&MemDC,m_rcThumRect.left, m_rcThumRect.top,m_szThum.cx,m_szThum.cy,0,0,m_pBtImg->GetWidth()/3,m_pBtImg->GetHeight()); } }