?
Solved

Simple Window Programming Questions

Posted on 2003-03-15
6
Medium Priority
?
191 Views
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);
     DrawWindowItems(hdc);
     DrawMenu(hdc);
     Othello->DrawBoard(hdc);
     DrawPlayerGraphics(hdc);
     DrawLoggWindow(hdc);

}

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

     GamePaint(_hOffscreenDC);

     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??
0
Comment
Question by:Snurre
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 1

Expert Comment

by:MatrixDud
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.
0
 
LVL 1

Expert Comment

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

Expert Comment

by:frogger1999
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.
0
Industry Leaders: 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!

 
LVL 2

Author Comment

by:Snurre
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)
0
 
LVL 2

Accepted Solution

by:
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
  www.programming.de

Gool luck !
0
 
LVL 2

Author Comment

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

0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

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…
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses
Course of the Month8 days, 8 hours left to enroll

764 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