# Error I cant resolve

## Recommended Posts

Hi there, I was wondering if anyone could help me with an error I have in my code. I'm working from the book 'Tricks of Windows Game Programming Gurus' and on chapter 4...drawing lines. This is the code giving me the trouble... HPEN green_pen = CreatePen(PS_SOLID, 1, RGB(255,255,255)); HPEN old_pen = SelectObject(hdc, green_pen); MoveToEx(hdc, 10,10,NULL); LineTo(hdc,160,60); SelectObject(hdc,old_pen); DeleteObject(green_pen); And this is the error... error C2440: 'initializing' : cannot convert from 'void *' to 'struct HPEN__ *' Any help greatly appreciated, Many Thanks, David

##### Share on other sites
You don't say what line the error is on. I assume it's the second line. Try:
HPEN old_pen = (HPEN) SelectObject(hdc, green_pen);

Skizz

##### Share on other sites
Thanks very much Skizz. You were right, the error was on the 2nd line, well spotted!

The program is now working...I drew my first line! Yehh!

Cheers,

David

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628316
• Total Posts
2982032

• 9
• 9
• 13
• 11
• 14