Jump to content
  • Advertisement
Sign in to follow this  
Banan

Releasing DC and destroying a window

This topic is 4553 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! I've beem going through the OpenGL tutorial and after some time of reading I started to create my own library for future useage. It generally works but I'm unable to release a device context (using ReleaseDC) and a window handler (using DestroyWindow). This part of code is taken from the tutorial (maybe not exactly copied) and here it goes: (...) if (hDC && !ReleaseDC(hWnd, hDC)) { MessageBox(**Not important**); hDC=NULL; } if (hWnd && !DestroyWindow(hWnd)) { MessageBox(**The same here**); hWnd=NULL; } (...) My question is what conditions can cause those functions to fail? Any ideas are welcome (; Edited: spelling [Edited by - Banan on May 6, 2006 2:59:31 PM]

Share this post


Link to post
Share on other sites
Advertisement
ReleaseDC() can fail if either the HWND or the HDC is invalid. Similarly, DestroyWindow() can fail if the HWND is invalid. With DestroyWindow(), at least, you can use GetLastError() to determine what happened.

Share this post


Link to post
Share on other sites
Thanks for the reply.

According to my watch list GetLastError() returns '0'... :| Does it help?

Edited:

Ok, not exactly. This function should return DWORD right? After assigning
DWORD Err = GetLastError, Err has the zero value but when I move my mouse over the function name a box appears where it's written that GetLastError() returns 77F45BA5. What does it mean?

Share this post


Link to post
Share on other sites
You should output the results from GetLastError to verify (messagebox it) it's 0 and not something else, this has example code on how to format it (get the code and turn it into text for you):
GetLastError() MSDN link.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!