Simple Window Programming Questions

I am developing a Game in GDI for Windows and uses WinAPI.

When I'm running the Game in WinXP everything is OK, but when I'm trying to run it under Win98 or WinME the Game Looses the Graphics and Font Settings that I have written...

I Think that it gottohave with the HDC stuff to do...

Uses the following to print the Graphics:

void GamePaint(HDC hdc)
     // Draw The Game Plan...
     GamePlan->Draw(hdc, 0, 0);


void GameCycle()
        HDC hDC = GetDC(Game->GetWindow());


     BitBlt(hDC, 0, 0, Game->GetWidth(), Game->GetHeight(),
          _hOffscreenDC, 0,0, SRCCOPY);
     DeleteDC(hDC); // Unsure if I sould delete it or not???

And a Second question:
Does someone have some info about desgining own Windows or some tutorial??
Who is Participating?
MirkoLMVConnect With a Mentor Commented:
Games relying on GDI are not expected anyway to be especially performant.
Normally a global Device Context used with almost no pause on the same window should not cause problems and could be released at the very end of using the window.

A good tutorial on Windows programming is written by Brook Miles, who likes to appear on the name The Forger.
Another good source for small Games in Window is the site

Gool luck !
I don;t think windows 98 fully support GDI/GDI+ out of the box very well. Make sure you've downloaded the latest patches from Microsoft Update. Windows XP/Me/2000 would have newer versions that Win98. Maybe that's the issue.
I think your mistake it's DeleteDC. Try to use ReleaseDC instead. Sorry for my English...
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

GDI is fully supported out of the win 98 box.  GDI+ is not.  However this is not the problem....  It could be a problem with DeleteDC

from MSDN

"An application must not delete a device context whose handle was obtained by calling the GetDC function. Instead, it must call the ReleaseDC function to free the device context."

call ReleaseDC instead.
SnurreAuthor Commented:
Yes I Saw it on the MSN that it should be ReleaseDC instead, but, It's Still Messed up.

I'm going to explain a little more...

I have created all the nessesary stuff needed for my game, Bitmap Handlers and Sprites and more... And they are proofed to function under Win98 and Later...

But when I Started doing this Game I got the troubles with the Graphics disapering.

All I would need to know is, when should I Release the HDC Handler, It's used in many different Functions, Should I only have ONE Global HDC, does it make any difference in Passing the DC on in the Function header, or if I use the GetDC() Function??

My English isen't good Eighter... Sorry for the Inconvinience :o)
SnurreAuthor Commented:
I Give you the Points for the Funni little Gaming Site and The Tut you Recomended...

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.