void CTrashSkipCtrl::_OnRealPaint(CDC& memDC) { CRect rcDraw(m_rcClient); _DrawHeader(memDC, rcDraw); rcDraw.top = DEF_HEAD_HEIGHT + DEF_VERT_SPACE; rcDraw.bottom = rcDraw.top + DEF_ITEM_HEIGHT; rcDraw.left = DEF_LEFT_SPACE - (DEF_HORI_SPACE + DEF_ITEM_WIDTH); rcDraw.right = rcDraw.left + DEF_ITEM_WIDTH; for (size_t iCount = 0; iCount < m_vecItems.size(); ++iCount) { if ((rcDraw.right + DEF_RIGHT_SPACE + DEF_ITEM_WIDTH + DEF_HORI_SPACE) <= m_rcClient.right) { rcDraw.left += (DEF_HORI_SPACE + DEF_ITEM_WIDTH); rcDraw.right = rcDraw.left + DEF_ITEM_WIDTH; } else { rcDraw.left = DEF_LEFT_SPACE; rcDraw.top += DEF_ITEM_HEIGHT + DEF_VERT_SPACE; rcDraw.right = rcDraw.left + DEF_ITEM_WIDTH; rcDraw.bottom = rcDraw.top + DEF_ITEM_HEIGHT; } _DrawSoftItem(memDC, rcDraw, (int)iCount); } }
void CTrashCleanCtrl::_DrawTextInfor(CDC& dc, CRect& rcItem, LPTRASH_ITEM lpItem) { CRect rcDraw(rcItem); HFONT hFont = KuiFontPool::GetFont(TRUE, FALSE, FALSE); if (lpItem->bShowDetail) { _DrawText(dc, rcDraw, lpItem->strItemName, DEF_TRASH_DEFAULT_TEXT_CLR, hFont); ::CopyRect(lpItem->rcText, rcDraw); } else { rcDraw.top += (rcItem.Height() / 2) - (DEF_ICON_HEIGHT / 2); rcDraw.bottom = rcItem.top + (rcItem.Height() / 2); _DrawText(dc, rcDraw, lpItem->strItemName, DEF_TRASH_DEFAULT_TEXT_CLR, hFont); CRect rcBrief(rcItem); HFONT briefFont = KuiFontPool::GetFont(FALSE, FALSE, FALSE); rcBrief.top += (rcItem.Height() / 2) + 3; rcBrief.bottom = rcItem.top + (rcItem.Height() / 2) + (DEF_ICON_HEIGHT / 2); _DrawText(dc, rcBrief, lpItem->strBrief, DEF_TRASH_DETAIL_TEXT_CLR, briefFont); } // 绘制信息 rcDraw.left = rcDraw.right; rcDraw.right = lpItem->rcBox.right; _DrawItemStatus(dc, rcDraw, lpItem); }
HRESULT CImageImpl::RenderFrame(HDC hDC, UINT uFrame, LPCRECT pDstRect) { USE_CLASS_DATA(CLASS_DATA_MEMBER_LIST); if (m_pBitmap == NULL) return S_FALSE; try { GUID guidGif = Gdiplus::FrameDimensionTime; m_pBitmap->SelectActiveFrame(&guidGif, uFrame); CRect dstRect = *pDstRect; Gdiplus::Rect rcDraw(dstRect.left, dstRect.top, (dstRect.right - dstRect.left), (dstRect.bottom - dstRect.top)); Gdiplus::Graphics graphics(hDC); Gdiplus::Status ret = graphics.DrawImage(m_pBitmap, rcDraw); if (ret == Gdiplus::Ok) return S_OK; } catch (...) { return S_FALSE; } return S_FALSE; }
extern "C" BOOL WINAPI QHTM_GetHTMLHeight( HDC hdc, LPCTSTR pcsz, HINSTANCE hInst, UINT uFlags, UINT uWidth, UINT *lpuHeight ) { g_HTMLBoardWidth = uWidth; #ifdef QHTM_ALLOW_RENDER if( !IsBadWritePtr( lpuHeight, sizeof( UINT ) ) ) { if( lpuHeight && pcsz && hdc ) { CHTMLSection sectHTML( &g_defaults ); if( uFlags & QHTM_RENDER_FLAG_TRANSPARENT ) { sectHTML.Transparent( true ); } uFlags = uFlags & 3; switch( uFlags ) { case QHTM_SOURCE_TEXT: sectHTML.SetHTML( pcsz, _tcslen( pcsz ), NULL ); break; case QHTM_SOURCE_RESOURCE: if( !sectHTML.SetHTML( hInst, pcsz ) ) { return FALSE; } break; case QHTM_SOURCE_FILENAME: if( !sectHTML.SetHTMLFile( pcsz ) ) { return FALSE; } break; } WinHelper::CRect rcDraw( 0, 0, uWidth, 5 ); GS::CDrawContext dc( NULL, hdc, true ); sectHTML.OnLayout( rcDraw, dc ); const WinHelper::CSize size( sectHTML.GetSize() ); *lpuHeight = size.cy; return TRUE; } } #else // QHTM_ALLOW_RENDER UNREFERENCED_PARAMETER( hdc ); UNREFERENCED_PARAMETER( pcsz ); UNREFERENCED_PARAMETER( hInst ); UNREFERENCED_PARAMETER( uFlags ); UNREFERENCED_PARAMETER( uWidth ); UNREFERENCED_PARAMETER( lpuHeight ); #endif // QHTM_ALLOW_RENDER return FALSE; }
void CTrashCleanCtrl::_DrawItemIcon(CDC& dc, CRect& rcItem, LPTRASH_ITEM lpItem) { CRect rcDraw(rcItem); rcDraw.top = rcItem.top + (rcItem.Height() / 2 - DEF_ICON_HEIGHT / 2); m_iconList.Draw(dc, lpItem->nIconID, rcDraw.left, rcDraw.top, TRANSPARENT); lpItem->rcIcon.left = rcDraw.left; lpItem->rcIcon.right = rcDraw.left + DEF_ICON_HEIGHT; lpItem->rcIcon.top = rcDraw.top; lpItem->rcIcon.bottom = rcDraw.top + DEF_ICON_HEIGHT; }
void CGIFControl::DrawBorder(Graphics& g) { if(!m_bBorderEnable) { return; } CRect rcClient; GetClientRect(&rcClient); //准备绘制 Rect rcDraw(rcClient.left,rcClient.top,rcClient.Width(),rcClient.Height()); SolidBrush bs(m_cBorder); g.FillRectangle(&bs,rcDraw); }
void CWmfShape::OnPaint() { CPaintDC dc(this); // device context for painting CRect rcClient; CRgn rgClip; GetClientRect( &rcClient ); rgClip.CreateRectRgnIndirect( &rcClient ); dc.SelectClipRgn( &rgClip, RGN_AND ); if( NULL != m_pMetaFile ) { CPoint ptZero( rcClient.left, ( rcClient.bottom + rcClient.top ) / 2 ); CDRect rcDraw( 0, 0, m_szPict.cx, m_szPict.cy ); m_pMetaFile->Play( &dc, m_rcDraw, &ptZero, m_bSwapX, m_bSwapY ); } DrawOffset( &dc ); // Do not call CStatic::OnPaint() for painting messages }
void CTrashCleanCtrl::_DrawItemBKGround(CDC& dc, CRect& rcItem, LPTRASH_ITEM lpItem) { CRect rcDraw(rcItem); if (lpItem->bShowDetail) { dc.FillSolidRect(&rcDraw, RGB(245, 250, 254)); } else { if (m_nHoverIndex == lpItem->uItemId) { dc.FillSolidRect(&rcDraw, RGB(245, 250, 254)); } // 绘制分割线 _DrawLine(dc, CPoint(rcItem.left, rcItem.bottom-1), CPoint(rcItem.right, rcItem.bottom-1), RGB(227,237,247), PS_SOLID); } }
// This method is called whenever the mouse moves, it works out which item is under the mouse, and stores it's ID for use if // the click occurs, in which case it's used to send the command to the main window. void COXHyperBarRender::SetActiveItem(POINT pt) { CImageList * const pImages = m_pToolbar->GetToolBarCtrl().GetImageList(); RECT rect; m_pToolbar->GetClientRect(&rect); RECT * pRect = ▭ const int width = pRect->right - pRect->left; const int height = pRect->bottom - pRect->top; const int imageCount = pImages->GetImageCount(); const int buttonWidth = (int)floor(width/(double)imageCount); const int buttonCount = m_pToolbar->GetToolBarCtrl().GetButtonCount(); // It's reset every time this method is called. m_nCmd = -1; for(int j=0;j<buttonCount;++j) { TBBUTTON btn; m_pToolbar->GetToolBarCtrl().GetButton(j, &btn); IMAGEINFO iif; pImages->GetImageInfo(btn.iBitmap, &iif); const int imgWidth = iif.rcImage.right - iif.rcImage.left; const int imgHeight = iif.rcImage.bottom - iif.rcImage.top; POINT ptDraw; ptDraw.x = buttonWidth * btn.iBitmap + (buttonWidth - imgWidth)/2; ptDraw.y = (height - imgHeight)/2; CRect rcDraw(ptDraw.x, ptDraw.y, imgWidth + ptDraw.x, ptDraw.y + imgHeight + 20); // We've found a match. if (PtInRect(&rcDraw, pt)) { m_nCmd = btn.idCommand; break; } } }
void CTrashCleanCtrl::_DrawDetailItem(CDC& dc, CRect& rcItem, LPTrashDetailItem lpDetailItem) { CRect rcDraw(rcItem); COLORREF clrText = DEF_TRASH_DETAIL_TEXT_CLR; HFONT hFont = KuiFontPool::GetFont(FALSE, FALSE, FALSE); rcDraw.left = rcItem.left; rcDraw.top = m_nTotalHeight; rcDraw.bottom = rcDraw.top + DEF_DETAIL_ITEM_HEIGHT; rcDraw.right = m_rcClient.right; _DrawCheckBox(dc, rcDraw, lpDetailItem->rcCheck, lpDetailItem); rcDraw.left = lpDetailItem->rcCheck.right + DEF_CHECK_TO_TEXT - 3; rcDraw.top = m_nTotalHeight - 3; rcDraw.bottom = rcDraw.top + DEF_DETAIL_ITEM_HEIGHT + 6; rcDraw.right = m_rcClient.right - 40; ::CopyRect(lpDetailItem->rcSelected, rcDraw); if (m_nSelectedIndex == lpDetailItem->nItemId) { _DrawSelectedBox(dc, rcDraw, lpDetailItem); clrText = RGB(0,0,0); } else if (m_nHoverIndex == lpDetailItem->nItemId) { _DrawHoverBox(dc, rcDraw, lpDetailItem); } rcDraw.left = lpDetailItem->rcCheck.right + DEF_CHECK_TO_TEXT; rcDraw.top = m_nTotalHeight; rcDraw.bottom = rcDraw.top + DEF_DETAIL_ITEM_HEIGHT; rcDraw.right = m_rcClient.right; _DrawText(dc, rcDraw, lpDetailItem->strName, clrText, hFont); lpDetailItem->rcCheck.right = rcDraw.right; // 根据状态 绘制 _DrawDetailItemStatus(dc, rcDraw, lpDetailItem); }
void SClock::OnPaint(SOUI::IRenderTarget * pRT) { SWindow::OnPaint(pRT); CRect rcClient; GetClientRect(&rcClient); CPoint center = rcClient.CenterPoint(); // 计算矩形 // 35 * 16 CRect rcDraw(center, SOUI::CPoint(center.x + 200, center.y + 32)); rcDraw.OffsetRect(-35, -16); CRect rcSrc(0, 0, 200, 32); SYSTEMTIME last_refresh_time; ::GetLocalTime(&last_refresh_time); { double angle = GetHourAngle(last_refresh_time.wHour,last_refresh_time.wMinute); SMatrix form = InitMatrix(angle, center); pRT->SetTransform(&form, NULL); pRT->DrawBitmapEx(rcDraw, pointer_hour, &rcSrc, EM_STRETCH, 255); } { double angle = GetMinuteSecondAngle(last_refresh_time.wMinute); SMatrix form = InitMatrix(angle, center); pRT->SetTransform(&form, NULL); pRT->DrawBitmapEx(rcDraw, pointer_minute, &rcSrc, EM_STRETCH, 255); } { double angle = GetMinuteSecondAngle(last_refresh_time.wSecond); SMatrix form = InitMatrix(angle, center); pRT->SetTransform(&form, NULL); pRT->DrawBitmapEx(rcDraw, pointer_second, &rcSrc, EM_STRETCH, 255); } pRT->SetTransform(&SMatrix()); }
void CTrashSkipCtrl::OnPaint(CDCHandle dcHandle) { CPaintDC dc(m_hWnd); CBitmap memBmp; CDC memDC; CRect rcDraw(m_rcRealClient); memDC.CreateCompatibleDC(dc.m_hDC); memBmp.CreateCompatibleBitmap(dc.m_hDC, rcDraw.Width(), rcDraw.Height()); memDC.SetBkMode(TRANSPARENT); SelectObject(memDC, memBmp); memDC.FillSolidRect(rcDraw, RGB(0xff, 0xff, 0xff)); _OnRealPaint(memDC); m_nHeight = int((m_rcRealClient.Height() - m_rcClient.Height()) * (m_nPos * 1.0) / (m_rcRealClient.Height())); dc.BitBlt(0, 0, m_rcClient.Width(), m_rcClient.Height(), memDC.m_hDC, 0, m_nHeight, SRCCOPY); ReleaseDC(memDC); }
void CTrashCleanCtrl::OnPaint(CDCHandle /*dcHandle*/) { CPaintDC dc(m_hWnd); CBitmap memBmp; CDC memDC; CRect rcClient(m_rcClient); CString str; // str.Format(L"paint times is %d\n", counter++); // OutputDebugStr(str); // dc.FillSolidRect(m_rcRealClient, RGB(255, 255, 255)); if (m_vecTrashItems.size() <= 0) { CString strWait = L"正在加载,请稍候..."; HFONT hFont = KuiFontPool::GetFont(FALSE, FALSE, FALSE); HFONT oldFont = dc.SelectFont(hFont); CRect rcDraw(m_rcClient); rcDraw.top += 50; dc.FillSolidRect(m_rcRealClient, RGB(255, 255, 255)); dc.DrawText(strWait, strWait.GetLength(), &rcDraw, DT_CENTER | DT_VCENTER); dc.SelectFont(oldFont); return; } memDC.CreateCompatibleDC(dc.m_hDC); memBmp.CreateCompatibleBitmap(dc.m_hDC, m_rcRealClient.Width(), m_rcRealClient.Height()); memDC.SetBkMode(TRANSPARENT); SelectObject(memDC, memBmp); memDC.FillSolidRect(m_rcRealClient, RGB(255, 255,255)); _OnRealPaint(memDC); m_nHeight = int((m_rcRealClient.Height() - m_rcClient.Height()) * (m_nPos * 1.0) / (m_rcRealClient.Height())); dc.BitBlt(0, 0, m_rcClient.Width(), m_rcClient.Height(), memDC, 0, m_nHeight, SRCCOPY); ReleaseDC(memDC); }
void CTrashCleanCtrl::_DrawCheckDetail(CDC& dc, CRect& rcItem, LPTrashDetailItem lpDetailItem) { HFONT hFont = KuiFontPool::GetFont(FALSE, TRUE, FALSE); CRect rcDraw(rcItem); COLORREF clrText; CString strText = KAppRes::Instance().GetString("IDS_TRASH_CHECK_DETAIL"); // 查看详情 if (lpDetailItem->bInDetail && m_nHoverIndex == lpDetailItem->nItemId) { clrText = RGB(255, 23, 23); } else { clrText = RGB(77, 112, 150); } rcDraw.left = rcDraw.right - 70; _DrawText(dc, rcDraw, strText, clrText, hFont); ::CopyRect(lpDetailItem->rcDetail, rcDraw); }
extern "C" BOOL WINAPI QHTM_RenderHTML( HDC hdc, LPCTSTR pcsz, HINSTANCE hInst, UINT uFlags, UINT uWidth ) { g_HTMLBoardWidth = uWidth; #ifdef QHTM_ALLOW_RENDER if( pcsz && hdc ) { CHTMLSection sectHTML( &g_defaults ); if( uFlags & QHTM_RENDER_FLAG_TRANSPARENT ) { sectHTML.Transparent( true ); } uFlags = uFlags & 3; switch( uFlags ) { case QHTM_SOURCE_TEXT: sectHTML.SetHTML( pcsz, _tcslen( pcsz ), NULL ); break; case QHTM_SOURCE_RESOURCE: if( !sectHTML.SetHTML( hInst, pcsz ) ) { return FALSE; } break; case QHTM_SOURCE_FILENAME: if( !sectHTML.SetHTMLFile( pcsz ) ) { return FALSE; } break; } WinHelper::CRect rcDraw( 0, 0, uWidth, 5 ); // // Needs to be scoped because firstly we are just measuring and this doesn't require a clip rect { GS::CDrawContext dc( NULL, hdc, true ); sectHTML.OnLayout( rcDraw, dc ); } const WinHelper::CSize size( sectHTML.GetSize() ); rcDraw.bottom = size.cy; // // Now we know the size, we can pass this into the clip rect. { GS::CDrawContext dc( &rcDraw, hdc, true ); sectHTML.OnLayout( rcDraw, dc ); SelectPalette( hdc, GS::GetCurrentWindowsPalette(), TRUE ); RealizePalette( hdc ); sectHTML.OnDraw( dc ); } return TRUE; } #else // QHTM_ALLOW_RENDER UNREFERENCED_PARAMETER( hdc ); UNREFERENCED_PARAMETER( pcsz ); UNREFERENCED_PARAMETER( hInst ); UNREFERENCED_PARAMETER( uFlags ); UNREFERENCED_PARAMETER( uWidth ); #endif // QHTM_ALLOW_RENDER return FALSE; }
void COXHyperBarRender::RenderToolbar(CDC * pDC, RECT * pRect, SIZE szBtn, POINT * pMouse, CBitmap * pOverlay) { // The first time this is run after the toolbar is set up, // call the method to fill the array of image data if (!m_buttonInfo) { if(m_pToolbar->GetToolBarCtrl().m_hWnd && m_pToolbar->GetToolBarCtrl().GetButtonCount()) { Initialise(szBtn); } else return; } CImageList * const pImages = m_pToolbar->GetToolBarCtrl().GetImageList(); const int width = pRect->right - pRect->left; const int height = pRect->bottom - pRect->top; // Create the bitmap used as a double buffer if (!m_buffer) { m_buffer = new CBitmap(); // The buffer will be created when the mouse is not over the toolbar m_buffer->CreateCompatibleBitmap(pDC, width, height+(COXHyperBar::OffsetY * 2)); } CDC dc; dc.CreateCompatibleDC(pDC); CBitmap * pOld = dc.SelectObject(m_buffer); // offset is the amount of space around each button const int offset = 4; const int buttonCount = m_pToolbar->GetToolBarCtrl().GetButtonCount(); RECT rc; rc.right = width; rc.bottom = height; rc.top = rc.left = 0; // Reset the command, it will be set again if our mouse is over a button in the code below m_nCmd = -1; // This variable is used to accumulate the current position as we draw the buttons POINT ptDraw; ptDraw.x = ptDraw.y = 0; // We need to do this in two parts: // 1 - create a bitmap which has the overlay as a background and then the buttons drawn in the right positions // 2 - use the AlphaBlend function to blend this toolbar onto our device context. // The reason for this is that we need to use the Image List to draw the buttons transparently first, // then we need to do the alpha blend after that. CDC imageListDC; imageListDC.CreateCompatibleDC(pDC); CBitmap imageListBitmap; imageListBitmap.CreateCompatibleBitmap(pDC, width, height); imageListDC.SetStretchBltMode(COLORONCOLOR); dc.SetStretchBltMode(COLORONCOLOR); CBitmap * pOldImageList = imageListDC.SelectObject(&imageListBitmap); // If pOverlay != NULL, then draw the pOverlay onto both the buffer bitmap, and the bitmap that will be the source for alpha blending. if (pOverlay) { CDC dcBmp; dcBmp.CreateCompatibleDC(&dc); CBitmap * pOld = dcBmp.SelectObject(pOverlay); imageListDC.BitBlt(0, 0, width, height, &dcBmp, 0, 0, SRCCOPY); dc.BitBlt(0, 0, width, height, &dcBmp, 0, 0, SRCCOPY); dcBmp.SelectObject(&pOld); } // rcBar becomes the rectangle we use to know the position of the toolbar within our CDC CRect rcBar = rc; if (pOverlay) { rcBar.InflateRect(0, -(COXHyperBar::OffsetY + 2)); } ((COXHyperBar*)m_pToolbar)->RenderBackground(&dc, &rcBar); ((COXHyperBar*)m_pToolbar)->RenderBackground(&imageListDC, rcBar); double * hypers = new double[buttonCount]; double hyperTotal = 0.0; for(int j=0;j<buttonCount;++j) { // Skip seperators, which would otherwise kill the spacing, etc. if (!m_buttonInfo[j].commandID) { hypers[j] = 0; continue; } double distanceFromDOI = ColumnDistanceFromDOI(j, buttonCount, width, pMouse); // Plug the distance from zero (the DOI itself is at zero) into the hyperbolic function. // .05 -> .4 Focus hypers[j] = ValueAtX(distanceFromDOI, m_Focus); hyperTotal += hypers[j]; } double factor = width/hyperTotal; for(int n=0;n<buttonCount;++n) { double distanceFromDOI = ColumnDistanceFromDOI(n, buttonCount, width, pMouse); double hyperbolic = hypers[n]; // commandID is 0 for non buttons. if (!m_buttonInfo[n].commandID) continue; int alpha = 255; if (pMouse) { // The second param is always 1 alpha = (int) (ValueAtX(distanceFromDOI, m_Focus) * 255); } // If we're not drawing the overlay window, we nust draw at the default width int imgWidth = (pMouse) ? (int)(factor * hyperbolic) - offset * 2 : m_buttonInfo[n].width ; int imgHeight = (pMouse)?(int)(m_buttonInfo[n].height * factor/m_buttonInfo[n].width * hyperbolic) : m_buttonInfo[n].height ; ptDraw.x += offset; ptDraw.y = (height - imgHeight)/2; POINT pt; pt.x = pt.y = 0; // Draw the whole toolbar image SIZE szDraw; szDraw.cx = szDraw.cy = 0; CDC itemDC; itemDC.CreateCompatibleDC(&dc); CBitmap itemBitmap; itemBitmap.CreateCompatibleBitmap(&dc, m_buttonInfo[n].defaultWidth, m_buttonInfo[n].defaultHeight); CBitmap * pOldItemBitmap = itemDC.SelectObject(&itemBitmap); itemDC.FillSolidRect(0, 0, m_buttonInfo[n].defaultWidth, m_buttonInfo[n].defaultHeight, RGB(255,0,255)); pImages->Draw(&itemDC, m_buttonInfo[n].bitmapIndex, pt, ILD_TRANSPARENT); if (pMouse) { // Check if this is the active button CRect rcDraw(ptDraw.x, ptDraw.y, imgWidth + ptDraw.x, ptDraw.y + imgHeight); if (PtInRect(&rcDraw, *pMouse)) { m_nCmd = m_buttonInfo[n].commandID; } } // Draw the button transparently onto the image list render DC TransparentBlt(imageListDC, ptDraw.x, ptDraw.y, imgWidth, imgHeight, itemDC, 0, 0, m_buttonInfo[n].defaultWidth, m_buttonInfo[n].defaultHeight, RGB(255, 0, 255)); // Now blend it back across the main DC BLENDFUNCTION bf; bf.AlphaFormat = 0; bf.BlendFlags = 0; bf.BlendOp = 0; bf.SourceConstantAlpha = (BYTE)alpha; AlphaBlend(dc, ptDraw.x, ptDraw.y, imgWidth, imgHeight, imageListDC, ptDraw.x, ptDraw.y, imgWidth, imgHeight, bf); itemDC.SelectObject(pOldItemBitmap); ptDraw.x += offset + imgWidth; } pDC->BitBlt(0, 0, width, height, &dc, 0, 0, SRCCOPY); imageListDC.SelectObject(pOldImageList); dc.SelectObject(pOld); delete [] hypers; // Once the paint has occurred, set the flag to say if we drew over the main toolbar, or the floating window. ((COXHyperBar*)m_pToolbar)->m_bHasRedrawn = (pMouse == NULL); }
//绘画界面 void CGameClientView::DrawGameView(CDC * pDC, int nWidth, int nHeight) { //绘画背景 DrawViewImage(pDC,m_ImageViewFill,enMode_Spread); DrawViewImage(pDC,m_ImageViewBack,enMode_Centent); //绘画用户 TCHAR szBuffer[64]=TEXT(""); for (WORD i=0;i<GAME_PLAYER;i++) { //变量定义 WORD wUserTimer=GetUserTimer(i); const tagUserData * pUserData=GetUserInfo(i); //test //WORD wUserTimer = 30; //tagUserData *pUserData = new tagUserData; //lstrcpy(pUserData->szName,TEXT("测试玩家")); //pUserData->lScore = 10000L; //pUserData->cbUserStatus = US_READY; //绘画用户 if (pUserData!=NULL) { //用户名字 pDC->SetTextAlign(((i==0)||(i==1))?TA_RIGHT:TA_LEFT); DrawTextString(pDC,pUserData->szName,RGB(255,255,255),RGB(0,0,0),m_ptName[i].x,m_ptName[i].y); //用户金币 LONG lLeaveScore=pUserData->lScore-((pUserData->cbUserStatus==US_PLAY)?m_lTableScore[i]:0); _snprintf(szBuffer,CountArray(szBuffer),TEXT("%ld"),lLeaveScore); DrawTextString(pDC,szBuffer,RGB(255,255,255),RGB(0,0,0),m_ptName[i].x,m_ptName[i].y+16); //当前下注 if( m_lTableScore[i] > 0L ) { if( i == 2 ) pDC->SetTextAlign(TA_RIGHT); _snprintf(szBuffer,CountArray(szBuffer),TEXT("已下注%ld"),m_lTableScore[i]); DrawTextString(pDC,szBuffer,RGB(255,255,255),RGB(0,0,0),m_ptTableScore[i].x,m_ptTableScore[i].y); } //其他信息 if (wUserTimer!=0) DrawUserTimer(pDC,m_ptTimer[i].x,m_ptTimer[i].y,wUserTimer); if (pUserData->cbUserStatus==US_READY) DrawUserReady(pDC,m_ptReady[i].x,m_ptReady[i].y); DrawUserFace(pDC,pUserData,m_ptFace[i].x,m_ptFace[i].y,pUserData->cbUserStatus==US_OFFLINE); } //delete pUserData; //玩家筹码 m_PlayerJeton[i].DrawJettonControl(pDC); //筹码数字 LONG lJetonScore = m_PlayerJeton[i].GetScore(); if( lJetonScore > 0L ) { CPoint pt = m_PlayerJeton[i].GetBenchmarkPos(); CRect rcDraw(pt.x-50,pt.y+15,pt.x+50,pt.y+27); _snprintf(szBuffer,CountArray(szBuffer),TEXT("%ld"),lJetonScore); pDC->SetTextAlign(TA_LEFT); DrawTextString(pDC,szBuffer,RGB(255,255,85),RGB(0,0,0),&rcDraw); } } m_PlayerJeton[GAME_PLAYER].DrawJettonControl(pDC); //绘画扑克 if (m_SendCardItemArray.GetCount()>0) { //变量定义 CImageHandle HandleCard(&m_ImageCard); tagSendCardItem * pSendCardItem=&m_SendCardItemArray[0]; //获取大小 int nItemWidth=m_ImageCard.GetWidth()/13; int nItemHeight=m_ImageCard.GetHeight()/5; //绘画扑克 m_ImageCard.AlphaDrawImage(pDC,m_SendCardCurPos.x,m_SendCardCurPos.y,nItemWidth,nItemHeight,nItemWidth*2,nItemHeight*4,RGB(255,0,255)); } //test //CImageHandle HandleCard(&m_ImageCard); //m_ImageCard.AlphaDrawImage(pDC,m_SendCardPos.x,m_SendCardPos.y,m_ImageCard.GetWidth()/13,m_ImageCard.GetHeight()/5, // m_ImageCard.GetWidth()/13*2,m_ImageCard.GetHeight()/5*4,RGB(255,0,255)); INT nNumberWidth = m_PngNumber.GetWidth()/10; INT nNumberHeight = m_PngNumber.GetHeight(); //底注信息 if( m_lCellScore > 0L ) { INT nXPos; INT nYPos = nHeight/2-325; int nCellCount = 0; BYTE byCell[10]; LONG lCellScore = m_lCellScore; while( lCellScore > 0L ) { byCell[nCellCount++] = (BYTE)(lCellScore-lCellScore/10*10); lCellScore /= 10; if( nCellCount == 10 ) break; } nXPos = nWidth/2-200-nCellCount*nNumberWidth/2; for( int j = nCellCount-1; j >= 0; j-- ) { m_PngNumber.DrawImage(pDC,nXPos,nYPos,nNumberWidth,nNumberHeight,byCell[j]*nNumberWidth,0); nXPos += nNumberWidth; } } //计算总注 LONG lTableScore=0L; //注:包括正在下注在内 for(int i = 0; i < GAME_PLAYER; i++ ) lTableScore += m_PlayerJeton[i].GetScore(); lTableScore+=m_PlayerJeton[GAME_PLAYER].GetScore(); //test //lTableScore = 1234567L; //总注信息 if (lTableScore>0L) { INT nXPos = nWidth/2+18; INT nYPos = nHeight/2-295; int nCellCount = 0; BYTE byCell[10]; while( lTableScore > 0L ) { byCell[nCellCount++] = (BYTE)(lTableScore-lTableScore/10*10); lTableScore /= 10; if( nCellCount == 10 ) break; } for( int j = nCellCount-1; j >= 0; j-- ) { m_PngNumber.DrawImage(pDC,nXPos,nYPos,nNumberWidth,nNumberHeight,byCell[j]*nNumberWidth,0); nXPos += nNumberWidth; } } return; }
HRESULT CImageImpl::Render(HDC hDC, LPCRECT pDstRect, LPCRECT pSrcRect, LPCRECT pBoundRect) { USE_CLASS_DATA(CLASS_DATA_MEMBER_LIST); UNREFERENCED_PARAMETER(pSrcRect); UNREFERENCED_PARAMETER(pBoundRect); if (m_pImage == NULL) return S_FALSE; BOOL bGray = m_pImage->IsGrayScale(); UINT uFrames = 0; if (S_OK == GetNumFrames(&uFrames) && uFrames > 1) { if (bGray) { //填充白色 HBRUSH hBrush = ::CreateSolidBrush(RGB(255, 255, 255)); ::FillRect(hDC, pDstRect, hBrush); ::DeleteObject(hBrush); try { //去alpha矩阵,未实现 static Gdiplus::ColorMatrix removeAlphaMatrix = { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, }; //去色矩阵 static Gdiplus::ColorMatrix grayMatrix = { 0.3f, 0.3f, 0.3f, 0.0f, 0.0f, 0.59f, 0.59f, 0.59f, 0.0f, 0.0f, 0.11f, 0.11f, 0.11f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, }; //选择第一帧 GUID guidGif = Gdiplus::FrameDimensionTime; m_pBitmap->SelectActiveFrame(&guidGif, 0); CRect dstRect = *pDstRect; Gdiplus::Rect rcDraw(dstRect.left, dstRect.top, (dstRect.right - dstRect.left), (dstRect.bottom - dstRect.top)); Gdiplus::Graphics graphics(hDC); Gdiplus::ImageAttributes *pImageAttributes = new Gdiplus::ImageAttributes(); pImageAttributes->SetColorMatrix(&grayMatrix); Gdiplus::Status ret = graphics.DrawImage(m_pBitmap, rcDraw, 0, 0, m_pBitmap->GetWidth(), m_pBitmap->GetHeight(), Gdiplus::UnitPixel, pImageAttributes); delete pImageAttributes; if (ret == Gdiplus::Ok) return S_OK; } catch (...) { } } else { //填充白色 ::FillRect(hDC, pDstRect, (HBRUSH)::GetStockObject(WHITE_BRUSH)); if (S_OK == RenderFrame(hDC, 0, pDstRect)) return S_OK; } } if (! m_pImage->AlphaIsValid()) { if (! m_pImage->Stretch(hDC, *pDstRect)) return S_FALSE; } else { if (! m_pImage->Draw(hDC, *pDstRect)) return S_FALSE; } return S_OK; }
void CStatisticDlg::DrawVariogram(CDC* pDC, CRect& rc, int band, float& fMean, float& fStandDeviation, std::vector<float>& bandVariogram, drawParam& dp) { if (bandVariogram.empty()) return; // init CPen* pFrameLine = new CPen(PS_SOLID, 1, RGB(0, 0, 0)); CPen* pOldPen = pDC->SelectObject(pFrameLine); CFont* pOldFont = pDC->SelectObject(m_pFont); COLORREF oldColor = pDC->SetTextColor(RGB(0, 0, 0)); //COLORREF oldBkg = pDC->SetBkColor(RGB(255, 255, 255)); CRect rcDraw(rc); rcDraw.DeflateRect(1, 1, 1, 1); CRect rcTemp1, rcTemp2; pDC->DrawText(_T("(lag in pixels)"), &rcTemp1, DT_CALCRECT); pDC->DrawText(_T("(semi-variance 1/2)"), &rcTemp2, DT_CALCRECT); rcDraw.DeflateRect(rcTemp2.Width() + 2, 0, rcTemp1.Width() + 2, 0); LOGFONT lf; m_pFont->GetLogFont(&lf); CRect rcLabel, rcX, rcY, rcChart; // label rcLabel = rcDraw; rcLabel.bottom = rcLabel.top + abs(lf.lfHeight) + 2; CRect rcTemp; pDC->DrawText(_T("00.000"), &rcTemp, DT_CALCRECT); // x rcX = rcDraw; rcX.top = rcDraw.bottom - abs(lf.lfHeight) - 2; // y rcY = rcDraw; rcY.top= rcLabel.bottom + 1; rcY.right = rcY.left + rcTemp.Width();; rcY.bottom = rcX.top - 1; rcX.left = rcY.right + 1; rcLabel.left = rcY.right + 1; // chart rcChart = rcDraw; rcChart.left = rcY.right + 1; rcChart.top = rcLabel.bottom + 1; rcChart.bottom = rcX. top - 1; //pDC->FillSolidRect(rcDraw, RGB(255, 0, 0)); //pDC->FillSolidRect(rcLabel, RGB(255, 0, 0)); //pDC->FillSolidRect(rcX, RGB(0, 255, 0)); //pDC->FillSolidRect(rcY, RGB(0, 0, 255)); //pDC->FillSolidRect(rcChart, RGB(0, 0, 0)); //return; // draw // label CString strLabel; strLabel.Format(_T("band%d --- mean: %.2f, SD: %.2f"), band+1, fMean, fStandDeviation); pDC->DrawText(strLabel, rcLabel, DT_SINGLELINE|DT_CENTER); int y = 0; CRect rcYAxis = rcLabel; CRect rcTemp3; rcYAxis.right = rcY.right - 1; rcYAxis.left = rcYAxis.right - rcTemp2.Width() - 1; pDC->DrawText(_T("(semi-variance "), &rcTemp3, DT_CALCRECT); pDC->DrawText(_T("(semi-variance "), rcYAxis, DT_SINGLELINE|DT_LEFT); rcYAxis.left += rcTemp3.Width(); // change font; pDC->SelectObject(m_pFontSmall); pDC->DrawText(_T("1/2"), &rcTemp3, DT_CALCRECT); pDC->DrawText(_T("1/2"), rcYAxis, DT_SINGLELINE|DT_LEFT); rcYAxis.left += rcTemp3.Width(); // change font pDC->SelectObject(m_pFont); pDC->DrawText(_T(")"), rcYAxis, DT_SINGLELINE|DT_LEFT); // y float f = rcY.Height() / (float)5.0; rcTemp = rcY; rcTemp.bottom = (int)(rcTemp.top + f); for (int i = 0; i < 5; i++) { CString str; str.Format(_T("%.2f"), dp.fMax *(1 - i / 5.0)); pDC->DrawText(str, rcTemp, DT_SINGLELINE|DT_RIGHT); rcTemp.top += f; rcTemp.bottom += f; } // x f = rcX.Width() / (float)5.0; rcTemp = rcX; for (int i = 0; i <= 5; i++) { CString str; str.Format(_T("%d"), (int)(dp.iMax * i / 5.0)); CRect rcMid; pDC->DrawText(str, rcMid, DT_SINGLELINE|DT_CALCRECT); if (i == 0) pDC->DrawText(str, rcX, DT_SINGLELINE|DT_LEFT); else if (i == 5) pDC->DrawText(str, rcX, DT_SINGLELINE|DT_RIGHT); else { CRect rcx = rcTemp; rcx.MoveToX(rcTemp.left - rcMid.Width() / 2); pDC->DrawText(str, rcx, DT_SINGLELINE|DT_LEFT); } rcTemp.left += f; rcTemp.right = rcTemp.left + f + 1; } CRect rcXAxis = rcX; rcXAxis.MoveToX(rcX.right + 10); rcXAxis.right = rcXAxis.right + rcTemp1.Width(); pDC->DrawText(_T("(lag in pixels)"), rcXAxis, DT_SINGLELINE|DT_LEFT); // chart pDC->MoveTo(rcChart.left, rcChart.top); pDC->LineTo(rcChart.left, rcChart.bottom); pDC->LineTo(rcChart.right, rcChart.bottom); int iHeight = rcChart.Height() - 2; int iWidth = rcChart.Width() - 2; int iCount = (int)bandVariogram.size(); CPoint ptStart; ptStart.x = rcChart.left + (int)((float)iWidth / (float)iCount); ptStart.y = rcChart.bottom - (int)(bandVariogram[0] * (float)iHeight / dp.fMax); pDC->MoveTo(ptStart); for (int i = 0; i < iCount; i++) { CPoint pt; pt.x = rcChart.left + (int)((i + 1) * (float)iWidth / (float)iCount); pt.y = rcChart.bottom - (int)(bandVariogram[i] * (float)iHeight / dp.fMax); pDC->LineTo(pt); } // uninit pDC->SelectObject(pOldFont); pDC->SelectObject(pOldPen); pDC->SetTextColor(oldColor); //pDC->SetBkColor(oldBkg); delete pFrameLine; }
void CTrashCleanCtrl::_OnRealPaint(CDC& dc) { int iCount; CRect rcDraw(0,0,0,0); int bLastShowDetail = FALSE; CRect rcBox; int nItemHeight; // m_nTotalHeight = DEF_TOP_TO_FIRST; m_nTotalHeight = 0; for (iCount = 0; iCount < (int)m_vecTrashItems.size(); ++iCount) { if (!m_vecTrashItems[iCount].bShow) continue; if (m_vecTrashItems[iCount].bShowDetail) { nItemHeight = DEF_ITEM_THIN_HEIGHT; } else { nItemHeight = DEF_ITEM_FAT_HEIGHT; } rcDraw.left = 0; rcDraw.right = m_rcClient.Width(); rcDraw.top = m_nTotalHeight; rcDraw.bottom = rcDraw.top + nItemHeight; _DrawItemBKGround(dc, rcDraw, &m_vecTrashItems[iCount]); rcDraw.left = DEF_LEFT_TO_ICON; rcDraw.top = m_nTotalHeight; rcDraw.bottom = rcDraw.top + nItemHeight; rcDraw.right = m_rcClient.right; _DrawItemIcon(dc, rcDraw, &m_vecTrashItems[iCount]); _DrawShowDetailBar(dc, rcDraw, rcBox, &m_vecTrashItems[iCount]); ::CopyRect(m_vecTrashItems[iCount].rcBox, rcBox); rcDraw.left = (DEF_LEFT_TO_DETAIL - 2); rcDraw.top = m_nTotalHeight; rcDraw.bottom = rcDraw.top + nItemHeight; rcDraw.right = m_rcClient.right; // 绘制大条目的文字信息 _DrawTextInfor(dc, rcDraw, &m_vecTrashItems[iCount]); m_vecTrashItems[iCount].rcBox.left = m_rcClient.left; m_vecTrashItems[iCount].rcBox.right = m_rcClient.right; m_vecTrashItems[iCount].rcBox.top = m_nTotalHeight; m_vecTrashItems[iCount].rcBox.bottom = m_nTotalHeight + nItemHeight; m_nTotalHeight += nItemHeight; if (m_vecTrashItems[iCount].bShowDetail) { m_nTotalHeight += DEF_BETWEEN_SHADOW; rcDraw.left = DEF_LEFT_TO_ICON; rcDraw.top = m_nTotalHeight; _DrawShadowLine(dc, rcDraw); rcDraw.left = DEF_LEFT_TO_DETAIL; rcDraw.top = m_nTotalHeight; _DrawItem(dc, rcDraw, &m_vecTrashItems[iCount]); m_nTotalHeight += 1; } // else // { // m_nTotalHeight += DEF_BETWEEN_ITEM; // } } }
BOOL CXTPTabManagerItem::DrawRotatedImage(CDC* pDC, CRect rcItem, CXTPImageManagerIcon* pImage) { CXTPImageManagerIconHandle& imageHandle = !IsEnabled() ? pImage->GetDisabledIcon(): IsHighlighted() ? pImage->GetHotIcon() : IsSelected() ? pImage->GetCheckedIcon() : pImage->GetIcon(); const int cx = rcItem.Width(); const int cy = rcItem.Height(); ASSERT(cx == cy); if (cx != cy) return FALSE; UINT* pSrcBits = NULL, *pDestBits = NULL; HBITMAP hbmSrc = CXTPImageManager::Create32BPPDIBSection(NULL, cx, cy, (LPBYTE*)&pSrcBits); if (!pSrcBits) return FALSE; HBITMAP hbmDest = CXTPImageManager::Create32BPPDIBSection(NULL, cx, cy, (LPBYTE*)&pDestBits); if (!pDestBits) return FALSE; CDC dc; dc.CreateCompatibleDC(NULL); HGDIOBJ hbmpOld = ::SelectObject(dc, hbmSrc); CRect rcDraw(0, 0, cx, cy); dc.BitBlt(0, 0, cx, cy, pDC, rcItem.left, rcItem.top, SRCCOPY); ::SelectObject(dc, hbmpOld); UINT* pSrcInv = pDestBits; UINT* pDestInv = pSrcBits; UINT* pDest = &pDestBits[cx]; int i; for (i = 0; i < cy; i++) { pDest -= 1; pDestBits = pDest; for (int j = 0; j < cx; j++) { *pDestBits = *pSrcBits; pSrcBits += 1; pDestBits += cy; } } hbmpOld = ::SelectObject(dc, hbmDest); pImage->Draw(&dc, rcDraw.TopLeft(), imageHandle, rcDraw.Size()); ::SelectObject(dc, hbmpOld); pDest = &pDestInv[cx * (cy - 1)]; for (i = 0; i < cy; i++) { pDestInv = pDest; for (int j = 0; j < cx; j++) { *pDestInv = *pSrcInv; pSrcInv += 1; pDestInv -= cy; } pDest += 1; } pDC->DrawState(rcItem.TopLeft(), rcItem.Size(), hbmSrc, DST_BITMAP); DeleteObject(hbmSrc); DeleteObject(hbmDest); return TRUE; }
BOOL CXFSFrame::Draw(CDC *pDC) { BOOL bRet = TRUE; CSize sizeFrame;//the width and height of the frame CXFSField *pField = NULL;//first get the correct field if(m_strFrames == "") { //POSITION XFSGetSize(pDC,m_pRootForm->unit.m_strBase,CSize(position.m_wX,position.m_wY),\ CSize(m_pRootForm->unit.m_wX,m_pRootForm->unit.m_wY),sizeFrame, m_pRootForm->m_lXExt,m_pRootForm->m_lYExt); } else { POSITION pos; CString strTemp; pos = m_pRootForm->m_listFields.GetHeadPosition(); while(pos)//get the responding field { pField = (CXFSField*)m_pRootForm->m_listFields.GetNext(pos); if(pField->m_strFieldName == m_strFrames) { break; } } XFSGetSize(pDC,m_pRootForm->unit.m_strBase,CSize(pField->position.m_wX,pField->position.m_wY),\ CSize(m_pRootForm->unit.m_wX,m_pRootForm->unit.m_wY),sizeFrame, m_pRootForm->m_lXExt,m_pRootForm->m_lYExt); } //get the form aligment CPrinterBase pb; CSize sizePaper; pb.GetPaperWidthAndHeight(sizePaper);// mm/10 XFSGetSize(pDC,"MM",CSize(sizePaper.cx/10,sizePaper.cy/10),CSize(m_pRootForm->unit.m_wX,\ m_pRootForm->unit.m_wY),sizePaper,m_pRootForm->m_lXExt,m_pRootForm->m_lYExt); CSize sizeForm; XFSGetSize(pDC,m_pRootForm->unit.m_strBase,CSize(m_pRootForm->alignment.m_wXoffset,\ m_pRootForm->alignment.m_wYoffset),CSize(m_pRootForm->unit.m_wX,m_pRootForm->unit.m_wY),sizeForm, m_pRootForm->m_lXExt,m_pRootForm->m_lYExt); CSize sizeFormOffset; CSize sizeOut; sizeOut = sizeFrame; XFSOffsetForm(m_pRootForm->alignment.m_strAlignment,sizePaper,sizeForm,sizeFormOffset);//relative to the form offset to the media sizeOut += sizeFormOffset;//form offset add frame offset m_nPositionX = sizeOut.cx; m_nPositionY = sizeOut.cy; //size CRect rcDraw(CPoint(m_nPositionX,m_nPositionY),CSize(sizeFrame.cx,sizeFrame.cy)); ///header if(!XFSIsNeedToDrawThisPage(m_strHeader,m_pRootForm->m_dwPage))//print the current page? yes or no return FALSE; //header //footer if(!XFSIsNeedToDrawThisPage(m_strFooter,m_pRootForm->m_dwPage))//print the curent page? yes or no return FALSE; //footer //repeatonx if(repeatonx.m_wRepeatCount != 0) { int nTemp; nTemp = repeatonx.m_wRepeatCount; //sizeOut.cx = m_nPositionX;///get the position and the width and height is store in sizeFrame //sizeOut.cy = m_nPositionY; while(nTemp)///draw this frame nTemp times { rcDraw.OffsetRect(repeatonx.m_wXoffset,0); nTemp --; pDC->Draw3dRect(rcDraw,0,0); } } //repeatony if(repeatony.m_wRepeatCount != 0) { int nTemp; nTemp = repeatony.m_wRepeatCount; while(nTemp) { rcDraw.OffsetRect(0,repeatony.m_wYoffset); nTemp --; } pDC->Draw3dRect(rcDraw,0,0); } if(m_strType == "RECTANGLE") {} else if(m_strType == "ROUNDED_CORNER") { pDC->RoundRect(&rcDraw,CPoint(70,70)); } else if(m_strType == "ELLIPSE") { pDC->Ellipse(&rcDraw); } if(m_strOverflow == "TERMINATE"){} else if(m_strOverflow == "TRUNCATE"){} else if(m_strOverflow == "BESTFIT"){} COLORREF r; XFSSetColor(m_strColor,r); pDC->SetTextColor(r); if(rgbcolor.m_bRed == 0 && rgbcolor.m_bGreen== 0 && rgbcolor.m_bBlue== 0) { } else { pDC->SetTextColor(RGB(rgbcolor.m_bRed,rgbcolor.m_bGreen,rgbcolor.m_bBlue)); } pDC->Draw3dRect(rcDraw,0,0); return bRet; }