本文整理汇总了C++中CBrush::CreateBrushIndirect方法的典型用法代码示例。如果您正苦于以下问题:C++ CBrush::CreateBrushIndirect方法的具体用法?C++ CBrush::CreateBrushIndirect怎么用?C++ CBrush::CreateBrushIndirect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBrush
的用法示例。
在下文中一共展示了CBrush::CreateBrushIndirect方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Draw
void CDrawPoly::Draw(CDC* pDC)
{
ASSERT_VALID(this);
CBrush brush;
if (!brush.CreateBrushIndirect(&m_logbrush))
return;
CPen pen;
if (!pen.CreatePenIndirect(&m_logpen))
return;
CBrush* pOldBrush;
CPen* pOldPen;
if (m_bBrush)
pOldBrush = pDC->SelectObject(&brush);
else
pOldBrush = (CBrush*)pDC->SelectStockObject(NULL_BRUSH);
if (m_bPen)
pOldPen = pDC->SelectObject(&pen);
else
pOldPen = (CPen*)pDC->SelectStockObject(NULL_PEN);
pDC->Polygon(m_points, m_nPoints);
pDC->SelectObject(pOldBrush);
pDC->SelectObject(pOldPen);
}
示例2: Draw
void CEllipse::Draw(CDC *pDC)
{
if(m_lStatus!=ST_NOMAL) return;
LOGPEN tPen=m_pen;
UPtoLP(m_pen.lopnWidth.x,m_pen.lopnWidth.y,&tPen.lopnWidth.x,&tPen.lopnWidth.y);
CPen pen;
pen.CreatePenIndirect(&tPen);
CPen *pOldPen=pDC->SelectObject(&pen);
CBrush brush;
brush.CreateBrushIndirect(&m_brush);
CBrush *pOldBrush=pDC->SelectObject(&brush);
pDC->SetBkMode(TRANSPARENT);
long x1,y1,x2,y2;
x1=m_lx1;
y1=m_ly1;
if(m_lx1>m_lx2){
m_lx1=m_lx2;
m_lx2=x1;
}
if(m_ly1>m_ly2){
m_ly1=m_ly2;
m_ly2=y1;
}
UPtoLP(m_lx1,m_ly1,&x1,&y1);
UPtoLP(m_lx2,m_ly2,&x2,&y2);
pDC->Ellipse(x1,y1,x2,y2);
pDC->SelectObject(pOldPen);
pDC->SelectObject(pOldBrush);
}
示例3: DrawSymbol
void DrawSymbol(CDC *pDC, int x, int y, int length, int width, COLORREF color, DSYMBOL symbol, bool bFill, int angle)
{
//TRACE("Entering CGraphLine::DrawSymbol\n");
int l = length; // velkost krizika
double PI = 3.1415926535897932384626433832795;
CPen pen, *pPen;
pen.CreatePen(PS_SOLID, width, color);
pPen = pDC->SelectObject(&pen);
if(symbol == CROSS) {
pDC->MoveTo(x+l, y);
pDC->LineTo(x-l, y);
pDC->MoveTo(x, y+l);
pDC->LineTo(x, y-l);
return;
}
if(symbol == ARROW) {
pDC->MoveTo(x, y);
int xx = int (x + 3*l*cos(angle/10*PI/180)),
yy = int (y + 3*l*sin(angle/10*PI/180));
pDC->LineTo(xx, yy);
return;
}
if( (symbol == CIRCLE) || (symbol == RECTANGLE)) {
LOGBRUSH logBrush;
if(bFill) {
logBrush.lbStyle = BS_SOLID;
}
else {
logBrush.lbStyle = BS_HOLLOW;
}
logBrush.lbColor = color;
logBrush.lbHatch = HS_CROSS;
CBrush brush;
brush.CreateBrushIndirect(&logBrush);
CBrush* pOldBrush = (CBrush*)pDC->SelectObject(&brush);
if(symbol == CIRCLE) {
pDC->Ellipse(x-l, y-l, x+l, y+l);
}
if(symbol == RECTANGLE) {
pDC->Rectangle(x-l, y-l, x+l, y+l);
}
pDC->SelectObject(pOldBrush);
}
pDC->SelectObject( pPen );
}
示例4: OnMouseMove
void CRectTool::OnMouseMove(_CVIEW* pView, UINT nFlags, CPoint& point)
{
CDC* pDC = NULL;
pDC = pView->GetDC();
if (pDC == NULL) return;
CMiniCADDoc* pDoc = pView->GetDocument();
if (pDoc==NULL)return;
CADGraphics *pGraphics = &pDoc->m_Graphics;
CDisplay *pDisplay = pGraphics->m_pDisplay;
if (pDisplay == NULL) return;
if (pDoc->m_Graphics.m_GraphicsMode==Layout)
SetCursor(AfxGetApp()->LoadCursor(IDC_DRAW_B));
else
SetCursor(AfxGetApp()->LoadCursor(IDC_DRAW_W));
if (c_bSnap)
{
pDoc->m_Graphics.m_bSnapStatus=true;
pDoc->m_Graphics.SnapHandle(pDC,point);
}
if (c_nDown!=1)
{
DeleteDC(pDC->m_hDC);
return;
}
CPen Pen;
if (!Pen.CreatePen(PS_SOLID, 1, RGB(255,255,255)))
return;
CPen* pOldPen = pDC->SelectObject(&Pen);
LOGBRUSH logBrush;
logBrush.lbColor = 0;
logBrush.lbHatch = 0;
logBrush.lbStyle = BS_NULL;
CBrush NullBrush;
NullBrush.CreateBrushIndirect(&logBrush);
CBrush* pOldBrush = pDC->SelectObject(&NullBrush);
int oldDrawMode = pDC->SetROP2(R2_XORPEN);
if (!c_bJustDraw)
pDC->Rectangle(c_PtDown.x,c_PtDown.y,c_PtOld.x,c_PtOld.y);
c_bJustDraw = false;
pDC->Rectangle(c_PtDown.x,c_PtDown.y,point.x,point.y);
pDC->SetROP2(oldDrawMode);
pDC->SelectObject(pOldPen);
pDC->SelectObject(pOldBrush);
Pen.DeleteObject();
DeleteDC(pDC->m_hDC);
CDrawTool::OnMouseMove(pView, nFlags, point);
}
示例5: CreateImageList
void CFolderListCtrl::CreateImageList()
{
CImageList * pImgList = new CImageList;
pImgList->Create( m_Properties.m_nItemCX, m_Properties.m_nItemCY, ILC_COLOR, 32, 32 );
CDC * pdcThis = GetDC();
CDC dcBmp;
CBitmap bmpRes;
dcBmp.CreateCompatibleDC( pdcThis );
bmpRes.CreateCompatibleBitmap( pdcThis, m_Properties.m_nItemCX, m_Properties.m_nItemCY );
CBitmap * pbmpOld = static_cast<CBitmap*>(dcBmp.SelectObject( &bmpRes ));
CRect r( 0, 0, m_Properties.m_nItemCX, m_Properties.m_nItemCY );
LOGBRUSH lbBackground;
ReleaseDC( pdcThis );
lbBackground.lbColor = RGB( 255, 255, 255 );
lbBackground.lbHatch = 0;
lbBackground.lbStyle = BS_SOLID;
CBrush brBackground;
brBackground.CreateBrushIndirect( &lbBackground );
dcBmp.FillRect( r, &brBackground );
dcBmp.Rectangle( r );
dcBmp.MoveTo( 0, 0 );
dcBmp.LineTo( m_Properties.m_nItemCX, m_Properties.m_nItemCY );
dcBmp.MoveTo( m_Properties.m_nItemCX, 0 );
dcBmp.LineTo( 0, m_Properties.m_nItemCY );
dcBmp.SelectObject( pbmpOld );
dcBmp.DeleteDC();
if( m_pimlThumbnails )
{
for( int i = m_pimlThumbnails->GetImageCount() - 1; i >= 0; i-- )
m_pimlThumbnails->Remove( i );
delete m_pimlThumbnails;
}
pImgList->Add( &bmpRes, RGB( 0, 0, 0 ) );
m_pimlThumbnails = pImgList;
if( m_flvtViewType == flvtThumbnail )
SetImageList( pImgList, LVSIL_NORMAL );
}
示例6: OnLButtonDown
void CRectTool::OnLButtonDown(_CVIEW * pView, UINT nFlags, CPoint& point)
{
CDC* pDC = NULL;
pDC = pView->GetDC();
if (pDC == NULL) return;
CMiniCADDoc* pDoc = pView->GetDocument();
if (pDoc==NULL)return;
CADGraphics *pGraphics = &pDoc->m_Graphics;
CDisplay *pDisplay = pGraphics->m_pDisplay;
if (pDisplay == NULL) return;
if (c_nDown==0)
{
/// c_PtDown=point;
CPen Pen;
if (!Pen.CreatePen(PS_SOLID, 1, RGB(255,255,255)))
return;
CPen* pOldPen = pDC->SelectObject(&Pen);
LOGBRUSH logBrush;
logBrush.lbColor = 0;
logBrush.lbHatch = 0;
logBrush.lbStyle = BS_NULL;
CBrush NullBrush;
NullBrush.CreateBrushIndirect(&logBrush);
CBrush* pOldBrush = pDC->SelectObject(&NullBrush);
int oldDrawMode = pDC->SetROP2(R2_XORPEN);
pView->m_pTempEntity=new CADPolyline();
CADPolyline* pPolyline=(CADPolyline*)pView->m_pTempEntity;
pView->SetProjectLineWidth(pPolyline);
pPolyline->m_nLayer=pDoc->m_LayerGroup.indexOf(pDoc->m_curLayer);
pPolyline->m_Closed=true;
if(c_bSnap && pDoc->m_Graphics.m_bHaveSnap)
{
ADPOINT* pPoint=new ADPOINT();
*pPoint = pDoc->m_Graphics.m_curSnapP;
pPolyline->m_Point.Add((CObject*)pPoint);
c_PtDown = pDoc->m_Graphics.DocToClient(pDoc->m_Graphics.m_curSnapP);
c_PtOld = point;
} else
{
ADPOINT* pPoint=new ADPOINT();
*pPoint = pDoc->m_Graphics.ClientToDoc(point);
pPolyline->m_Point.Add((CObject*)pPoint);
c_PtDown = point;
c_PtOld = point;
}
pDC->Rectangle(point.x,point.y,point.x,point.y);
pDC->SetROP2(oldDrawMode);
pDC->SelectObject(pOldPen);
pDC->SelectObject(pOldBrush);
Pen.DeleteObject();
}
if (c_nDown<2)
c_nDown++;
if (c_nDown==2)
{
c_nDown=0;
ADPOINT adPoint;
if (c_bSnap && pDoc->m_Graphics.m_bHaveSnap)
{
adPoint=pDoc->m_Graphics.m_curSnapP;
} else
{
adPoint=pDoc->m_Graphics.ClientToDoc(point);
}
CADPolyline* pPolyline=(CADPolyline*)pView->m_pTempEntity;
ADPOINT* pPoint1=(ADPOINT*)pPolyline->m_Point.GetAt(0);
ADPOINT* pPoint=new ADPOINT();
pPoint->x = adPoint.x;
pPoint->y = pPoint1->y;
pPolyline->m_Point.Add((CObject*)pPoint);
pPoint=new ADPOINT();
*pPoint = adPoint;
pPolyline->m_Point.Add((CObject*)pPoint);
pPoint=new ADPOINT();
pPoint->x = pPoint1->x;
pPoint->y = adPoint.y;
pPolyline->m_Point.Add((CObject*)pPoint);
pDoc->m_Graphics.m_Entities.Add((CObject*)pPolyline);
pDoc->m_Graphics.DrawGraphics(pDisplay->GetDC(),pView->m_pTempEntity);
pView->m_pTempEntity=NULL;
pView->ReBitBlt();
}
DeleteDC(pDC->m_hDC);
//CDrawTool::OnLButtonDown(pView, nFlags, point);
}
示例7: OnPaint
void CVideoWnd::OnPaint()
{
CPaintDC dc(this);
//WIDTHHEIGHT
CRect clrect(m_rectWnd);
clrect.right -= clrect.left;
clrect.bottom -= clrect.top;
clrect.left = 0;
clrect.top = 0;
int width = clrect.right - clrect.left;
int height = clrect.bottom - clrect.top;
CRect cRect(clrect);
CDC memDC;
memDC.CreateCompatibleDC(&dc);
CDC *pDC = &memDC;
CBitmap NewMemBmp;
NewMemBmp.CreateCompatibleBitmap(&dc, width, height);
CBitmap* pOldMemBmp = pDC->SelectObject(&NewMemBmp);
if (!m_iStatus) {
pDC->FillSolidRect(0, 0, clrect.Width(), clrect.Height(), RGB(255,255,255));
} else if (m_ImageBitmap.GetSafeHandle()) {
m_ImageBitmap.BitBlt(pDC, CPoint(0,0));
}
CFont dxfont;
dxfont.CreateFontIndirect(&m_textfont);
CFont* oldfont = (CFont *) pDC->SelectObject(&dxfont);
//Draw Text
int textlength = m_textstring.GetLength(); //get number of bytes
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(m_rgb);
pDC->DrawText((char *)LPCTSTR(m_textstring), textlength, &m_tracker.m_rect, m_horzalign | DT_VCENTER | DT_WORDBREAK );
pDC->SelectObject(oldfont);
if ((m_bBorderYes) && (regionSHAPE == m_regionType)) {
double rx = cRect.Width() * m_roundrectFactor;
double ry = cRect.Height() * m_roundrectFactor;
double rval = (rx > ry) ? ry : rx;
CPen borderPen;
borderPen.CreatePen( PS_SOLID , m_borderSize, m_borderColor );
CPen* oldPen = (CPen *) pDC->SelectObject(&borderPen);
LOGBRUSH logbrush;
logbrush.lbStyle = BS_HOLLOW;
CBrush borderBrush;
borderBrush.CreateBrushIndirect(&logbrush);
CBrush* oldBrush = (CBrush *) pDC->SelectObject(&borderBrush);
int drawOffset = m_borderSize/2;
if (m_regionPredefinedShape == regionROUNDRECT) {
pDC->RoundRect(drawOffset-1, drawOffset-1, cRect.Width()-1-drawOffset, cRect.Height()-1-drawOffset, (int) rval, (int) rval);
} else if (m_regionPredefinedShape == regionELLIPSE) {
pDC->Ellipse(drawOffset-1,drawOffset-1, cRect.Width()-1-drawOffset, cRect.Height()-1-drawOffset);
} else if (m_regionPredefinedShape == regionRECTANGLE) {
pDC->Rectangle(drawOffset-1, drawOffset-1, cRect.Width()-1-drawOffset, cRect.Height()-1-drawOffset);
}
pDC->SelectObject(oldBrush);
pDC->SelectObject(oldPen);
borderPen.DeleteObject();
borderBrush.DeleteObject();
}
CDC *pWinDC = &dc;
pWinDC->BitBlt(0,0,clrect.Width(),clrect.Height(),pDC,0,0,SRCCOPY);
pDC->SelectObject(pOldMemBmp);
NewMemBmp.DeleteObject();
memDC.DeleteDC();
if (m_bTrackingOn) {
m_tracker.Draw(pWinDC);
}
}