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


C++ CClientDC类代码示例

本文整理汇总了C++中CClientDC的典型用法代码示例。如果您正苦于以下问题:C++ CClientDC类的具体用法?C++ CClientDC怎么用?C++ CClientDC使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CClientDC类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ASSERT_VALID

//*********************************************************************
void CCxNDArrayDimGrid::SetRowHeight ()
{
	if (m_bIsPrinting)
	{
		ASSERT_VALID (m_pPrintDC);

		// map to printer metrics
		HDC hDCFrom = ::GetDC(NULL);
		int nYMul = m_pPrintDC->GetDeviceCaps(LOGPIXELSY);	// pixels in print dc
		int nYDiv = ::GetDeviceCaps(hDCFrom, LOGPIXELSY);	// pixels in screen dc
		::ReleaseDC(NULL, hDCFrom);

		TEXTMETRIC tm;
		m_pPrintDC->GetTextMetrics (&tm);
		m_PrintParams.m_nRowHeight = tm.tmHeight + ::MulDiv (2 * TEXT_VMARGIN, nYMul, nYDiv);
		m_PrintParams.m_nLargeRowHeight = m_PrintParams.m_nRowHeight;
	}
	else
	{
		CClientDC dc (this);
		HFONT hfontOld = SetCurrFont (&dc);

		TEXTMETRIC tm;
		dc.GetTextMetrics (&tm);
		m_nRowHeight = tm.tmHeight + 2 * TEXT_VMARGIN;
		m_nLargeRowHeight = m_nRowHeight;

		::SelectObject (dc.GetSafeHdc (), hfontOld);
	}
}
开发者ID:cugxiangzhenwei,项目名称:WorkPlatForm,代码行数:31,代码来源:CxNDArrayDimGrid.cpp

示例2: MoveElement

void CSketcherView::MoveElement(CClientDC & aDC, const CPoint & point)
{
	CSize distance = point - m_CursorPos; // Get move distance
	m_CursorPos = point; // Set current point as 1st for next time
	
	// If there is an element selected, move it
	if(m_pSelected)
	{
		if (typeid(*m_pSelected) == typeid(CText))
		{
			CRect oldRect=m_pSelected->GetBoundRect(); // Get old bound rect
			aDC.LPtoDP(oldRect); // Convert to client coords
			m_pSelected->Move(distance); // Move the element
			InvalidateRect(&oldRect); // Invalidate combined area
			UpdateWindow(); // Redraw immediately
			m_pSelected->Draw(&aDC,m_pSelected); // Draw highlighted
			return;
		}
		// ...otherwise, use this method
				
		aDC.SetROP2(R2_NOTXORPEN);
		m_pSelected-> Draw(&aDC, m_pSelected); // Draw the element to erase it
		m_pSelected-> Move(distance); // Now move the element
		m_pSelected-> Draw(&aDC, m_pSelected); // Draw the moved element
	}
}
开发者ID:ktjones,项目名称:BVC2010,代码行数:26,代码来源:SketcherView.cpp

示例3: clientDC

void CMainFrame::DrawCell (UINT col,UINT row,BOOL alive)
{
	CBrush* pBrush;
	CClientDC clientDC (this);
	CDC memDC;
	memDC.CreateCompatibleDC (&clientDC);
	memDC.SelectObject (m_pBitmap);

	if(alive)
		pBrush=new CBrush(RGB(255, 0, 0));
	else
	{	
		if (m_showdead)
			pBrush=new CBrush(RGB(200, 200, 200));
		else
			pBrush=new CBrush(RGB(255, 255, 255));
	}

	CBrush* pOldBrush1=memDC.SelectObject (pBrush);
	CBrush* pOldBrush2=clientDC.SelectObject (pBrush);

	UINT drawCol= col * SQUARESIZE + HOROFFSET;
	UINT drawRow= row * SQUARESIZE + VEROFFSET;

	memDC.Rectangle (drawCol,drawRow,drawCol+SQUARESIZE+1, drawRow+SQUARESIZE+1);
	clientDC.Rectangle (drawCol,drawRow,drawCol+SQUARESIZE+1, drawRow+SQUARESIZE+1);

	memDC.SelectObject (pOldBrush1);
	clientDC.SelectObject (pOldBrush2);

	delete pBrush;
}
开发者ID:BorisMomtchev,项目名称:ConwaysLife,代码行数:32,代码来源:mainfrm.cpp

示例4: dc

int CChildView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CWnd ::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	//
	// Load the bitmap.
	//
    m_bitmap.LoadBitmap (IDB_BITMAP);

	//
	// Create a palette for a gradient fill if this is a palettized device.
	//
    CClientDC dc (this);
    if (dc.GetDeviceCaps (RASTERCAPS) & RC_PALETTE) {
        struct {
            LOGPALETTE lp;
            PALETTEENTRY ape[63];
        } pal;

        LOGPALETTE* pLP = (LOGPALETTE*) &pal;
        pLP->palVersion = 0x300;
        pLP->palNumEntries = 64;

        for (int i=0; i<64; i++) {
            pLP->palPalEntry[i].peRed = 0;
            pLP->palPalEntry[i].peGreen = 0;
            pLP->palPalEntry[i].peBlue = 255 - (i * 4);
            pLP->palPalEntry[i].peFlags = 0;
        }
        m_palette.CreatePalette (pLP);
    }
	return 0;
}
开发者ID:jiayuehua,项目名称:MFCProgramming,代码行数:34,代码来源:ChildView.cpp

示例5: RealizeSysPalette

// =====
// Helper function to swap palettes...
// ==
BOOL
RealizeSysPalette(CClientDC &dc)
{
	// if user loaded palette not loaded no realize
	if( gPalette == NULL )
		return FALSE;

	CPalette* pOldPal = dc.SelectPalette( gPalette, 0);
	if( pOldPal != NULL ) {
		int rCnt = dc.RealizePalette();

		dc.SelectPalette(pOldPal, 1);

		if( rCnt != 0 )
			afxDump << "QUERYNEWPALETTE  - The number of colors realized " << rCnt << "\n";
		else
			return FALSE;
	}
	else
		return FALSE;

	// we realized our palette so cause a redraw
	if( dc.GetWindow() != NULL )
		dc.GetWindow()->Invalidate(TRUE);

	// indicates that we realized our palette
	return TRUE;
}
开发者ID:AltimorTASDK,项目名称:TribesRebirth,代码行数:31,代码来源:palHelp.cpp

示例6: dc

//*****************************************************************************************
void CIconCombo::OnMeasureItem(int /*nIDCtl*/, LPMEASUREITEMSTRUCT lpMeasureItemStruct) 
{
	int nTextWidth = 0;
	int nTextHeight = 0;

	if (!m_lstIconNames.IsEmpty ())
	{
		nTextHeight = globalData.GetTextHeight ();

		CClientDC dc (this);
		CFont* pOldFont = dc.SelectObject (&globalData.fontRegular);

		for (POSITION pos = m_lstIconNames.GetHeadPosition (); pos != NULL;)
		{
			CString str = m_lstIconNames.GetNext (pos);

			nTextWidth = max (nTextWidth, dc.GetTextExtent (str).cx + nIconMargin);
		}

		dc.SelectObject (pOldFont);
	}

	lpMeasureItemStruct->itemWidth = m_imageListIcons.GetImageSize ().cx + nTextWidth + 3 * nIconMargin;
	lpMeasureItemStruct->itemHeight = max (nTextHeight, m_imageListIcons.GetImageSize ().cy + 2 * nIconMargin);
}
开发者ID:zxlooong,项目名称:bcgexp,代码行数:26,代码来源:customcells.cpp

示例7: eraseDataText

void CComputer::eraseDataText(CClientDC &dc)
{
	dc.SetTextColor(white);
	originalFont = dc.SelectObject(&dataFont);
	drawDataText(dc);
	dc.SelectObject(&originalFont);
}
开发者ID:flomar,项目名称:CrypTool-VS2015,代码行数:7,代码来源:Computer.cpp

示例8: CenterText

void CBigIcon::CenterText(CClientDC &dc, LPCSTR lpszStatus, int top)
{
	int			nMargin;
	CRect		rect;
	TEXTMETRIC	tm;

	// Leave a horizontal margin equal to the widest character
	VERIFY(dc.GetTextMetrics(&tm));
	nMargin = tm.tmMaxCharWidth;

	// Compute the opaque rect
	rect.left = nMargin;
	rect.right = m_sizeBitmap.cx - nMargin;
	rect.top = top;
	rect.bottom = rect.top + tm.tmHeight;

	// We need to compute where to draw the text so it is centered
	// horizontally
	int		x = rect.left;
    CSize   extent = CIntlWin::GetTextExtent(0, dc.m_hDC, lpszStatus, XP_STRLEN(lpszStatus));

	if (extent.cx < rect.Width())
		x += (rect.Width() - extent.cx) / 2;

	// Draw opaquely so we can avoid erasing the old text
	dc.ExtTextOut(x, rect.top, ETO_OPAQUE, &rect, lpszStatus, strlen(lpszStatus), NULL);


}
开发者ID:vicamo,项目名称:b2g_mozilla-central,代码行数:29,代码来源:splash.cpp

示例9: AfxGetApp

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CBCGPMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	HICON m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
	SetIcon(m_hIcon, TRUE); // Set big icon

	// Menu will not take the focus on activation:
	CBCGPPopupMenu::SetForceMenuFocus (FALSE);

	EnableDocking(CBRS_ALIGN_TOP);

	if (!m_wndMenuBar.Create (this))
	{
		TRACE0("Failed to create menubar\n");
		return -1;      // fail to create
	}

	m_wndMenuBar.SetBarStyle(m_wndMenuBar.GetBarStyle() | CBRS_SIZE_DYNAMIC);
	m_wndMenuBar.SetRecentlyUsedMenus(FALSE); //不加这句话,菜单初始时,只显示一个下拉键头,不显示全部菜单项.
	// Detect color depth. 256 color toolbars can be used in the
	// high or true color modes only (bits per pixel is > 8):
	CClientDC dc (this);
	BOOL bIsHighColor = dc.GetDeviceCaps (BITSPIXEL) > 8;

	UINT uiToolbarHotID = bIsHighColor ? IDB_TOOLBAR256 : 0;

	if (!m_wndStatusBar.Create(this) ||
		!m_wndStatusBar.SetIndicators(indicators,
		  sizeof(indicators)/sizeof(UINT)))
	{
		TRACE0("Failed to create status bar\n");
		return -1;      // fail to create
	}
	// TODO: Delete these three lines if you don't want the toolbar to be dockable
	m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
	EnableDocking(CBRS_ALIGN_ANY);
	EnableAutoHideBars(CBRS_ALIGN_ANY);
	DockControlBar(&m_wndMenuBar);

	CreateMineToolBar(); // 创建工具栏
	m_MineToolbar.EnableDocking(CBRS_ALIGN_ANY);
	DockControlBar(&m_MineToolbar);
	// Allow user-defined toolbars operations:
	InitUserToobars (NULL,
					uiFirstUserToolBarId,
					uiLastUserToolBarId);

	AdjustClientArea();
	// Enable windows manager:
	EnableWindowsDialog (ID_WINDOW_MANAGER, IDS_WINDOWS_MANAGER, TRUE);
	OnAppLook (m_nAppLook);

	SetWindowText("综合设计环境");
	SetTitle( "综合设计环境" );
	// VISUAL_MANAGER
	return 0;
}
开发者ID:cugxiangzhenwei,项目名称:MySrcCode,代码行数:59,代码来源:MainFrm.cpp

示例10: draw

void CListSelector::draw(CClientDC &dc, int orgX, int orgY, int width, int height)
{
	
	
	list<CSelectorItem>::iterator iter;
	
	int y0 = orgY;
	int y1 = orgY;
	
	int x0 = orgX;
	int x1 = orgX + width;

	
	//dc.Rectangle(orgX,orgY,orgX + width,orgY + height);
	
	int size=this->itemList.size();

	//dc.LineTo(x1,y1);
	int count=9;
	int start=4;
	int isNeedBreak=FALSE;

	int j=0;

	for(int i= -4 + focusIndex ; 
		i<= 4 + focusIndex;
		i++)
	{

		y0 = orgY + (j)*40;
		y1 = y0 + 40;
		CRect rect2(x0, y0+1, x1, y1);
		dc.Rectangle(&rect2);

		if(i==focusIndex)
		{
			CBrush *p=new CBrush();
			p->CreateSolidBrush(RGB(200,0,000));
			dc.FillRect(&rect2,p);
			dc.SetTextColor(RGB(255,255,255));
			delete p;
		}else{
			dc.SetTextColor(RGB(0,0,0));
		}

		int index = 0;
		if(i<0){
			index = (size*0X100000 + i) % size  ;
		}else{
			index=i % size ;
		}

		CString str(itemList[ index  ].getValue().c_str());		
		dc.DrawText(str,&rect2,DT_CENTER|DT_VCENTER|DT_SINGLELINE);
		j++;
	
	}	
	
}
开发者ID:philipgreat,项目名称:cplusplus-windows-test-apps,代码行数:59,代码来源:ListSelector.cpp

示例11: CSize

CSize CBCGPPopupDlg::GetOptimalTextSize (CString str)
{
	if (str.IsEmpty ())
	{
		return CSize (0, 0);
	}

	CRect rectScreen;

	CRect rectDlg;
	GetWindowRect (rectDlg);

	MONITORINFO mi;
	mi.cbSize = sizeof (MONITORINFO);
	if (GetMonitorInfo (MonitorFromPoint (rectDlg.TopLeft (), MONITOR_DEFAULTTONEAREST), &mi))
	{
		rectScreen = mi.rcWork;
	}
	else
	{
		::SystemParametersInfo (SPI_GETWORKAREA, 0, &rectScreen, 0);
	}

	CClientDC dc (this);

	CFont* pOldFont = dc.SelectObject (&globalData.fontRegular);
	ASSERT_VALID (pOldFont);

	int nStepY = globalData.GetTextHeight ();
	int nStepX = nStepY * 3;

	CRect rectText (0, 0, nStepX, nStepY);

	for (;;)
	{
		CRect rectTextSaved = rectText;

		int nHeight = dc.DrawText (str, rectText, DT_CALCRECT | DT_WORDBREAK | DT_NOPREFIX);
		int nWidth = rectText.Width ();

		rectText = rectTextSaved;

		if (nHeight <= rectText.Height () ||
			rectText.Width () > rectScreen.Width () ||
			rectText.Height () > rectScreen.Height ())
		{
			rectText.bottom = rectText.top + nHeight + 5;
			rectText.right = rectText.left + nWidth + 5;
			break;
		}

		rectText.right += nStepX;
		rectText.bottom += nStepY;
	}

	dc.SelectObject (pOldFont);
	return rectText.Size ();
}
开发者ID:cugxiangzhenwei,项目名称:WorkPlatForm,代码行数:58,代码来源:BCGPPopupDlg.cpp

示例12: dc

void CCGuiFlatTabbedViewView::OnSize(UINT nType, int cx, int cy) 
{
	CGuiViewWorkTab::OnSize(nType, cx, cy);
	CClientDC dc (this);
	CString strItem;
	m_wndEdit.GetText (90, strItem);
	int cxExtentMax = 0;
	cxExtentMax = dc.GetTextExtent (strItem).cx;
	m_wndEdit.SetHorizontalExtent (cxExtentMax);
	
	// TODO: Add your message handler code here
	
}
开发者ID:ZhaoboMeng,项目名称:k-line-print,代码行数:13,代码来源:CGuiFlatTabbedViewView.cpp

示例13: dc

void CDlgCalcDlg::UpdateDisplay(LPCTSTR pszDisplay)
{
    CClientDC dc (this);
    CFont* pOldFont = dc.SelectObject (GetFont ());
    CSize size = dc.GetTextExtent (pszDisplay);

    CRect rect = m_rect;
    rect.InflateRect (-2, -2);
    int x = rect.right - size.cx - m_cxChar;
    int y = rect.top + ((rect.Height () - m_cyChar) / 2);

    dc.ExtTextOut (x, y, ETO_OPAQUE, rect, pszDisplay, NULL);
    dc.SelectObject (pOldFont);
}
开发者ID:jiayuehua,项目名称:MFCProgramming,代码行数:14,代码来源:DlgCalcDlg.cpp

示例14: ASSERT

//******************************************************************************
void CBCGPRibbonCommandsListBox::MeasureItem(LPMEASUREITEMSTRUCT lpMIS)
{
	ASSERT (lpMIS != NULL);

	CClientDC dc (this);
	CFont* pOldFont = (CFont*) dc.SelectStockObject (DEFAULT_GUI_FONT);
	ASSERT_VALID (pOldFont);

	TEXTMETRIC tm;
	dc.GetTextMetrics (&tm);

	lpMIS->itemHeight = tm.tmHeight + 6;

	dc.SelectObject (pOldFont);
}
开发者ID:iclosure,项目名称:jframework,代码行数:16,代码来源:BCGPRibbonCommandsListBox.cpp

示例15: DrwaWaveChar

void CAudioCtrl::DrwaWaveChar(CClientDC &dc, DWORD dwDrawBytes, BYTE *pCharData, BOOL bLeftChannel)
{
	CRect rcBK = GetRectByChannel ( bLeftChannel );
	int y = (int) ( pCharData[0] * rcBK.Height() / 0xff );
	dc.MoveTo ( 0, y );
	float fStep = (float)rcBK.Width() / (float)(dwDrawBytes);
	float fLineX = 0;
	for ( DWORD i=1; i<dwDrawBytes; i++ )
	{
		fLineX += fStep;
		y = (int) ( pCharData[i] * rcBK.Height() / 0xff );
		dc.LineTo ( (int)fLineX, y );
		//TRACE2("DrawWave X=%f Y=%d\r\n", fLineX, y);
	}
}
开发者ID:weiwei22844,项目名称:AVProject,代码行数:15,代码来源:AudioCtrl.cpp


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