Hi,
I know this is possible with GDI but that is flickering like hell. Is there a way to draw some text in an existing directx9 window without this flickering issue?
Ive stumbled across DirectDraw but it seems so damn complex.. What would you guys suggest me? Can anyone hook me with a small example?
Thanks in advance.
use the forum search tool
look for "CreateCompatibleDC", "BitBlt", "DIB"
you might also try "flicker"
mov hDC, rv(GetDC, hCanvas) ; canvas can be the main window, or a static child, or an edit window, or ...
mov memDC, rv(CreateCompatibleDC, eax) ; prepare for a bitmap
mov hBmp, rv(CreateCompatibleBitmap, hDC, esi, ebx) ; hDC, not memDC!
invoke SelectObject, memDC, eax
CASE WM_PAINT
... do drawing to memDC ...
lea edi, ps ; ptr PAINTSTRUCT
invoke BeginPaint, hCanvas, edi
invoke BitBlt, eax, 0, 0, rc.right, rc.bottom, memDC, 0, 0, SRCCOPY
invoke EndPaint, hCanvas, edi
And read Microsoft's view on CS_OWNDC (http://www.microsoft.com/msj/0298/c0298.aspx) vs Raymond Chen's view (http://blogs.msdn.com/b/oldnewthing/archive/2006/06/01/612970.aspx)
There are three things to keep in mind to avvoid flicker.
1: You should avvoid the system of erasing the background of the window, if it does that it will update the window pixels data two times per one time window update, this will produce flicker.
2: You should use double buffering with a compatible dc and bitmap.
3: If your controls flicker you can set WS_CLIPCHILDREN in the style of your window
Beside this you can also look into the the extended window style WS_EX_COMPOSITED, it speaks about double buffering, I havent checked it out though, just recall I've seen it.
Quote from: zemtex on February 11, 2011, 08:45:23 AM
WS_EX_COMPOSITED
Can someone explain WS_EX_COMPOSITED (http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/ca0e6cc1-8e03-4dfc-832d-0a7a6ae38d56)
controls implemented as non managed child window's are deprecated. Support to draw them flicker free has been effectively removed
Microsoft at work :lol
Quote3: If your controls flicker you can set WS_CLIPCHILDREN in the style of your window
thanks for the tip zemtex
hadn't thought of it, but it makes perfect sense