当前位置: 首页>>代码示例>>C++>>正文


C++ CDCHandle类代码示例

本文整理汇总了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;
}
开发者ID:GordonSmith,项目名称:eclide,代码行数:33,代码来源:IPictureHelper.cpp

示例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;
}
开发者ID:Williamzuckerberg,项目名称:chtmoneyhub,代码行数:31,代码来源:SkinManager.cpp

示例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());
    }
  }
}
开发者ID:inetra,项目名称:peers1,代码行数:28,代码来源:TextRenderer.cpp

示例4: OnCtlColorEdit

HBRUSH JHCEdit::OnCtlColorEdit(CDCHandle dc, CEdit edit)
{
	dc.SetTextColor(colorTx);
	dc.SetBkColor(colorBg);
	dc.SetDCBrushColor(colorBg);
	return HBRUSH(GetStockObject(DC_BRUSH));
}
开发者ID:JohnHind,项目名称:Winsh.lua,代码行数:7,代码来源:JHCEdit.cpp

示例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 ;
}
开发者ID:Williamzuckerberg,项目名称:chtmoneyhub,代码行数:29,代码来源:TooltipElem.cpp

示例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);

}
开发者ID:shaellancelot,项目名称:ic2014,代码行数:25,代码来源:WTLView.cpp

示例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()
}
开发者ID:uvbs,项目名称:SupportCenter,代码行数:32,代码来源:CWidgetSplitter.cpp

示例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;
}
开发者ID:charlessoft,项目名称:PicManager,代码行数:30,代码来源:ListViewCtrlEx.cpp

示例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());
}
开发者ID:Williamzuckerberg,项目名称:chtmoneyhub,代码行数:8,代码来源:MenuSkin.cpp

示例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);
}
开发者ID:Ballaw,项目名称:fr_public,代码行数:9,代码来源:PreviewWindow.cpp

示例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);
}
开发者ID:yzx65,项目名称:ndas4windows,代码行数:56,代码来源:eventhandler.cpp

示例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);
}
开发者ID:kevinzhwl,项目名称:duiplant,代码行数:10,代码来源:DuiColorPicker.cpp

示例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;
}
开发者ID:Aerodynamic,项目名称:rhodes,代码行数:11,代码来源:NativeToolbar.cpp

示例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;
}
开发者ID:corytodd,项目名称:WindowsPrinterDriver,代码行数:52,代码来源:Controls.cpp

示例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
开发者ID:moon-sky,项目名称:fishjam-template-library,代码行数:27,代码来源:ButtonST.cpp


注:本文中的CDCHandle类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。