示例#1
0
// Create the "4 corner" region surrounding cRect
void CFlashingWnd::MakeFixedRegion(CRgn &wndRgn, CRgn &rgnTemp, CRgn &rgnTemp2, CRgn &rgnTemp3)
{
	CRect rectWnd(0, 0, m_cRect.Width() + THICKNESS + THICKNESS, m_cRect.Height() + THICKNESS + THICKNESS);
	CRect rectTemp(THICKNESS, THICKNESS, m_cRect.Width() + THICKNESS + 1, m_cRect.Height() + THICKNESS + 1);
	CRect rectTemp2(0, SIDELEN2, m_cRect.Width() + THICKNESS + THICKNESS, m_cRect.Height() - SIDELEN + 1);
	CRect rectTemp3(SIDELEN2, 0, m_cRect.Width() - SIDELEN + 1, m_cRect.Height() + THICKNESS + THICKNESS);

	VERIFY(wndRgn.CreateRectRgnIndirect(rectWnd));
	VERIFY(rgnTemp.CreateRectRgnIndirect(rectTemp));
	VERIFY(rgnTemp2.CreateRectRgnIndirect(rectTemp2));
	VERIFY(rgnTemp3.CreateRectRgnIndirect(rectTemp3));

	VERIFY(ERROR != wndRgn.CombineRgn(&wndRgn, &rgnTemp, RGN_DIFF));
	VERIFY(ERROR != wndRgn.CombineRgn(&wndRgn, &rgnTemp2, RGN_DIFF));
	VERIFY(ERROR != wndRgn.CombineRgn(&wndRgn, &rgnTemp3, RGN_DIFF));

	VERIFY(ERROR != wndRgn.OffsetRgn(m_cRect.left - THICKNESS, m_cRect.top - THICKNESS));
}
示例#2
0
//*****************************************************************************
//
// Function Name: DrawPushLikeCell( LPDRAWITEMSTRUCT lpDrawItemStruct )
//
// Description:   An application calls the SetCellDimensions member 
//                function to set the height and width of cells in 
//                a grid control. 
//
// Returns:	      None
//
// Exceptions:	   None
//
//*****************************************************************************
void RGridCtrlBase::DrawPushLikeCell( LPDRAWITEMSTRUCT lpDrawItemStruct ) const
{
	CDC dc ;
	dc.Attach( lpDrawItemStruct->hDC ) ;

	RECT& rect = lpDrawItemStruct->rcItem ;
//	CRect rectTemp = rect ;

	//
	// Erase the background
	//
	dc.FillSolidRect( &rect, GetSysColor( COLOR_BTNFACE ) ) ;

	//
	// Draw the cell in a pushlike state
	//
	if (lpDrawItemStruct->itemState & ODS_SELECTED)
	{
		dc.Draw3dRect( rect.left, rect.top,
			(rect.right - rect.left + 1), 
			(rect.bottom - rect.top + 1),
			RGB( 0, 0, 0 ),	GetSysColor( COLOR_BTNHILIGHT ) ) ;

		CPen pen(PS_SOLID, 1, GetSysColor( COLOR_BTNSHADOW )) ;
		CPen *pOldPen = dc.SelectObject( &pen ) ;

		dc.MoveTo( rect.left + 1, rect.bottom - 1 ) ;
		dc.LineTo( rect.left + 1, rect.top + 1 ) ;
		dc.LineTo( rect.right, rect.top + 1) ;

		dc.SelectObject( pOldPen ) ;

		// Update the drawing rect
		rect.top += 2 ;	rect.left += 2 ;
		rect.bottom-- ; rect.right-- ;

		try
		{
			/*static*/ CBitmap bmpPattern ;

//			if (!bmpPattern.GetSafeHandle())
//			{
				static BITMAP   bitmap = { 0, 8, 8, 2, 1, 1 } ;
				static WORD wPatternBits[] = 
				{ 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA } ;

				bitmap.bmBits = (LPSTR) wPatternBits ;
				bmpPattern.CreateBitmapIndirect (&bitmap) ;
//			}

			CBrush   brush (&bmpPattern) ;
			COLORREF crOldBackColor = dc.SetBkColor(GetSysColor (COLOR_BTNFACE)) ;
			COLORREF crOldTextColor = dc.SetTextColor(GetSysColor (COLOR_BTNHILIGHT)) ;

			CRect rectTemp(rect.left + 1, rect.top + 1, rect.right, rect.bottom) ;

			dc.FillRect (&rectTemp, &brush) ;
			dc.SetBkColor (crOldBackColor) ;
			dc.SetTextColor (crOldTextColor) ;
		}
		catch (CResourceException& /*e*/)
		{
			// REVIEW: Put some type of error message here?
		}
	}
	else 
	{
		dc.Draw3dRect( &rect, 
			GetSysColor( COLOR_BTNHILIGHT ),
			GetSysColor( COLOR_BTNSHADOW ) ) ;

		dc.MoveTo( rect.left, rect.bottom ) ;
		dc.LineTo( rect.right, rect.bottom ) ;
		dc.LineTo( rect.right, rect.top - 1 ) ;

		// Update the drawing rect
		rect.bottom -= 2 ;	rect.right -= 2 ;
		rect.top++ ; rect.left++ ;
	}

	dc.Detach() ;
}
示例#3
0
CSize CPopupWnd::GetContentDlgSize( CDialog* pDlg, UINT nID )
{
	CSize sizeDlg;
	typedef struct {
		WORD dlgVer;
		WORD signature;
		DWORD helpID;
		DWORD exStyle;
		DWORD style;
		WORD cDlgItems;
		short x;
		short y;
		short cx;
		short cy;
		// 后面的属性不能直接用,要根据具体的情况分析,是变长结构
		// ...
	} DLGTEMPLATEEX;

	//
	LPCTSTR lpszName = MAKEINTRESOURCE( nID );
	HINSTANCE hInstance = AfxFindResourceHandle( lpszName, RT_DIALOG ); 
	HRSRC hResource = ::FindResource( hInstance, lpszName, RT_DIALOG );
	HGLOBAL hTemplate = LoadResource( hInstance, hResource);

	DLGTEMPLATE* pTemplate;
	WORD *pDlgTemplateTemp = NULL;
	int nPageWidth = 0;
	int nPageHeight = 0;

	pTemplate = (DLGTEMPLATE*)(LPCDLGTEMPLATE)LockResource(hTemplate);
	// 判断是哪一种 dlg 模板
	pDlgTemplateTemp = (WORD*)pTemplate;
	if ( pDlgTemplateTemp[1] == 0xFFFF )
	{
		// 扩展模板
		DLGTEMPLATEEX *pTemplateEx = (DLGTEMPLATEEX*)pTemplate;
		nPageWidth = pTemplateEx->cx;
		nPageHeight = pTemplateEx->cy;

	}
	else
	{
		nPageWidth = pTemplate->cx;
		nPageHeight = pTemplate->cy;
	}

	//

	UnlockResource(hTemplate);

	// dialog模板使用的是 dialog unit, 需要转换成 pixel unit 
	CRect rectTemp( 0, 0, nPageWidth, nPageHeight);
	::MapDialogRect( pDlg->GetSafeHwnd(), &rectTemp );

	sizeDlg.cx = rectTemp.Width();
	sizeDlg.cy = rectTemp.Height();

	//
	return sizeDlg;

}
示例#4
0
void CChartLegend::Draw(CDC *pDC)
{
	if (!pDC->GetSafeHdc())
		return;
	if (!m_bIsVisible)
		return;
	if (m_ObjectRect.IsRectEmpty())
		return;

	CPen SolidPen(PS_SOLID,0,RGB(0,0,0));
	CPen* pOldPen;
	CFont* pOldFont;
	CFont NewFont;
	NewFont.CreatePointFont(m_iFontSize,m_strFontName.c_str(),pDC);

	// Draw the shadow
	if (m_bShadow)
	{
		CRect ShadowRect = m_ObjectRect;
		ShadowRect.OffsetRect(m_iShadowDepth,m_iShadowDepth);
		CBrush BrushShadow;
		BrushShadow.CreateSolidBrush(m_ShadowColor) ;
		pDC->FillRect(ShadowRect,&BrushShadow);
	}

	if (!m_bIsTransparent)
	{
		//Fill back color
		CBrush BrushBack;
		BrushBack.CreateSolidBrush(m_ObjectColor) ;
		pDC->FillRect(m_ObjectRect,&BrushBack);
	}

	pOldFont = pDC->SelectObject(&NewFont);
	pOldPen = pDC->SelectObject(&SolidPen);

	//Draw rectangle:
	pDC->MoveTo(m_ObjectRect.left,m_ObjectRect.top);
	pDC->LineTo(m_ObjectRect.right,m_ObjectRect.top);
	pDC->LineTo(m_ObjectRect.right,m_ObjectRect.bottom);
	pDC->LineTo(m_ObjectRect.left,m_ObjectRect.bottom);
	pDC->LineTo(m_ObjectRect.left,m_ObjectRect.top);

	int iPrevMode = pDC->SetBkMode(TRANSPARENT);
	CRect rectBitmap(m_ObjectRect.left+2,m_ObjectRect.top+5,
					 m_ObjectRect.left+2+m_BitmapSize.cx,
					 m_ObjectRect.top+6+m_BitmapSize.cy);
	int SeriesCount = m_pParent->GetSeriesCount();
	for (int i=0;i<SeriesCount;i++)
	{
		CChartSerie* pSerie = m_pParent->GetSerie(i);
		if ( (pSerie->GetName() == _T("")) || !pSerie->IsVisible() )
			continue;

		int MaxHeight = 0;
		CSize TextSize = pDC->GetTextExtent(pSerie->GetName().c_str());
		if (TextSize.cy > m_BitmapSize.cy)
		{
			pDC->ExtTextOut(rectBitmap.right+4,rectBitmap.top,ETO_CLIPPED,NULL,pSerie->GetName().c_str(),NULL);
			CRect rectTemp(rectBitmap);
			int YOffset = TextSize.cy/2 - rectBitmap.Height()/2;
			rectTemp.OffsetRect(0,YOffset);
			pSerie->DrawLegend(pDC,rectTemp);
			MaxHeight = TextSize.cy;
		}
		else
		{
			int YOffset = rectBitmap.CenterPoint().y - TextSize.cy/2;
			pDC->ExtTextOut(rectBitmap.right+4,YOffset,ETO_CLIPPED,NULL,pSerie->GetName().c_str(),NULL);
			MaxHeight = m_BitmapSize.cy;
			pSerie->DrawLegend(pDC,rectBitmap);
		}
		

		if (!m_bIsHorizontal)
			rectBitmap.OffsetRect(0,MaxHeight+2);
		else
			rectBitmap.OffsetRect(m_BitmapSize.cx+4+TextSize.cx+10,0);
	}

	pDC->SetBkMode(iPrevMode);
	pDC->SelectObject(pOldFont);
	DeleteObject(NewFont);
	pDC->SelectObject(pOldPen);
	DeleteObject(SolidPen);
}
示例#5
0
CSDWindow::CSDWindow(POINT point, SIZE size)
{
	CRect rectTemp(point, size);

	CopyRect(rectTemp);
}