Does someone has some idea of such weird thing about pixel format?

First I call SetPixelFormat which just returns true. Like such:
SetPixelFormat(hdc, 0xa, &pfd);
Immediately following that, I call GetPixelFormat(hdc), but surprisingly it gives back a zero value.I am puzzled.Thanks for any light on this issue.

What error code returns GetLastError() ?
(my guess: hdc is invalid; how did you get it?)

I get the dc handle from outer application. Is there anyway to conclude a handle is valid or not? Can WindowFromDC be credible? 3X!

What do you mean “from outer application”?
Do you try to set a pixelformat in another application’s window? Don’t!

oh, sorry, I don’t make me clear. I just wrap SetPixelFormat in a dll.

  • SetPixelFormat() returns a boolean. Did it succeed?

  • Do you call this inside DllMain()?
    That might be problematic because it would invoke other DLLs and LoadLibrary() is not allowed inside DLLMain().
    http://msdn2.microsoft.com/en-us/library/ms682583.aspx
    Cite: “It must not call the LoadLibrary or LoadLibraryEx function (or a function that calls these functions), because this may create dependency loops in the DLL load order.”

  • Has the window the necessary window styles WS_CLIPCHILDREN and WS_CLIPSIBLINGS for OpenGL?

How and where do you get the hdc?
Do you get it inside the wrapper or is it an argument to it?

(Initializing OpenGL inside DLLMain() sound crazy x_X )

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.