本文整理汇总了C++中CDCHandle类的典型用法代码示例。如果您正苦于以下问题:C++ CDCHandle类的具体用法?C++ CDCHandle怎么用?C++ CDCHandle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CDCHandle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetFirstPixel
// returns 16, 24, 32 bit depth
CLIB_API int GetFirstPixel(HBITMAP hBitmap, COLORREF& firstPixel)
{
BITMAP bmp;
if (::GetObject(hBitmap, sizeof(bmp), &bmp) && bmp.bmBits)
{
if (bmp.bmBitsPixel > 16)
{
unsigned offset=(((bmp.bmWidth*bmp.bmBitsPixel/8)+3)/4) * 4 * (bmp.bmHeight-1);
firstPixel = *(COLORREF*)((BYTE*)bmp.bmBits + offset);
// in memory it is laid out as BGR, so convert to RGB...
firstPixel = RGB(GetBValue(firstPixel), GetGValue(firstPixel), GetRValue(firstPixel));
return bmp.bmBitsPixel;
}
else
{
ATLASSERT(bmp.bmBitsPixel==16);
// we need a temporary memory bitmap to paint into.
CClientDC dcc(0);
CMemBm bmpFirstPixel(dcc, 0, 0, 0, 1, 1);
CDCHandle hdcH = bmpFirstPixel;
HBITMAP hbmpold=dcc.SelectBitmap(hBitmap);
hdcH.BitBlt(0, 0, 1, 1, dcc, 0, 0, SRCCOPY);
dcc.SelectBitmap(hbmpold);
// get trans color
firstPixel = bmpFirstPixel.GetFirstPixel();
return bmp.bmBitsPixel;
}
}
return 0;
}
示例2: DrawGlowText
int CSkinManager::DrawGlowText(CDCHandle hdc, LPCTSTR lpchText, int cchText, LPRECT lprc, UINT format, bool bGlow)
{
const int iGlowMargin = 10;
CDC dcMem;
dcMem.CreateCompatibleDC(hdc);
CBitmap bmp;
BITMAPINFO dib = { sizeof(BITMAPINFOHEADER), lprc->right - lprc->left + iGlowMargin + iGlowMargin, lprc->top - lprc->bottom, 1, 32, BI_RGB };
bmp.CreateDIBSection(hdc, &dib, DIB_RGB_COLORS, NULL, NULL, 0);
dcMem.SelectBitmap(bmp);
__DTTOPTS dto = { sizeof(__DTTOPTS) };
dto.dwFlags = _DTT_TEXTCOLOR | _DTT_COMPOSITED | (bGlow ? _DTT_GLOWSIZE : 0);
dto.crText = hdc.GetTextColor();
dto.iGlowSize = 8;
dcMem.SelectFont(hdc.GetCurrentFont());
RECT rcText2 = { iGlowMargin, 0, lprc->right - lprc->left + iGlowMargin, lprc->bottom - lprc->top };
int iRet = ::TuoDrawThemeTextEx(s()->GetTheme(), dcMem, 0, 0, lpchText, cchText, format, &rcText2, &dto);
BLENDFUNCTION bf;
bf.BlendOp = AC_SRC_OVER;
bf.BlendFlags = 0;
bf.SourceConstantAlpha = 0xff;
bf.AlphaFormat = AC_SRC_ALPHA;
::AlphaBlend(hdc, lprc->left - iGlowMargin, lprc->top, lprc->right - lprc->left + iGlowMargin + iGlowMargin, lprc->bottom - lprc->top, dcMem, 0, 0, lprc->right - lprc->left + iGlowMargin + iGlowMargin, lprc->bottom - lprc->top, bf);
return iRet;
}
示例3:
void TextRenderer::Paragraph::draw(CDCHandle dc, int x, int y) const {
bool isFirstWord = true;
HFONT lastFont = NULL;
COLORREF lastColor = 0;
for (vector<Word>::const_iterator i = words.begin(); i != words.end(); ++i) {
const Word& w = *i;
if (!w.m_text.empty()) {
if (isFirstWord) {
isFirstWord = false;
dc.SelectFont(w.m_font);
lastFont = w.m_font;
dc.SetTextColor(w.m_fontColor);
lastColor = w.m_fontColor;
}
else {
if (lastFont != w.m_font) {
dc.SelectFont(w.m_font);
lastFont = w.m_font;
}
if (lastColor != w.m_fontColor) {
dc.SetTextColor(w.m_fontColor);
lastColor = w.m_fontColor;
}
}
dc.TextOut(x + w.m_location.x, y + w.m_location.y, w.m_text.c_str(), w.m_text.length());
}
}
}
示例4: OnCtlColorEdit
HBRUSH JHCEdit::OnCtlColorEdit(CDCHandle dc, CEdit edit)
{
dc.SetTextColor(colorTx);
dc.SetBkColor(colorBg);
dc.SetDCBrushColor(colorBg);
return HBRUSH(GetStockObject(DC_BRUSH));
}
示例5: GetRect
RECT CItemData::GetRect(CDCHandle& dc)
{
if ( NULL == m_pData )
return RECT() ;
if ( TIT_LINK != m_pData->dwType && TIT_TEXT != m_pData->dwType )
return RECT() ;
RECT rcItem = {0} ;
wstring wsText ;
switch(m_pData->dwType)
{
case TIT_LINK:
{
CFont font ;
font.CreateFont(13,0,0,0,GetBold()?FW_BOLD:FW_NORMAL,0,TRUE,0,0,0,0,0,0,_T("Tahoma")) ;
HFONT hOldFont = dc.SelectFont(font) ;
wsText = m_pData->pData->pilLink->wsText ;
dc.DrawText(wsText.c_str() , wsText.size() , &rcItem , DT_CALCRECT|DT_NOPREFIX|DT_NOCLIP|DT_SINGLELINE) ;
dc.SelectFont(hOldFont) ;
}
break;
case TIT_TEXT :
wsText = m_pData->pData->pitText->wsText ;
dc.DrawText(wsText.c_str() , wsText.size() , &rcItem , DT_CALCRECT|DT_NOPREFIX|DT_NOCLIP|DT_SINGLELINE) ;
break ;
}
return rcItem ;
}
示例6: DoPaint
void CWTLView::DoPaint( CDCHandle dc )
{
CRect rc;
SYSTEMTIME st;
CString sTime;
// Get our window's client area.
GetClientRect ( rc );
// Build the string to show in the window.
GetLocalTime ( &st );
sTime.Format ( _T("The time is %d:%02d:%02d"), st.wHour, st.wMinute, st.wSecond );
// Set up the DC and draw the text.
dc.SaveDC();
dc.SetBkColor ( RGB(255,153,0) );
dc.SetTextColor ( RGB(0,0,0) );
dc.ExtTextOut ( 0, 0, ETO_OPAQUE, rc, sTime, sTime.GetLength(), NULL );
// Restore the DC.
dc.RestoreDC(-1);
}
示例7: DrawSplitterBar
void CWidgetSplitter::DrawSplitterBar(CDCHandle dc)
{
TRY_CATCH
RECT rect;
if ( GetSplitterBarRect(&rect) )
{
RECT rc;
GetClientRect(&rc);
HRGN rgnWnd = CreateRectRgnIndirect(&rc);
HRGN rgnBar = CreateRectRgnIndirect(&rect);
CombineRgn(rgnWnd,rgnWnd,rgnBar,RGN_XOR);
rc = rect;
rc.left = rect.left + (rect.right - rect.left)/2;
rc.right = rc.left + 1;
HRGN rgnLine = CreateRectRgnIndirect(&rc);
CombineRgn(rgnWnd,rgnWnd,rgnLine,RGN_OR);
SetWindowRgn(rgnWnd,TRUE);
DeleteObject(rgnBar);
DeleteObject(rgnLine);
DeleteObject(rgnWnd);
dc.MoveTo(rc.left,rc.top);
dc.LineTo(rc.left,rc.bottom);
}
CATCH_THROW()
}
示例8: _DrawCheckBox
int CListViewCtrlEx::_DrawCheckBox( CDCHandle &dc, RECT &rcItem, BOOL bChecked, DWORD dwFlags )
{
if(rcItem.left>-16)
{
CDC dcTmp;
dcTmp.CreateCompatibleDC(dc);
RECT rcCheckBox = _GetRectCheckBox( rcItem );
HBITMAP hBmpOld = NULL;
int x=rcCheckBox.left + 3, y=rcCheckBox.top, nWidth=13, nHeight=13, xSrc=bChecked ? 0 : 13, ySrc=0;
if(dwFlags&LISTITEM_CHECKBOX)
{
hBmpOld = dcTmp.SelectBitmap(m_bitmapCheck);
dc.BitBlt(x, y, nWidth, nHeight, dcTmp, xSrc, ySrc, SRCCOPY);
}
else
{
// Need Mask
hBmpOld = dcTmp.SelectBitmap(m_bitmapRadioMask);
dc.BitBlt(x, y, nWidth, nHeight, dcTmp, xSrc, ySrc, SRCAND);
dcTmp.SelectBitmap(m_bitmapRadio);
dc.BitBlt(x, y, nWidth, nHeight, dcTmp, xSrc, ySrc, SRCPAINT);
}
dcTmp.SelectBitmap(hBmpOld);
dcTmp.DeleteDC();
}
return 3 + 13 + 3;
}
示例9: DrawColumnSepLine
void CMenuSkin::DrawColumnSepLine(CDCHandle dc, const RECT &rcClient, int iLineX)
{
CPen pen;
pen.CreatePen(PS_SOLID, 1, CSkinProperty::GetColor(Skin_Property_Menu_Vertical_Sep_Color));
dc.SelectPen(pen);
dc.MoveTo(iLineX, rcClient.top + GetMenuMarginDelta());
dc.LineTo(iLineX, rcClient.bottom - GetMenuMarginDelta());
}
示例10: OnControlColor
LRESULT CPreviewWindow::OnControlColor(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
CDCHandle dc = (HDC) wParam;
dc.SetBkColor(RGB(174, 169, 167));
dc.SetTextColor(RGB(0, 0, 0));
return (LRESULT) ((HBRUSH) m_bgBrush);
}
示例11: dc
void
CAboutDialog::OnPaint(HDC hDC)
{
//
// HDC hDC is not a DC
// bug in atlcrack.h
//
CPaintDC dc(m_hWnd);
SIZE sizePic = {0, 0};
m_pix.GetSizeInPixels(sizePic);
CRect rcWnd, rcClient;
GetClientRect(rcClient);
GetWindowRect(rcWnd);
ATLTRACE(_T("Picture Size: %d, %d\n"), sizePic.cx, sizePic.cy);
ATLTRACE(_T("Client Size: %d, %d\n"), rcClient.Width(), rcClient.Height());
ATLTRACE(_T("Window Size: %d, %d\n"), rcWnd.Width(), rcWnd.Height());
//
// adjust the picture size to the same width of the dialog
//
SIZE sizeAdj =
{
rcWnd.Width(),
MulDiv(sizePic.cy, rcWnd.Width(), sizePic.cx)
};
LONG lBaseUnits = GetDialogBaseUnits();
INT baseX = LOWORD(lBaseUnits);
INT baseY = HIWORD(lBaseUnits);
INT tplX = MulDiv(sizePic.cx, 4, baseX);
INT tplY = MulDiv(sizePic.cy, 4, baseY);
ATLTRACE(_T("Adjusted Size: %d, %d\n"), sizeAdj.cx, sizeAdj.cy);
//
// avoid distortion from a little difference
//
int diff = sizePic.cx - sizeAdj.cx;
diff = (diff > 0) ? diff : -diff;
if (diff < 30)
{
sizeAdj = sizePic;
}
ATLTRACE(_T("Using Size: %d, %d\n"), sizeAdj.cx, sizeAdj.cy);
CRect rectPic(CPoint(0,0),sizeAdj);
CDCHandle dcHandle;
dcHandle.Attach((HDC)dc);
m_pix.Render(dcHandle, rectPic);
}
示例12: OnPaint
void CDuiColorPicker::OnPaint( CDCHandle dc )
{
CRect rcClient;
GetClient(&rcClient);
ALPHAINFO ai;
CGdiAlpha::AlphaBackup(dc,rcClient,ai);
dc.FillSolidRect(&rcClient,m_crCur);
dc.DrawEdge(&rcClient, BDR_RAISEDINNER, BF_RECT);
CGdiAlpha::AlphaRestore(dc,ai);
}
示例13: GetClientRect
LRESULT CNativeToolbar::OnEraseBkgnd(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
{
CRect rect;
GetClientRect(rect);
CDCHandle hdc = (HDC)wParam;
hdc.FillSolidRect(rect, m_rgbBackColor );
bHandled = TRUE;
return 1;
}
示例14: GetClientRect
void CODStaticImageImpl::DrawItem (LPDRAWITEMSTRUCT lpdis)
{
if (!m_szImagePath.IsEmpty())
{
RECT rcClient;
GetClientRect(&rcClient);
CDCHandle dc = lpdis->hDC;
dc.SaveDC();
HBITMAP hBitmap, hOldBitmap;
HPALETTE hPalette, hOldPalette;
BITMAP bm;
if( LoadBitmapFromBMPFile( m_szImagePath.LockBuffer(), &hBitmap, &hPalette ) )
{
GetObject(hBitmap, sizeof(BITMAP), &bm);
HDC hMemDC = CreateCompatibleDC(dc.m_hDC);
hOldBitmap = (HBITMAP)SelectObject(hMemDC, hBitmap);
hOldPalette = dc.SelectPalette(hPalette, FALSE);
dc.RealizePalette();
dc.StretchBlt(rcClient.left, rcClient.top, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top,\
hMemDC, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY );
SelectObject(hMemDC, hOldBitmap);
DeleteObject(hBitmap);
dc.SelectPalette(hOldPalette, FALSE);
DeleteObject(hPalette);
}
m_szImagePath.UnlockBuffer();
dc.RestoreDC(-1);
}
else if (m_nBitmapId > 0)
{
RECT rcClient;
GetClientRect(&rcClient);
CDCHandle dc = lpdis->hDC;
dc.SaveDC();
CBitmap bitmap;
_U_STRINGorID id (m_nBitmapId);
bitmap.LoadBitmap(id);
CMemDC memDC(dc, &rcClient);
memDC.SelectBitmap(bitmap.m_hBitmap);
dc.RestoreDC(-1);
}
return;
}
示例15: OnDrawBorder
// This function is called every time the button border needs to be painted.
// If the button is in standard (not flat) mode this function will NOT be called.
//
// Parameters:
// [IN] pDC
// Pointer to a CDC object that indicates the device context.
// [IN] pRect
// Pointer to a CRect object that indicates the bounds of the
// area to be painted.
//
// Return value:
// BTNST_OK
// Function executed successfully.
//
DWORD CButtonST::OnDrawBorder(CDCHandle pDC, LPCRECT pRect)
{
if (m_bIsPressed)
{
pDC.Draw3dRect(pRect, ::GetSysColor(COLOR_BTNSHADOW), ::GetSysColor(COLOR_BTNHILIGHT));
}
else
{
pDC.Draw3dRect(pRect, ::GetSysColor(COLOR_BTNHILIGHT), ::GetSysColor(COLOR_BTNSHADOW));
}
return BTNST_OK;
} // End of OnDrawBorder