• Advertisement
Sign in to follow this  

Releasing DC and destroying a window

This topic is 4369 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
Sign in to follow this  

  • Advertisement