I'm attempting to extend an unmanaged VC++ 6.0 OCX that uses GDI for displaying images and drawing simple graphical elements - lines, points, and rectangles. I am trying to add translucent polygons on top of these elements. Based on articles found
here, I believe I've made the code
GDI+ ready.
The brush is established:
void CDQuad::SetColor(COLORREF aColor, int alpha)
{
m_Color = Color(alpha, GetRValue(aColor), GetGValue(aColor), GetBValue(aColor));
m_pBrush->SetColor(m_Color);
}
The following is the only code that attempts to use GDI+ and the status comes back 0:
void CDQuad::Draw(CDC *pDC, CTfw* pTfw)
{
Point* points = new Point[5];
CPoint pCurr;
Graphics* graphics = new Graphics(pDC->m_hDC);
if(pTfw != NULL)
{
for (int i = 0;i < 5; i++){
pCurr = pTfw->GeoPointToScreen(m_x[i], m_y[i]);
points[i].X = pCurr.x;
points[i].Y = pCurr.y;
}
Status astatus = graphics->FillPolygon(m_pBrush,points,5);
}
delete graphics;
delete [] points;
points = NULL;
}
This code is called in the following method, surrounded by Draw's that utilize GDI:
void CShape::Draw(CDC* pDC, int nVertOffset)
{
if(m_bShow && !m_bNoGeo)
{
CLine* pLine = NULL;
CDQuad* pQuad = NULL;
int nParts = m_objShapeParts.GetSize();
int nIndex;
for (int i=0; i<nParts;i++)
{
if(m_bShowIndex)
nIndex = i+1;
else
nIndex = 0;
pLine = (CLine* )m_objShapeParts.GetAt(i);
pLine->Draw(pDC,m_nOffsetX,m_nOffsetY, m_dZoomFactor, m_nPanX, m_nPanY, m_pPen, m_pTfw, &m_DxfExtent, m_bShowVertex, nIndex, nVertOffset);
}
nParts = m_objQuads.GetSize();
for (i=0; i<nParts;i++)
{
pQuad = (CDQuad* )m_objQuads.GetAt(i);
pQuad->Draw(pDC,m_pTfw);
}
}
}
The CLine object is rendered correctly using GDI, but the FillPolygon doesn't appear. Any thoughts? Any more information required?
Thanks in advance
Ted