Simple Window Programming Questions

Posted on 2003-03-15
Medium Priority
Last Modified: 2010-04-01
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??
Question by:Snurre

Expert Comment

ID: 8143459
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.

Expert Comment

ID: 8143480
I think your mistake it's DeleteDC. Try to use ReleaseDC instead. Sorry for my English...

Expert Comment

ID: 8143491
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.
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 8144551
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)

Accepted Solution

MirkoLMV earned 150 total points
ID: 8151808
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 !

Author Comment

ID: 8151910
I Give you the Points for the Funni little Gaming Site and The Tut you Recomended...


Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question