A HPEN isn't just a numeric handle. It is a pointer to an object.
SelectObject() doesn't know what type of selection is made
(pen,brush,...), so the declaration of it can't just specify HPEN as
return value.
You have to make a type cast on the returned value.
/Per W
On Mon, 23 Sep 2002, Vlada Djurovic wrote:
> Hi, everybody
> I wrote this function:
> =20
> void CLine::Draw(HDC hdc)
> {
> HPEN hPen,hOldPen;
> hPen=3DCreatePen(PS_SOLID,m_iWidth,m_crColor);
> hOldPen=3DSelectObject(hdc,hPen); //this is where I
> get error message
> =20
> MoveToEx(hdc,m_ptFrom.x,m_ptFrom.y,NULL);
> LineTo(hdc,m_ptTo.x,m_ptTo.y);
> SelectObject(hdc,hOldPen);
> DeleteObject(hPen);
> DeleteObject(hOldPen);
> }
> =20
> When I try to compile it, I get the message =93ANSI C++ forbids implicit
> conversion from `void *' in assignment=94 in commented line. What is the
> problem?
>=20
|