void WINAPI duOutlookBar::DrawObject(HDC hDC) { duRect rect; GetRect(&rect); rect.OffsetRect(-rect.left, -rect.top); duStyleGroup *pStyleGroup = (duStyleGroup *)GetResObj(GetStyle(), DU_RES_STYLEGROUP); if (pStyleGroup) pStyleGroup->Draw(hDC, &rect, DU_STATE_ALL, GetText(), GetAlpha()); duStyleGroup *pItemStyleGroup = (duStyleGroup *)GetResObj(m_szItemStyle, DU_RES_STYLEGROUP); if (pItemStyleGroup == NULL) return ; int i; OutlookBarItem *pOutlookBarItem = NULL; int nItemCount = GetItemCount(); duRect rectItem = rect; rectItem.bottom = rectItem.top + m_nItemHeight; for (i = 0;i < nItemCount; i++) { pOutlookBarItem = m_vtItems[i]; pItemStyleGroup->Draw(hDC, &rectItem, pOutlookBarItem->iState, pOutlookBarItem->strText.c_str(), GetAlpha()); if (pOutlookBarItem->fSelected) { rectItem.top = rect.bottom - (nItemCount - i - 1) * m_nItemHeight; rectItem.bottom = rectItem.top + m_nItemHeight; } else rectItem.OffsetRect(0, m_nItemHeight); } }
void WINAPI duListBox::DrawObject(HDC hDC) { duRect rcListBox; Plugin_GetRect(this, &rcListBox); rcListBox.OffsetRect(-rcListBox.left, -rcListBox.top); duStyleGroup *pStyleGroup = (duStyleGroup *)GetResObj(GetStyle(), DU_RES_STYLEGROUP); if (pStyleGroup) pStyleGroup->Draw(hDC, &rcListBox, GetState(), GetText(), GetAlpha()); pStyleGroup = (duStyleGroup *)GetResObj(m_szItemStyle, DU_RES_STYLEGROUP); if (pStyleGroup == NULL) return; duRect rcItem; rcItem.SetRectEmpty(); rcItem.right = rcListBox.Width(); rcItem.OffsetRect(0, -m_nYOffset); ListBoxItem *pItem = NULL; int i; int nItemCount = GetItemCount(); for (i = 0;i < nItemCount; i++) { pItem = m_vtItem[i]; rcItem.top = rcItem.bottom; rcItem.bottom = rcItem.top + m_nItemHeight; DrawItem(pItem, hDC, pStyleGroup, rcItem); } }
int duTreeCtrl::CalcItemWidth(TreeCtrlItem *pItem) { if (pItem == NULL) return 0; HDC hDC = GetDC(NULL); HFONT hFont = (HFONT)GetStockObject(SYSTEM_FONT); duFont *pFont = (duFont *)GetResObj(m_szFont, DU_RES_FONT); if (pFont) hFont = pFont->GetHFont(); HFONT hOldFont = (HFONT)::SelectObject(hDC, hFont); int nItemWidth = (pItem->nLevel * m_nIndentWidth) + m_nIndentIconSpace + m_nIconTextSpace + m_nIconWidth; if (pItem->strText.c_str() > 0 && !pItem->nTextWidth) { duRect rcText; rcText.SetRectEmpty(); ::DrawText(hDC, pItem->strText.c_str(), pItem->strText.length(), &rcText, DT_TOP|DT_LEFT|DT_SINGLELINE|DT_CALCRECT); pItem->nTextWidth = rcText.Width(); } nItemWidth += pItem->nTextWidth; ::SelectObject(hDC, hOldFont); ReleaseDC(NULL, hDC); return nItemWidth; }
void duXmlStatic::PaintSegMent(HDC hDC, XMLSTATICLINESEGMENT *pSegment, duRect &rcSegMent) { XMLTEXTHEAD *pTextHead = pSegment->pTextHead; HFONT hFont = GetXmlTextHeadFont(pTextHead); HFONT hOldFont = (HFONT)::SelectObject(hDC, hFont); LPTSTR lpString = new TCHAR[pSegment->nStringWidth + 1]; memset(lpString, 0, sizeof(TCHAR) * (pSegment->nStringWidth + 1)); _tcsncpy(lpString, pSegment->lpString, pSegment->nStringWidth); if (pTextHead->enType == NORMALTEXT) { duFont *pFont = (duFont *)GetResObj(m_szDefaultFont, DU_RES_FONT); DrawText32Bpp(hDC, pFont, m_clrDefault, lpString, pSegment->nStringWidth, &rcSegMent, DT_LEFT|DT_TOP|DT_SINGLELINE, GetAlpha()); } else if (pTextHead->enType == FORMATTEXT) { XMLFORMATTEXT *pFormatText = (XMLFORMATTEXT *)pTextHead; if (m_pHotSegMent && (m_pHotSegMent->pTextHead == pSegment->pTextHead) && IsHrefSegment(m_pHotSegMent)) { duFont *pFont = (duFont *)GetResObj(pFormatText->strFont.c_str(), DU_RES_FONT); duFont *pFontUnderline = new duFont; pFontUnderline->SetHeight(pFont->GetHeight()); pFontUnderline->SetWeight(pFont->GetWeight()); pFontUnderline->SetItalic(pFont->IsItalic()); pFontUnderline->SetUnderline(TRUE); pFontUnderline->SetStrikeOut(pFont->IsStrikeOut()); pFontUnderline->SetFontFace(pFont->GetFontFace()); pFontUnderline->CreateFont(); DrawText32Bpp(hDC, pFontUnderline, pFormatText->clrText, lpString, pSegment->nStringWidth, &rcSegMent, DT_LEFT|DT_TOP|DT_SINGLELINE, GetAlpha()); delete pFontUnderline; } else { duFont *pFont = (duFont *)GetResObj(pFormatText->strFont.c_str(), DU_RES_FONT); DrawText32Bpp(hDC, pFont, pFormatText->clrText, lpString, pSegment->nStringWidth, &rcSegMent, DT_LEFT|DT_TOP|DT_SINGLELINE, GetAlpha()); } } ::SelectObject(hDC, hOldFont); delete [] lpString; }
void WINAPI duAnimation::DrawObject(HDC hDC) { duImage *pImage = (duImage *)GetResObj(m_szAnimation, DU_RES_IMAGE); if (pImage == NULL) return; int left = m_nCurFrame * (pImage->GetWidth() / m_nFrameCount); DrawNormal(hDC, 0, 0, pImage->GetWidth() / m_nFrameCount, pImage->GetHeight(), pImage, left, 0, GetAlpha()); }
HFONT duXmlStatic::GetXmlTextHeadFont(XMLTEXTHEAD *pTextHead) { duFont *font = NULL; HFONT hFont = (HFONT)::GetStockObject(DEFAULT_GUI_FONT); if (pTextHead->enType == NORMALTEXT || pTextHead->enType == BRTEXT) { font = (duFont *)GetResObj(m_szDefaultFont, DU_RES_FONT); } else if (pTextHead->enType == FORMATTEXT) { XMLFORMATTEXT *pFormatText = (XMLFORMATTEXT *)pTextHead; font = (duFont *)GetResObj(pFormatText->strFont.c_str(), DU_RES_FONT); } if (font) hFont = font->GetHFont(); return hFont; }
void WINAPI duStatic::OnMouseIn(POINT pt) { duCtrlManager *pCtrlManager = GetCtrlManager(m_hWnd); if (pCtrlManager == NULL) return; if (m_fShowToolTip) { pCtrlManager->AddToolTip((LPTSTR)GetText()); } else { LPCTSTR lpszText = GetText(); if (lpszText && *lpszText) { duStyleGroup *pStyleGroup = (duStyleGroup *)GetResObj(GetStyle(), DU_RES_STYLEGROUP); if (pStyleGroup == NULL) return; int i; int nStyleCount = pStyleGroup->GetStyleCount(); for (i = 0;i < nStyleCount; i++) { duStyleBase *pStyleBase = pStyleGroup->GetStyle(i); if (pStyleBase->GetType() == STYLE_TEXT) { duTextStyle *pTextStyle = (duTextStyle *)pStyleBase; duSize size(0, 0); pTextStyle->CalcTextRect(lpszText, &size); duRect rcStyle; rcStyle.SetRectEmpty(); duRect rcStatic; Plugin_GetRect(this, &rcStatic); rcStatic.OffsetRect(-rcStatic.left, -rcStatic.top); MakeRect(pTextStyle->GetLeft(), pTextStyle->GetTop(), pTextStyle->GetRight(), pTextStyle->GetBottom(), pTextStyle->GetWidth(), pTextStyle->GetHeight(), &rcStatic, &rcStyle); POINT point; point.x = size.cx; point.y = size.cy; if (!rcStyle.PtInRect(point)) { pCtrlManager->AddToolTip((LPTSTR)lpszText); } break; } } } } }
void duTreeListItem::DrawObject(HDC hDC) { duRect rcTreeListItem; GetRect(&rcTreeListItem); rcTreeListItem.OffsetRect(-rcTreeListItem.left, -rcTreeListItem.top); duRect rcIndent; rcIndent.left = m_nIndentStart + (m_nLevel - 1) * m_nExpandSpace; rcIndent.right = rcIndent.left + m_nIndentWidth; rcIndent.top = (rcTreeListItem.Height() - m_nIndentHeight) / 2; rcIndent.bottom = rcIndent.top + m_nIndentHeight; if (m_pTreeListItem && m_pTreeListItem->pFirstChild) { duStyleGroup *pStyleGroup = (duStyleGroup *)GetResObj(m_szIndentStyle, DU_RES_STYLEGROUP); if (pStyleGroup) pStyleGroup->Draw(hDC, &rcIndent, m_fExpand ? DU_STATE_NORMAL : DU_STATE_CHECKED, NULL, GetAlpha()); } if (m_fShowCheckBox) { duImage *pCheckBoxImage = (duImage *)GetResObj(m_szCheckBoxImage, DU_RES_IMAGE); if (pCheckBoxImage) { duRect rcCheckBox; rcCheckBox.left = rcIndent.right + m_nIndentSpace; rcCheckBox.right = rcCheckBox.left + m_nCheckBoxWidth; rcCheckBox.top = (rcTreeListItem.Height() - m_nCheckBoxHeight) / 2; rcCheckBox.bottom = rcCheckBox.top + m_nCheckBoxHeight; int nCheckBoxImageLeft = 0; if (m_uCheckBoxState == HEADER_CHECKBOX_CHECKED) nCheckBoxImageLeft = m_nCheckBoxWidth; else if (m_uCheckBoxState == HEADER_CHECKBOX_CHECKEDPART) nCheckBoxImageLeft = m_nCheckBoxWidth + m_nCheckBoxWidth; DrawNormal(hDC, rcCheckBox.left, rcCheckBox.top, rcCheckBox.Width(), rcCheckBox.Height(), pCheckBoxImage, nCheckBoxImageLeft, 0, GetAlpha()); } } }
void duIMPanelNode::DrawObject(HDC hDC) { duRect rcIMPanelNode; Plugin_GetRect(this, &rcIMPanelNode); rcIMPanelNode.OffsetRect(-rcIMPanelNode.left, -rcIMPanelNode.top); duStyleGroup *pStyleGroup = (duStyleGroup *)GetResObj(GetStyle(), DU_RES_STYLEGROUP); if (pStyleGroup) pStyleGroup->Draw(hDC, &rcIMPanelNode, GetState(), GetText(), GetAlpha()); }
void WINAPI duXmlStatic::DrawObject(HDC hDC) { duRect rectStatic; Plugin_GetRect(this, &rectStatic); rectStatic.OffsetRect(-rectStatic.left, -rectStatic.top); duStyleGroup *pStyleGroup = (duStyleGroup *)GetResObj(GetStyle(), DU_RES_STYLEGROUP); if (pStyleGroup) pStyleGroup->Draw(hDC, &rectStatic, GetState(), NULL, GetAlpha()); DrawXmlText(hDC); }
void WINAPI duStatic::DrawObject(HDC hDC) { duStyleGroup *pStyleGroup = (duStyleGroup *)GetResObj(GetStyle(), DU_RES_STYLEGROUP); if (pStyleGroup == NULL) return; duRect rcCtrl; rcCtrl.SetRectEmpty(); GetRect(&rcCtrl); rcCtrl.OffsetRect(-rcCtrl.left, -rcCtrl.top); pStyleGroup->Draw(hDC, &rcCtrl, GetState(), GetText(), GetAlpha()); }
void WINAPI duAnimation::Play() { duImage *pImage = (duImage *)GetResObj(m_szAnimation, DU_RES_IMAGE); if (pImage == NULL) return; StopPlay(); DWORD dwThreadId = 0; m_hTimerEvent = CreateEvent(NULL, TRUE, FALSE, NULL); m_hExitEvent = CreateEvent(NULL, TRUE, FALSE, NULL); m_hThread = CreateThread(NULL, 0, AnimationThread, this, 0, &dwThreadId); }
void duGifCtrl::Play() { Plugin_KillTimer(this, m_nTimerId); duImage *pImage = (duImage *)GetResObj(m_szGifName, DU_RES_IMAGE); if (pImage == NULL) return; int nFrameCount = pImage->GetFrameCount(); if (nFrameCount <= 1) return; m_nCurFrame = 0; int nFrameDelay = pImage->GetFrameDelay(m_nCurFrame); Plugin_SetTimer(this, m_nTimerId, nFrameDelay); }
void duListBox::DrawItem(ListBoxItem *pItem, HDC hDC, duStyleGroup *pStyleGroup, duRect &rcItem) { int nAlpha = GetAlpha(); UINT uItemState = DU_STATE_NORMAL; if (m_pSelItem == pItem) uItemState = DU_STATE_PRESS; if (pItem->fDisable) pStyleGroup->Draw(hDC, &rcItem, DU_STATE_DISABLE, pItem->szText.c_str(), nAlpha); else { if (m_pHotItem == pItem) { if (m_pHotItem == m_pSelItem) pStyleGroup->Draw(hDC, &rcItem, DU_STATE_PRESS, pItem->szText.c_str(), nAlpha); else { int nStyleCount = pStyleGroup->GetStyleCount(); int k; for (k = 0; k < nStyleCount; k++) { duStyleBase *pStyle = pStyleGroup->GetStyle(k); if (pStyle && (pStyle->GetState() & DU_STATE_OVER)) { if (pStyle->GetType() != STYLE_TEXT) pStyle->Draw(hDC, &rcItem, pItem->szText.c_str(), m_nAlphaFadeIn); else pStyle->Draw(hDC, &rcItem, pItem->szText.c_str(), nAlpha); } } } } else { pStyleGroup->Draw(hDC, &rcItem, uItemState, pItem->szText.c_str(), nAlpha); } } duImage *pIconImage = (duImage *)GetResObj(pItem->szIcon.c_str(), DU_RES_IMAGE); if (pIconImage == NULL) return; DrawStretch(hDC, rcItem.left + pItem->uIconX, rcItem.top + pItem->uIconY, pItem->uIconWidth, pItem->uIconHeight, pIconImage, 0, 0, pIconImage->GetWidth(), pIconImage->GetHeight(), nAlpha); }
void duTreeCtrl::SetFont(LPCTSTR lpszFont) { if (lpszFont) { if (!GetResObj(lpszFont, DU_RES_FONT)) return; _tcsncpy(m_szFont, lpszFont, MAX_NAME); TreeCtrlItem *pItem = m_pRoot; while (pItem) { pItem->nTextWidth = 0; pItem = GetNextItem(pItem); } UpdateScroll(); Plugin_Redraw(this, TRUE); } }
void duGifCtrl::DrawObject(HDC hDC) { duImage *pImage = (duImage *)GetResObj(m_szGifName, DU_RES_IMAGE); if (pImage == NULL) return; HBITMAP hBitmap = NULL; if (pImage->GetFrameCount() <= 1) hBitmap = pImage->GetBitmap(); else hBitmap = pImage->GetFrameBitmap(m_nCurFrame); HDC hSrcDC = ::CreateCompatibleDC(NULL); HBITMAP hSrcOldBmp = (HBITMAP)::SelectObject(hSrcDC, hBitmap); BLENDFUNCTION bf = {AC_SRC_OVER, 0, GetAlpha(), AC_SRC_ALPHA}; ::AlphaBlend(hDC, 0, 0, pImage->GetWidth(), pImage->GetHeight(), hSrcDC, 0, 0, pImage->GetWidth(), pImage->GetHeight(), bf); ::SelectObject(hSrcDC, hSrcOldBmp); ::DeleteDC(hSrcDC); }
void duGifCtrl::OnTimer(UINT nEventId) { if (nEventId != m_nTimerId) return; if (!Plugin_IsVisible(this)) return; Plugin_KillTimer(this, m_nTimerId); duImage *pImage = (duImage *)GetResObj(m_szGifName, DU_RES_IMAGE); if (pImage == NULL) return; int nFrameCount = pImage->GetFrameCount(); if (nFrameCount <= 1) return; int nFrameDelay = pImage->GetFrameDelay(m_nCurFrame); Plugin_SetTimer(this, m_nTimerId, nFrameDelay); Plugin_Redraw(this, TRUE); m_nCurFrame = (m_nCurFrame + 1) % nFrameCount; }
void duTreeCtrl::DrawObject(HDC hDC) { duRect rcTreeCtrl; Plugin_GetRect(this, &rcTreeCtrl); rcTreeCtrl.OffsetRect(-rcTreeCtrl.left, -rcTreeCtrl.top); BITMAPINFO bmInfo; BYTE *pBits; HDC hMemDC = ::CreateCompatibleDC(hDC); InitBitmapInfo(&bmInfo, rcTreeCtrl.Width(), rcTreeCtrl.Height()); HBITMAP hBmp = ::CreateDIBSection(hDC, &bmInfo, DIB_RGB_COLORS,(void**)&pBits, 0, 0); HBITMAP hOldBitmap = (HBITMAP)::SelectObject(hMemDC, hBmp); BLENDFUNCTION bf = {AC_SRC_OVER, 0, 255, AC_SRC_ALPHA}; ::AlphaBlend(hMemDC, 0, 0, rcTreeCtrl.Width(), rcTreeCtrl.Height(), hDC, 0, 0, rcTreeCtrl.Width(), rcTreeCtrl.Height(), bf); duStyleGroup *pStyleGroup = (duStyleGroup *)GetResObj(GetStyle(), DU_RES_STYLEGROUP); if (pStyleGroup) pStyleGroup->Draw(hMemDC, &rcTreeCtrl, GetState(), NULL, GetAlpha()); int nOffsetY = 0; TreeCtrlItem *pFirstVisible = GetFirstVisibleItem(nOffsetY); if (pFirstVisible == NULL || pFirstVisible == m_pRoot) return; duRect rcClient = _GetClientRect(); POINT ptView = GetViewPoint(); duFont *pFont = (duFont *)GetResObj(m_szFont, DU_RES_FONT); duSize sizeView; GetViewSize(&sizeView); int nDrawHeight = -nOffsetY; TreeCtrlItem *pItem = pFirstVisible; while (pItem) { duRect rcItem; rcItem.left = -ptView.x; rcItem.right = rcClient.right; rcItem.top = nDrawHeight; rcItem.bottom = rcItem.top + m_nItemHeight; UINT uItemState = DU_STATE_NORMAL; if (pItem == m_pHot) uItemState = DU_STATE_OVER; if (pItem == m_pSelect) uItemState = DU_STATE_PRESS; DrawByStyle(this, m_szItemStyle, hMemDC, &rcItem, uItemState, NULL, GetAlpha()); // draw indent[-+] int nLeft = (pItem->nLevel - 1) * m_nIndentWidth; duRect rcIndent = CalcVCenterRect(rcItem, nLeft, m_nIndentWidth, m_nIndentHeight); if (ItemHasChildren(pItem)) { UINT nIndentState = pItem->fExpand ? DU_STATE_NORMAL : DU_STATE_CHECKED; DrawByStyle(this, m_szIndentStyle, hMemDC, &rcIndent, nIndentState, NULL, GetAlpha()); } // draw icon nLeft += (m_nIndentWidth + m_nIndentIconSpace); duRect rcIcon = CalcVCenterRect(rcItem, nLeft, m_nIconWidth, m_nIconHeight); duImage *pIcon = (duImage *)GetResObj(pItem->strImage.c_str(), DU_RES_IMAGE); if (pIcon) DrawNormal(hMemDC, rcIcon.left, rcIcon.top, rcIcon.Width(), rcIcon.Height(), pIcon, 0, 0, GetAlpha()); // draw text duRect rcText; nLeft += (m_nIconWidth + m_nIconTextSpace); rcText = rcItem; rcText.left = rcItem.left + nLeft; if (pItem->strText.length() > 0) DrawText32Bpp(hMemDC, pFont, m_clrText, pItem->strText.c_str(), pItem->strText.length(), &rcText, DT_LEFT|DT_VCENTER|DT_SINGLELINE, GetAlpha()); if (nDrawHeight - nOffsetY > rcTreeCtrl.Height()) break; nDrawHeight += m_nItemHeight; pItem = GetNextVisibleItem(pItem); } ::AlphaBlend(hDC, 0, 0, rcTreeCtrl.Width(), rcTreeCtrl.Height(), hMemDC, 0, 0, rcTreeCtrl.Width(), rcTreeCtrl.Height(), bf); ::SelectObject(hMemDC, hOldBitmap); ::DeleteObject(hBmp); ::DeleteDC(hMemDC); }
void duSpin::DrawObject(HDC hDC) { duRect rcEdit; rcEdit.SetRectEmpty(); GetRect(&rcEdit); rcEdit.OffsetRect(-rcEdit.left, -rcEdit.top); duStyleGroup *pStyleGroup = (duStyleGroup *)GetResObj(GetStyle(), DU_RES_STYLEGROUP); if (pStyleGroup) pStyleGroup->Draw(hDC, &rcEdit, GetState(), NULL, GetAlpha()); duRect rcSpinUpButton, rcSpinDownButton; rcSpinUpButton.left = rcEdit.right - m_nSpinLeft; rcSpinUpButton.top = rcEdit.top + m_nSpinTop; rcSpinUpButton.right = rcSpinUpButton.left + n_nSpinWidth; rcSpinUpButton.bottom = rcSpinUpButton.top + (rcEdit.Height() - m_nSpinTop - m_nSpinBottom) / 2; rcSpinDownButton = rcSpinUpButton; rcSpinDownButton.top = rcSpinUpButton.bottom; rcSpinDownButton.bottom = rcEdit.bottom - m_nSpinBottom; duStyleGroup *pUpStyle = (duStyleGroup *)GetResObj(m_szUpStyle, DU_RES_STYLEGROUP); if (pUpStyle) pUpStyle->Draw(hDC, &rcSpinUpButton, m_uUpState, NULL, GetAlpha()); duStyleGroup *pDownStyle = (duStyleGroup *)GetResObj(m_szDownStyle, DU_RES_STYLEGROUP); if (pDownStyle) pDownStyle->Draw(hDC, &rcSpinDownButton, m_uDownState, NULL, GetAlpha()); HRGN hRgnClip = ::CreateRectRgn(m_rcFormat.left, m_rcFormat.top, m_rcFormat.right, m_rcFormat.bottom); ::SelectClipRgn(hDC, hRgnClip); int s = m_nSelectionStart; int e = m_nSelectionEnd; int ll; int x; int y; LRESULT pos; pos = EMPosFromChar(0); x = (short)LOWORD(pos); y = (short)HIWORD(pos); ll = GetEditTextLength(); s = min(m_nSelectionStart, m_nSelectionEnd); e = max(m_nSelectionStart, m_nSelectionEnd); s = min(ll, s); e = min(ll, e); if ((s != e) && IsFocus()) { x += PaintText(hDC, x, y, 0, 0, s, FALSE); x += PaintText(hDC, x, y, 0, s, e - s, TRUE); x += PaintText(hDC, x, y, 0, e, ll - e, FALSE); } else { x += PaintText(hDC, x, y, 0, 0, ll, FALSE); } ::SelectClipRgn(hDC, NULL); ::DeleteObject(hRgnClip); }
void duLEDTimer::DrawObject(HDC hDC) { duRect rcLEDTimer; Plugin_GetRect(this, &rcLEDTimer); rcLEDTimer.OffsetRect(-rcLEDTimer.left, -rcLEDTimer.top); duStyleGroup *pStyleGroup = (duStyleGroup *)GetResObj(GetStyle(), DU_RES_STYLEGROUP); if (pStyleGroup) pStyleGroup->Draw(hDC, &rcLEDTimer, GetState(), NULL, GetAlpha()); duImage *pImage = (duImage *)GetResObj(m_szImageFont, DU_RES_IMAGE); if (pImage == NULL) return; LPCTSTR lpszText = GetText(); int nImageWidth = pImage->GetWidth(); int nImageHeight = pImage->GetHeight(); int nTextLength = _tcslen(lpszText); int nFontWidth = nImageWidth / 12; HDC hMemDC = ::CreateCompatibleDC(hDC); HBITMAP hOldBitmap = (HBITMAP)::SelectObject(hMemDC, pImage->GetBitmap()); BLENDFUNCTION bf = {AC_SRC_OVER, 0, GetAlpha(), AC_SRC_ALPHA}; int i; int xDst = 0, yDst = 0; int xSrc; for (i = 0;i < nTextLength; i++) { xSrc = 0; switch (lpszText[i]) { case '1': xSrc = 0; break; case '2': xSrc = nFontWidth; break; case '3': xSrc = nFontWidth * 2; break; case '4': xSrc = nFontWidth * 3; break; case '5': xSrc = nFontWidth * 4; break; case '6': xSrc = nFontWidth * 5; break; case '7': xSrc = nFontWidth * 6; break; case '8': xSrc = nFontWidth * 7; break; case '9': xSrc = nFontWidth * 8; break; case '0': xSrc = nFontWidth * 9; break; case ':': xSrc = nFontWidth * 10; break; case '-': xSrc = nFontWidth * 11; break; default: xSrc = 0; break; } ::AlphaBlend(hDC, xDst, 0, nFontWidth, nImageHeight, hMemDC, xSrc, 0, nFontWidth, nImageHeight, bf); xDst += nFontWidth; } ::SelectObject(hMemDC, hOldBitmap); ::DeleteDC(hMemDC); }