Archived

This topic is now archived and is closed to further replies.

Bacardi34

Help with HDC calls

Recommended Posts

Hello, I am working on my first game, its really quite simple but i keep getting an error saying "''hdc'' undeclared identifier" when i try and compile its in the right place for the function call (i checked MSDN) but i cant seem to get rid of the error, any help? Here is the code
while( ballToDraw->next != NULL )
	{
		SelectObject( hdc, ballToDraw->brush ); //GETTING ERROR on THIS LINE
		Ellipse( hdc, ballToDraw->ballx, ballToDraw->bally,
			ballToDraw->ballx + ballToDraw->ballSize, ballToDraw->bally + ballToDraw->ballSize);
		ballToDraw = ballToDraw->next;
	}
 
Would apreciate any help! Thanks!

Share this post


Link to post
Share on other sites
well normally the hdc is the Handle to the Device Context
like Hwnd is the Handle to the WINdow.

if I am understanding your problem correctly, read up about setting up your display window.
try just doing that search on msn - "Handle to the Device Context"

plus im assuming you dont know much about hdc etc, which is a BIG assumption, so excuse my ignorance.

check for how its declared, look at some other proggies


[edited by - fatherjohn666 on September 1, 2002 7:18:34 PM]

Share this post


Link to post
Share on other sites
This is a long shot, and sorry if it insults your intelligence, but just in case: check if it should be hDC, cos I''ve seen it written like that mostly
Anyway, if you are still stuck, post a little more code for us.

Share this post


Link to post
Share on other sites
I solved the problem, be it a round about sort of way.
First i tried moving the Fuctions that use the the HDC call below winMain, and still got errors.
After that i moved the HDC hdc decleration up into the Global variabels and it worked out ok.
So i donno what the problem with it is but its ok for now.
Thanks for the help

Share this post


Link to post
Share on other sites
If you had your ''HDC hdc;'' in WinMain and tried to use it in whatever function that while loop was in.. there''s your problem. It''s local to the function. You did the right thing moving it into your global variables so that you can move it around the entire program.

// chimaera

Share this post


Link to post
Share on other sites