SetPixelFormat - New question

Started by
3 comments, last by Crypter 15 years, 10 months ago
Hey everyone, I have the following code:
if(!SetPixelFormat(hDC,PixelFormat,&pfd)) {
	g_EvehLog << LogLevel (ERROR) << " *** Unable to set pixel 
            format to Rendering window's device context.
             System error [" << GetLastError() << "]" << std::endl;
	return 0;
}
The above code fails (As I expected), However GetLastError() always seems to return 3221684230. I would be thinking this is a garbage value, however right before the call, GetLastError returns 0, so something in the above code must be setting it. MSDN states that SetPixelFormat sets the error code, but why would it be setting it to an invalid value? o_0 Is there something that I am missing? Its not a big problem, just curious of whats going on here... Thanks :) [Edited by - Crypter on May 23, 2008 8:09:48 PM]
Advertisement
3221684230 is 0xC0070006 in hex, which looks very much like a failed HRESULT code 0x0006 ("The handle is invalid." according to Error Lookup).
Quote:Original post by Evil Steve
3221684230 is 0xC0070006 in hex, which looks very much like a failed HRESULT code 0x0006 ("The handle is invalid." according to Error Lookup).

That makes perfect sense :) Thanks! I actually didn't know HRESULT had a specific format until I seen it on wikipedia--interesting read. (I thought the error would be in winerror.h--guess not)
More random information from winerror.h:
////  Values are 32 bit values layed out as follows:////   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1//   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0//  +---+-+-+-----------------------+-------------------------------+//  |Sev|C|R|     Facility          |               Code            |//  +---+-+-+-----------------------+-------------------------------+////  where////      Sev - is the severity code////          00 - Success//          01 - Informational//          10 - Warning//          11 - Error////      C - is the Customer code flag////      R - is a reserved bit////      Facility - is the facility code////      Code - is the facility's status code////// Define the facility codes//

And below that:
#define FACILITY_WIN32 7
Which makes the error code: "Error from Win32: The handle is invalid".

I'll stop rambling now [smile]
Hello again :)

I am hoping it will be okay to post another question that I have. I am thinking it is another simple answer so I decided to post it here instead of creating a new thread for it.

In another project of mine, I work with hardware structures. These structures follow specific bit formats that define different properties of it. At first, I would usually write up bit masks and flags to build up the bit pattern. This works, but poses problems as well.

So I was thinking of writing routines to get and set these properties (Kind of like setters and getters methods in C++). This would hide all of this in a nice easy to use interface. But...Is it worth it? These routines will only set or return a single bit (Or several bits.)

What would you suggest? Should I stay with the first method, or should I go with the safer and cleaner method (The second method), even though they only operate on single bits?

Thanks for any suggestions, and also thank you very much for answering my previous question! [smile]

This topic is closed to new replies.

Advertisement