本文整理汇总了C++中CBrush::CreateHatchBrush方法的典型用法代码示例。如果您正苦于以下问题:C++ CBrush::CreateHatchBrush方法的具体用法?C++ CBrush::CreateHatchBrush怎么用?C++ CBrush::CreateHatchBrush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBrush
的用法示例。
在下文中一共展示了CBrush::CreateHatchBrush方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw
void GEllipse::draw(CDC* dc)
{
CPen pen(this->getPattern(), this->getThick(), this->getLineColor());
dc->SelectObject(&pen);
CBrush brush;
brush.CreateHatchBrush(this->getFillPattern(), this->getFillColor());
dc->SelectObject(&brush);
// 처음에 색이 NULL 이면 투명으로
if (this->getFillColor() == NULL)
dc->SelectStockObject(NULL_BRUSH);
// 원 그리기는 여기서부터
dc->MoveTo(getStartX(), getStartY());
dc->Ellipse(this->getStartX(), this->getStartY(), GetEnd().x, GetEnd().y);
if (this->getSelected() == TRUE){
CPen pen2(PS_SOLID, 0, RGB(0, 0, 0));
dc->SelectObject(&pen2);
CBrush brush2(RGB(255, 255, 255));
dc->SelectObject(&brush2);
m_selectedRect[0] = new CRect(this->getStartX() - 5, this->getStartY() - 5, this->getStartX() + 5, this->getStartY() + 5);
m_selectedRect[1] = new CRect(this->getEndX() - 5, this->getStartY() - 5, this->getEndX() + 5, this->getStartY() + 5);
m_selectedRect[2] = new CRect(this->getStartX() - 5, this->getEndY() - 5, this->getStartX() + 5, this->getEndY() + 5);
m_selectedRect[3] = new CRect(this->getEndX() - 5, this->getEndY() - 5, this->getEndX() + 5, this->getEndY() + 5); // 메모리 누수의 위험 있음. 수정바람!
dc->Rectangle(m_selectedRect[0]);
dc->Rectangle(m_selectedRect[1]);
dc->Rectangle(m_selectedRect[2]);
dc->Rectangle(m_selectedRect[3]);
}
}
示例2: FillDest
void TTransRemain::FillDest( TImage<unsigned char> &image,
TPoint2D<int> &upCentre,
TPoint2D<int> &downCentre,
HDC &memHDC,
const size_t radius)
{
CBrush bush;
bush.CreateHatchBrush(HS_CROSS, RGB(255,255,255));
CRgn upRgn;
upRgn.CreateEllipticRgn( upCentre.x()- radius, upCentre.y()-radius,
upCentre.x()+ radius, upCentre.y()+radius);
FillRgn(memHDC , upRgn, bush);
CRgn downRgn;
downRgn.CreateEllipticRgn( downCentre.x()-radius, downCentre.y()-radius,
downCentre.x()+radius, downCentre.y()+radius);
FillRgn(memHDC,downRgn, bush);
CRgn midRgn;
POINT midRect[4];
midRect[0].x = upCentre.x()-radius;
midRect[0].y = upCentre.y();
midRect[1].x = downCentre.x()-radius;
midRect[1].y = downCentre.y();
midRect[2].x = downCentre.x()+radius;
midRect[2].y = downCentre.y();
midRect[3].x = upCentre.x()+radius;
midRect[3].y = upCentre.y();
midRgn.CreatePolygonRgn(midRect, 4, ALTERNATE);
FillRgn(memHDC, midRgn, bush);
}
示例3: DrawItem
// CColoredButton message handlers
void CColoredButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
EnableToolTips( TRUE);
CDC *pDC = GetDC();
m_rectButton = lpDrawItemStruct->rcItem;
m_rectButton.top+=2;
m_rectButton.bottom-=2;
m_dx = (m_rectButton.right-m_rectButton.left)/6;
m_dy = (m_rectButton.top-m_rectButton.bottom)/2;
if( m_bMixedColor && IsWindowEnabled())
{
CBrush brush;
brush.CreateHatchBrush(HS_BDIAGONAL, CLRF_CLR( RGBToColor(100,100,100)));
pDC->FillRect( &m_rectButton, &brush);
}
else
{
ColorToComponents();
UBYTE ubR, ubG, ubB;
UBYTE ubH, ubS, ubV, ubA;
ubH = m_ubComponents[0][0];
ubS = m_ubComponents[0][1];
ubV = m_ubComponents[0][2];
ubA = m_ubComponents[0][3];
ubR = m_ubComponents[1][0];
ubG = m_ubComponents[1][1];
ubB = m_ubComponents[1][2];
#define FILL_RECT( col, x, y, w, h) {\
RECT rectToFill;\
rectToFill.left = m_rectButton.left+m_dx*x;\
if( w<0) rectToFill.right = m_rectButton.right-2;\
else rectToFill.right = m_rectButton.left+rectToFill.left+m_dx*w;\
rectToFill.top = m_rectButton.top-m_dy*y;\
rectToFill.bottom = m_rectButton.top+rectToFill.top-m_dy*h;\
COLORREF clrfColor = CLRF_CLR( col);\
if( !IsWindowEnabled()) clrfColor = CLRF_CLR( 0xBBBBBBBB);\
pDC->FillSolidRect( &rectToFill, clrfColor);\
pDC->DrawEdge( &rectToFill, EDGE_SUNKEN, BF_RECT);}
FILL_RECT( HSVToColor( ubH, 255, 255), 0, 0, 1, 1);
FILL_RECT( HSVToColor( ubH, ubS, 255), 1, 0, 1, 1);
FILL_RECT( HSVToColor( ubH, 0, ubV), 2, 0, 1, 1);
FILL_RECT( RGBToColor( ubA, ubA, ubA), 3, 0, 1, 2);
FILL_RECT( RGBToColor( ubR, 0, 0), 0, 1, 1, 1);
FILL_RECT( RGBToColor( 0, ubG, 0), 1, 1, 1, 1);
FILL_RECT( RGBToColor( 0, 0, ubB), 2, 1, 1, 1);
FILL_RECT( m_colColor, 4, 0, 2, 2);
}
pDC->DrawEdge( &lpDrawItemStruct->rcItem, EDGE_BUMP, BF_RECT);
ReleaseDC( pDC);
}
示例4: DrawLegend
int CChartSurfaceSerie::DrawLegend(CDC* pDC, CPoint UpperLeft, int BitmapWidth) const
{
if (m_strSerieName == _T(""))
return 0;
//Draw Text
int TextHeigh = pDC->GetTextExtent(m_strSerieName.c_str()).cy;
pDC->ExtTextOut(UpperLeft.x+BitmapWidth+6,UpperLeft.y+1,ETO_CLIPPED,NULL,m_strSerieName.c_str(),NULL);
// Draw the bitmap
CBrush NewBrush;
if (m_FillStyle == fsSolid)
NewBrush.CreateSolidBrush(m_ObjectColor);
else
{
int nIndex = 0;
switch (m_FillStyle)
{
case fsHatchDownDiag:
nIndex = HS_FDIAGONAL;
break;
case fsHatchUpDiag:
nIndex = HS_BDIAGONAL;
break;
case fsHatchCross:
nIndex = HS_CROSS;
break;
case fsHatchDiagCross:
nIndex = HS_DIAGCROSS;
break;
case fsHatchHorizontal:
nIndex = HS_HORIZONTAL;
break;
case fsHatchVertical:
nIndex = HS_VERTICAL;
break;
}
NewBrush.CreateHatchBrush(nIndex,m_ObjectColor);
}
CBrush* pOldBrush = pDC->SelectObject(&NewBrush);
pDC->Rectangle(UpperLeft.x+2,UpperLeft.y+2,UpperLeft.x+17,UpperLeft.y+17);
pDC->SelectObject(pOldBrush);
DeleteObject(NewBrush);
return 15;
}
示例5: DrawLegend
void CChartSurfaceSerie::DrawLegend(CDC* pDC, const CRect& rectBitmap) const
{
if (m_strSerieName== _T(""))
return;
// Draw the bitmap
CBrush NewBrush;
if (m_FillStyle == fsSolid)
NewBrush.CreateSolidBrush(m_ObjectColor);
else
{
int nIndex = 0;
switch (m_FillStyle)
{
case fsHatchDownDiag:
nIndex = HS_FDIAGONAL;
break;
case fsHatchUpDiag:
nIndex = HS_BDIAGONAL;
break;
case fsHatchCross:
nIndex = HS_CROSS;
break;
case fsHatchDiagCross:
nIndex = HS_DIAGCROSS;
break;
case fsHatchHorizontal:
nIndex = HS_HORIZONTAL;
break;
case fsHatchVertical:
nIndex = HS_VERTICAL;
break;
}
NewBrush.CreateHatchBrush(nIndex,m_ObjectColor);
}
CBrush* pOldBrush = pDC->SelectObject(&NewBrush);
pDC->Rectangle(rectBitmap);
pDC->SelectObject(pOldBrush);
DeleteObject(NewBrush);
}
示例6: OnInvertTracker
void CEGPaneBar::OnInvertTracker(const CRect& rc)
{
CFrameWnd* pParentFrame = GetParentFrame ();
CDC* pDC = pParentFrame->GetDC();
CRect rect(rc);
ClientToScreen(rect);
pParentFrame->ScreenToClient(rect);
CBrush br;
// br.CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT));
// br.CreateSolidBrush( GetSysColor( COLOR_APPWORKSPACE ) );
br.CreateHatchBrush( HS_DIAGCROSS, GetSysColor( COLOR_APPWORKSPACE ) );
HBRUSH hOldBrush = NULL;
hOldBrush = (HBRUSH)SelectObject(pDC->m_hDC, br.m_hObject);
pDC->PatBlt( rect.left, rect.top, rect.Width(), rect.Height(), DSTINVERT );
if (hOldBrush != NULL) SelectObject(pDC->m_hDC, hOldBrush);
ReleaseDC(pDC);
}
示例7: OnDraw
//.........这里部分代码省略.........
CBrush br1;
double IFN_prot_conc = CGeneral::grid.m_Grid[in1][in].array[SM];
if(IFN_prot_conc == 0){
continue;
}
int normalized_IFN_prot_conc = floor(IFN_prot_conc);
br1.CreateSolidBrush(colors[normalized_IFN_prot_conc]);
CBrush* pSMBr = myDc->SelectObject( &br1 );
// myDc->Rectangle(in - X, in1 -Y, in + sd_sm -X, in1 + sd_sm - Y);
CRect rect(in - X, in1 -Y, in + sd_sm -X, in1 + sd_sm - Y);
myDc->FillRect(&rect ,&br1);
if(CGeneral::DrawSigMolNames)
{
char buf[30] = "IFNprot: ";
char buf5[10];
itoa(IFN_prot_conc,buf5,10);
strncat(buf, buf5, 10);//add coma
myDc->TextOut(in - X, in1 -Y, buf, strlen(buf));
}
}
}
}
/////////////////// begin drawing rafts //////////////////////////////////
if( CGeneral::DrawRafts )
{
CBrush gray_hatch_br, red_br, grey_br;
gray_hatch_br.CreateHatchBrush(HS_BDIAGONAL, col[15]);
grey_br.CreateSolidBrush(col[15]);
red_br.CreateSolidBrush(col[1]);
CBrush* pOldBr = myDc->SelectObject( &gray_hatch_br );
std::vector<CCell>::iterator raft_iter;
raft_iter = CGeneral::CellArray.begin();
CCell * p_Raft = raft_iter;
for(; raft_iter != CGeneral::CellArray.end(); raft_iter++)
{
p_Raft = raft_iter;
double rigI_rna_conc = p_Raft->GetRIGI_rna_conc();
// double normalized_rigI_rna_conc = rigI_rna_conc/CGeneral::RIGI_rna_maxLevel;
double IFN_prot_conc = p_Raft->GetIFN_prot_conc();
// double normalized_IFN_prot_conc = IFN_prot_conc/CGeneral::IFN_prot_maxLevel;
if( p_Raft->IsActivated() )
{
CBrush br;
double RIGI_rna_conc = p_Raft->GetRIGI_rna_conc();
int val=0;
if(CGeneral::DrawAgs)
double rigI_rna_conc = p_Raft->GetRIGI_rna_conc();
else
double rigI_rna_conc = p_Raft->GetRIGI_rna_conc();
if( !p_Raft->IsInfected() )//not infected
示例8: DrawAll
void CChartSurfaceSerie::DrawAll(CDC* pDC)
{
size_t count = m_vPoints.size();
CPoint* pPoints = new CPoint[count+2];
CBrush NewBrush;
if (m_FillStyle == fsSolid)
NewBrush.CreateSolidBrush(m_ObjectColor);
else
{
int nIndex = 0;
switch (m_FillStyle)
{
case fsHatchDownDiag:
nIndex = HS_FDIAGONAL;
break;
case fsHatchUpDiag:
nIndex = HS_BDIAGONAL;
break;
case fsHatchCross:
nIndex = HS_CROSS;
break;
case fsHatchDiagCross:
nIndex = HS_DIAGCROSS;
break;
case fsHatchHorizontal:
nIndex = HS_HORIZONTAL;
break;
case fsHatchVertical:
nIndex = HS_VERTICAL;
break;
}
NewBrush.CreateHatchBrush(nIndex,m_ObjectColor);
}
CBrush* pOldBrush = pDC->SelectObject(&NewBrush);
for (size_t i=0; i<count; i++)
{
ValueToScreen(m_vPoints[i].X,m_vPoints[i].Y,pPoints[i+1]);
}
if (m_bHorizontal)
{
pPoints[0].x = pPoints[1].x;
pPoints[count+1].x = pPoints[count].x;
float Position = m_pHorizontalAxis->GetPosition()/100.00;
int AxisPos = m_ObjectRect.top + (int)(Position * (m_ObjectRect.bottom-m_ObjectRect.top));
pPoints[0].y = AxisPos;
pPoints[count+1].y = AxisPos;
}
else
{
pPoints[0].y = pPoints[1].y;
pPoints[count+1].y = pPoints[count].y;
float Position = m_pVerticalAxis->GetPosition()/100.00;
int AxisPos = m_ObjectRect.left + (int)(Position * (m_ObjectRect.right-m_ObjectRect.left));
pPoints[0].x = AxisPos;
pPoints[count+1].x = AxisPos;
}
pDC->SetBkMode(TRANSPARENT);
//To have lines limited in the drawing rectangle :
pDC->IntersectClipRect(m_ObjectRect);
pDC->Polygon(pPoints,count+2);
pDC->SelectClipRgn(NULL);
pDC->SelectObject(pOldBrush);
DeleteObject(NewBrush);
delete[] pPoints;
}
示例9: DrawAll
void CChartSurfaceSerie::DrawAll(CDC* pDC)
{
int iFirst=0, iLast=0;
GetVisiblePoints(iFirst,iLast);
if (iFirst>0)
iFirst--;
if (iLast<(int)GetPointsCount())
iLast++;
int iCount = iLast - iFirst;
CPoint* pPoints = new CPoint[iCount+2];
CBrush NewBrush;
if (m_FillStyle == fsSolid)
NewBrush.CreateSolidBrush(m_ObjectColor);
else
{
int nIndex = 0;
switch (m_FillStyle)
{
case fsHatchDownDiag:
nIndex = HS_FDIAGONAL;
break;
case fsHatchUpDiag:
nIndex = HS_BDIAGONAL;
break;
case fsHatchCross:
nIndex = HS_CROSS;
break;
case fsHatchDiagCross:
nIndex = HS_DIAGCROSS;
break;
case fsHatchHorizontal:
nIndex = HS_HORIZONTAL;
break;
case fsHatchVertical:
nIndex = HS_VERTICAL;
break;
}
NewBrush.CreateHatchBrush(nIndex,m_ObjectColor);
}
CBrush* pOldBrush = pDC->SelectObject(&NewBrush);
for (int i=iFirst; i<iLast; i++)
{
ValueToScreen(m_vPoints[i].X,m_vPoints[i].Y,pPoints[i-iFirst+1]);
}
if (m_bHorizontal)
{
pPoints[0].x = pPoints[1].x;
pPoints[iCount+1].x = pPoints[iCount].x;
double Position = m_pHorizontalAxis->GetPosition()/100.00;
int AxisPos = m_ObjectRect.top + (int)(Position * (m_ObjectRect.bottom-m_ObjectRect.top));
pPoints[0].y = AxisPos;
pPoints[iCount+1].y = AxisPos;
}
else
{
pPoints[0].y = pPoints[1].y;
pPoints[iCount+1].y = pPoints[iCount].y;
double Position = m_pVerticalAxis->GetPosition()/100.00;
int AxisPos = m_ObjectRect.left + (int)(Position * (m_ObjectRect.right-m_ObjectRect.left));
pPoints[0].x = AxisPos;
pPoints[iCount+1].x = AxisPos;
}
pDC->SetBkMode(TRANSPARENT);
//To have lines limited in the drawing rectangle :
CRect TempClipRect(m_ObjectRect);
TempClipRect.DeflateRect(1,1);
pDC->SetBkMode(TRANSPARENT);
pDC->IntersectClipRect(TempClipRect);
pDC->Polygon(pPoints,iCount+2);
pDC->SelectClipRgn(NULL);
pDC->SelectObject(pOldBrush);
DeleteObject(NewBrush);
delete[] pPoints;
}
示例10: OnPaint
//.........这里部分代码省略.........
dc.SelectObject(oldpen);
newpen.DeleteObject( );
// draws several pixels
for(xcoord=500;xcoord<600;xcoord+=5)
dc.SetPixel(xcoord,400,0L);
dc.TextOut(540,410,"pixels",6);
// draws a wide diagonal line
newpen.CreatePen(PS_SOLID,10,dwColor[0]);
oldpen=dc.SelectObject(&newpen);
dc.MoveTo(20,20);
dc.LineTo(100,100);
dc.TextOut(60,20,"<- diagonal line",16);
dc.SelectObject(oldpen);
newpen.DeleteObject( );
// draws an arc
newpen.CreatePen(PS_DASH,1,dwColor[3]);
oldpen=dc.SelectObject(&newpen);
dc.Arc(25,125,175,225,175,225,100,125);
dc.TextOut(50,150,"small arc ->",12);
dc.SelectObject(oldpen);
newpen.DeleteObject( );
// draws a wide chord
newpen.CreatePen(PS_SOLID,10,dwColor[2]);
oldpen=dc.SelectObject(&newpen);
dc.Chord(125,125,275,225,275,225,200,125);
dc.TextOut(280,150,"<- chord",8);
dc.SelectObject(oldpen);
newpen.DeleteObject( );
// draws a pie slice and fills
newpen.CreatePen(PS_SOLID,2,dwColor[0]);
oldpen=dc.SelectObject(&newpen);
newbrush.CreateSolidBrush(dwColor[2]);
oldbrush=dc.SelectObject(&newbrush);
dc.Pie(200,0,300,100,200,50,250,100);
dc.TextOut(260,80,"<- pie wedge",12);
dc.SelectObject(oldbrush);
newbrush.DeleteObject( );
dc.SelectObject(oldpen);
newpen.DeleteObject( );
// draws a rectangle and fills
newbrush.CreateSolidBrush(dwColor[7]);
oldbrush=dc.SelectObject(&newbrush);
dc.Rectangle(25,350,150,425);
dc.TextOut(50,440,"rectangle",9);
dc.SelectObject(oldbrush);
newbrush.DeleteObject( );
// draws a rounded rectangle and fills
newbrush.CreateHatchBrush(HS_CROSS,dwColor[3]);
oldbrush=dc.SelectObject(&newbrush);
dc.RoundRect(400,320,550,360,20,20);
dc.TextOut(410,300,"rounded rectangle",17);
dc.SelectObject(oldbrush);
newbrush.DeleteObject( );
// draws a wide polygon and fills
newpen.CreatePen(PS_SOLID,5,dwColor[6]);
oldpen=dc.SelectObject(&newpen);
newbrush.CreateHatchBrush(HS_FDIAGONAL,dwColor[4]);
oldbrush=dc.SelectObject(&newbrush);
polygpts[0].x=40;
polygpts[0].y=200;
polygpts[1].x=100;
polygpts[1].y=270;
polygpts[2].x=80;
polygpts[2].y=290;
polygpts[3].x=20;
polygpts[3].y=220;
polygpts[4].x=40;
polygpts[4].y=200;
dc.Polygon(polygpts,5);
dc.TextOut(80,230,"<- polygon",10);
dc.SelectObject(oldbrush);
newbrush.DeleteObject( );
dc.SelectObject(oldpen);
newpen.DeleteObject( );
// draws several wide lines with polyline
newpen.CreatePen(PS_SOLID,4,dwColor[5]);
oldpen=dc.SelectObject(&newpen);
polylpts[0].x=210;
polylpts[0].y=330;
polylpts[1].x=210;
polylpts[1].y=400;
polylpts[2].x=250;
polylpts[2].y=400;
polylpts[3].x=210;
polylpts[3].y=330;
dc.Polyline(polylpts,4);
dc.TextOut(250,350,"polyline",8);
dc.SelectObject(oldpen);
newpen.DeleteObject( );
}
示例11: DrawRegion
void ecMemoryLayoutWindow::DrawRegion (wxDC& dc, int uRegion, int uUnitCount, int uPixelsPerUnit, std::list <mem_region>::iterator region)
{
#if 0
BOOL bDrawFocusRect = FALSE;
CRect rectAddress;
CString strAddress;
// setup the drawing objects
CBrush brshUnusedSection;
if (!brshUnusedSection.CreateHatchBrush (HS_BDIAGONAL, RGB (128, 128, 128)))
return;
CBrush brshUsedSection;
if (!brshUsedSection.CreateSolidBrush (GetSysColor (COLOR_WINDOW)))
return;
CBrush brshInitialSectionBar;
if (!brshInitialSectionBar.CreateSolidBrush (GetSysColor (COLOR_INACTIVECAPTION)))
return;
CBrush brshFixedSectionBar;
if (!brshFixedSectionBar.CreateSolidBrush (GetSysColor (COLOR_ACTIVECAPTION)))
return;
CBrush brshFinalSectionBar;
if (!brshFinalSectionBar.CreateSolidBrush (GetSysColor (COLOR_ACTIVECAPTION)))
return;
CPen penBorder;
if (!penBorder.CreatePen (PS_SOLID, 1, GetSysColor (COLOR_WINDOWTEXT)))
return;
CPen penSelected;
if (!penSelected.CreatePen (PS_SOLID, 2, GetSysColor (COLOR_WINDOWTEXT)))
return;
// select the border pen object
CPen * pOldPen = pDC->SelectObject (&penBorder);
// calculate the region rectangle
REGIONRECT srRegion;
srRegion.Rect.SetRect (HORIZ_BORDER, VERT_BORDER + REGION_SPACING * uRegion, HORIZ_BORDER + uUnitCount * uPixelsPerUnit + 1, VERT_BORDER + REGION_SPACING * uRegion + MAP_HEIGHT + 1);
srRegion.Region = region;
listRegionRect.AddTail (srRegion);
// draw the region
CPoint pointOrigin (srRegion.Rect.left, srRegion.Rect.top);
pDC->LPtoDP (&pointOrigin);
pointOrigin.x %= 8;
pointOrigin.y %= 8;
pDC->SetBrushOrg (pointOrigin);
CBrush * pOldBrush = pDC->SelectObject (&brshUnusedSection);
pDC->Rectangle (srRegion.Rect);
/*
pDC->MoveTo (srRegion.Rect.left, srRegion.Rect.bottom - 1); // draw tick
pDC->LineTo (srRegion.Rect.left, srRegion.Rect.bottom + TICK_HEIGHT); // draw tick
*/
if (region == m_riSelectedRegion)
{
bDrawFocusRect = TRUE;
m_rectSelectedItem = srRegion.Rect;
}
// draw the region label
CRect rectRegionLabel (HORIZ_BORDER, VERT_BORDER + REGION_SPACING * uRegion - EXTERNAL_TEXT_BORDER - 20, m_uViewWidth - HORIZ_BORDER /*HORIZ_BORDER + uUnitCount * uPixelsPerUnit + 1*/, VERT_BORDER + REGION_SPACING * uRegion - EXTERNAL_TEXT_BORDER);
CString strRegionLabel;
strRegionLabel.Format (_T("%s (%08X-%08X)%s"), CString(region->name.c_str ()), region->address, region->address + region->size - 1, ((region->type == read_only) ? _T(" read only") : _T("")));
pDC->DrawText (strRegionLabel, -1, rectRegionLabel, DT_BOTTOM | DT_SINGLELINE);
// draw the start address of the region
/*
rectAddress.SetRect (HORIZ_BORDER, VERT_BORDER + REGION_SPACING * uRegion + MAP_HEIGHT + EXTERNAL_TEXT_BORDER, HORIZ_BORDER + ADDRESS_TEXT_SPACE * UNITS_PER_SECTION * uPixelsPerUnit, VERT_BORDER + REGION_SPACING * uRegion + MAP_HEIGHT + EXTERNAL_TEXT_BORDER + 30);
strAddress.Format (ADDRESS_FORMAT, region->address);
pDC->DrawText (strAddress, -1, rectAddress, DT_LEFT | DT_SINGLELINE);
*/
// draw the end address of the region
/*
rectAddress.SetRect (HORIZ_BORDER + (uUnitCount - ADDRESS_TEXT_SPACE) * uPixelsPerUnit, VERT_BORDER + REGION_SPACING * uRegion + MAP_HEIGHT + EXTERNAL_TEXT_BORDER, HORIZ_BORDER + (uUnitCount + ADDRESS_TEXT_SPACE) * uPixelsPerUnit, VERT_BORDER + REGION_SPACING * uRegion + MAP_HEIGHT + EXTERNAL_TEXT_BORDER + 30);
strAddress.Format (ADDRESS_FORMAT, region->address + region->size);
pDC->DrawText (strAddress, -1, rectAddress, DT_CENTER | DT_SINGLELINE);
*/
// draw the sections within the region
UINT uSectionUnitCount = 0;
CRect rectBar;
SECTIONRECT srSection;
for (list <mem_section_view>::iterator section_view = region->section_view_list.begin (); section_view != region->section_view_list.end (); ++section_view)
{
if (section_view->section != NULL) // the section is used
{
// draw the section
pDC->SelectObject (brshUsedSection);
srSection.Rect.SetRect (HORIZ_BORDER + uSectionUnitCount * uPixelsPerUnit, VERT_BORDER + REGION_SPACING * uRegion, HORIZ_BORDER + (uSectionUnitCount + UNITS_PER_SECTION) * uPixelsPerUnit + 1, VERT_BORDER + REGION_SPACING * uRegion + MAP_HEIGHT + 1);
srSection.SectionView = section_view;
//.........这里部分代码省略.........
示例12: OnDraw
void CImconView::OnDraw(CDC* pDC)
{
CImconDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
if (pDC->IsPrinting())
{ // Print image
pDC->SetMapMode(MM_TWIPS);
pDoc->m_Dib.Stretch(pDC->m_hDC, pDoc->m_hPal,
pDoc->m_uLeftMargin, - (int) pDoc->m_uTopMargin,
pDoc->m_uHorzPrintSize, - (int) pDoc->m_uVertPrintSize);
}
else
{ // Draw image on screen
// Draw background
RECT Rect;
CBrush Brush;
Brush.CreateHatchBrush(HS_BDIAGONAL, RGB(192, 192, 192));
GetClientRect(&Rect);
Rect.right = max(Rect.right, (int) pDoc->m_uWidth);
Rect.bottom = max(Rect.bottom, (int) pDoc->m_uHeight);
CPoint ptScrollPos = GetScrollPosition();
pDC->SetBrushOrg(-ptScrollPos.x, -ptScrollPos.y);
CRgn rgnImage;
CRgn rgnWindow;
rgnImage.CreateRectRgn(0, 0, pDoc->m_uWidth, pDoc->m_uHeight);
rgnWindow.CreateRectRgnIndirect(&Rect);
rgnWindow.CombineRgn(&rgnWindow, &rgnImage, RGN_DIFF);
pDC->FillRgn(&rgnWindow, &Brush);
// pDC->FillRect(&Rect, &Brush);
// Draw image
HPALETTE hPal;
CPalette *pOldPal = NULL;
if (m_bActive)
hPal = pDoc->m_hPal;
else
{
hPal = NULL;
CPalette *pPal = CPalette::FromHandle(pDoc->m_hPal);
pOldPal = pDC->SelectPalette(pPal, TRUE);
pDC->RealizePalette();
}
RECT rcClientArea;
GetClientRect(&rcClientArea);
if (m_bScaleToWindow)
if (m_bUseDib)
pDoc->m_Dib.Stretch(pDC->m_hDC, hPal, 0, 0,
rcClientArea.right - rcClientArea.left,
rcClientArea.bottom - rcClientArea.top);
else
pDoc->m_Ddb.Stretch(pDC->m_hDC, hPal, 0, 0,
rcClientArea.right - rcClientArea.left,
rcClientArea.bottom - rcClientArea.top);
else
if (m_bUseDib)
pDoc->m_Dib.Draw(pDC->m_hDC, hPal, 0, 0);
else
pDoc->m_Ddb.Draw(pDC->m_hDC, hPal, 0, 0);
if (pOldPal)
pDC->SelectPalette(pOldPal, FALSE);
// Draw selection
if (m_bSelection)
{
LPRECT lpRect = &m_rectSelection;
pDC->PatBlt(lpRect->left, lpRect->top,
lpRect->right - lpRect->left, 1,
DSTINVERT);
pDC->PatBlt(lpRect->left, lpRect->bottom,
1, -(lpRect->bottom - lpRect->top),
DSTINVERT);
pDC->PatBlt(lpRect->right - 1, lpRect->top,
1, lpRect->bottom - lpRect->top,
DSTINVERT);
pDC->PatBlt(lpRect->right, lpRect->bottom - 1,
-(lpRect->right - lpRect->left), 1,
DSTINVERT);
}
}
}