PRB: Most Common Cause of SetPixelFormat() Failure
Article ID: 126019
Article Last Modified on 11/21/2006
APPLIES TO
- Microsoft Win32 Application Programming Interface, when used with:
- Microsoft Windows NT Server 3.5
- Microsoft Windows NT Server 3.51
- Microsoft Windows NT Server 4.0 Standard Edition
- Microsoft Windows NT Workstation 3.5
- Microsoft Windows NT Workstation 3.51
- Microsoft Windows NT Workstation 4.0 Developer Edition
This article was previously published under Q126019
SYMPTOMS
SetPixelFormat() fails with incorrect class or window styles.
CAUSE
Win32-based applications that use Microsoft's implementation of OpenGL to
render onto a window must include WS_CLIPCHILDREN and WS_CLIPSIBLINGS
window styles for that window.
RESOLUTION
Include WS_CLIPCHILDREN and WS_CLIPSIBLINGS window styles when in a Win32-
based application, you use Microsoft's implementation of OpenGL to render
onto a window.
Additionally, the window class attribute should not include the CS_PARENTDC
style. The two window styles can be added to the dwStyles parameter of
CreateWindow() or CreateWindowEX() call. If MFC is used, override
PreCreateWindow() to add the flags. For example:
BOOL CMyView::PreCreateWindow(CREATESTRUCT& cs)
{
cs.style |= (WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
return CView::PreCreateWindow(cs);
}
For more information, please refer to "comments" section of the online
documentation on SetPixelFormat.
STATUS
This behavior is by design.
Additional query words: 4.00
Keywords: kbnofix kbprb KB126019