将GDI +与GDI混合 [英] Mixing GDI+ with GDI
问题描述
我正在尝试扩展使用GDI的非托管VC ++ 6.0 OCX,该OCX用于显示图像并绘制简单的图形元素-线,点和矩形.我正在尝试在这些元素上添加半透明多边形.根据在此处找到的文章,我相信我已经准备好了代码 GDI + .
画笔已建立:
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);
}
以下是尝试使用GDI +的唯一代码,并且状态返回0:
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;
}
在以下方法中调用此代码,并被利用GDI的Draw包围:
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();
//draw shape
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);
}
}
}
使用GDI可以正确渲染CLine对象,但不会出现FillPolygon.有什么想法吗?需要更多信息吗?
在此先感谢
Ted
The CLine object is rendered correctly using GDI, but the FillPolygon doesn''t appear. Any thoughts? Any more information required?
Thanks in advance
Ted
推荐答案
请原谅我,但您是否通过调用 GdiplusStartup
?
Pardon me if you''ve already done this, but have you initialized GDI+ with a call to GdiplusStartup
?
这篇关于将GDI +与GDI混合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!