Well, read the subject, and I have the answer.
It seems that everyone programming in OpenGL knows that you’re supposed to set a window style of CS_OWNDC if you’re programming in Windows. All of you real programmers know how to do that, because you’re all doing the right thing and programming in Win32.
But what about us lowly persons that are enslaved in the wackey world of MFC (sic)? Well, I’ve asked many, but no one has known. Most people say, “Duh, set it on your PreCreateWindow’s cs.style attribute.” Well, they’re wrong. Read some books and you’ll find out that cs.style is indeed for window styles, but the idiots that keep referring to the CS_ attributes as windows styles are confusing the hell out of everybody!
What the CS_ attributes should more accurately be referred to as are “Creation Styles” or “Class Styles”. The second one should give a clue as to how to set it now in MFC. Read on!
PreCreateWindow of your OpenGL view (or CWnd) is indeed the right place to do it. But not using cs.style or cs.dwExStyle…
You do something akin to the following:
cs.lpszClass = ::AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS | CS_OWNDC, ::LoadCursor(NULL, IDC_ARROW), NULL, NULL);
Basically, this is the same thing as what the folks in Win32 land do right at the beginning of their code. They “Register the class”. Notice the CS_OWNDC. Its there! Woo! By the way, the second to last NULL (from what MSDN tells, and its been known to lie) causes the handler for WM_ERASEBKGND to NOT redraw the window, effectively allowing you to not have to override WM_ERASEBKGND to support flicker-free double buffering. Bonus!
Now, you may be asking “Uhh, why do I care about some stupid CS_OWN… CS_OWN… CS_WHATEVER?”
Well, if your target platform is going to be Windows 95, Windows 98 or Windows ME (god forbid), it is a potential problem. I won’t go into all the details, because any good OpenGL book that covers Windows GL programming will tell you why. Just know that this isn’t an issue for Windows NT and Windows 2000, but its still good practice. After all, you never know what you’re going to be running you program on!
Alrighty then… now that I’ve used my quota of smiles for the day, go forth and use the force wisely, lest it poke your eye out.
I hope this info is useful to somebody. I’ve personally been looking for it for the past 4 months, and no one has been able to help me. Digest, enjoy, and discuss amongst yourselves…
PS - Here’s a topic, the Holy Roman Empire was neither Holy, nor Roman, nor an Empire… discuss!
[This message has been edited by Siwko (edited 10-24-2000).]