Microsoft KB Archive/94236

{|
 * width="100%"|

INFO: Using Device Contexts Across Threads

 * }

Q94236

3.10 3.50 3.51 WINDOWS NT kbgraphic

-

The information in this article applies to:


 * Microsoft Win32 Application Programming Interface (API)
 * Microsoft Windows NT Workstation versions 3.1, 3.5, 3.51

-

SUMMARY
A window created with the CS_OWNDC style retains its device context (DC) attributes across GetDC calls.

However, the DC attributes are not retained if the GetDC calls are called from different threads. This is by design because DCs are thread-based. In the Win32 user interface, if the calling thread is not the owner of the window, then GetDC returns a cache DC instead of the owned DC handle.

To save attributes across threads, one must create a routine to initialize DC attributes, which is then called from threads not owning the given window.

Additional query words: 3.10

Keywords : kbOSWinNT310 kbOSWinNT350 kbOSWinNT351 kbOSWin32s

Issue type : kbinfo

Technology : kbWinNTsearch kbWinNTWsearch kbWinNT351xsearch kbWinNT350xsearch kbWinNTW350 kbWinNTW350xsearch kbWinNTW351xsearch kbWinNTW351 kbWinNTW310 kbAudDeveloper kbWinNT310xSearch kbWinNTW310Search kbWin32sSearch kbWin32API