Hi, I'm having problems with screen flicker and as I understand it BitBlting is the way to go.
In all of the examples I see, however, they use bitmaps.... I'm not using any bitmaps, just a lot of DrawText() calls.
Can BitBlt be used for DrawTexts?
I imagine that it would look something like this?
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
PAINTSTRUCT ps;
HDC hdc,compat;
RECT rect;
...
...
case WM_PAINT:
GetClientRect(MsghWnd,&rect);
BeginPaint(MsghWnd,&ps);
hdc=GetDC(MsghWnd);
compat=CreateCompatibleDC(hdc);
DrawText(compat,"test text",strlen("test text"),&rect,DT_TOP|DT_LEFT);
BitBlt(hdc,0,0,rect.right,rect.bottom,compat,0,0,SRCCOPY);
DeleteDC(compat);
EndPaint(MsghWnd,&ps);
|
Or, since I'm only drawing text, is there a different approach that may work better?
One problem I was having was that when I dragged the window, the text would redraw all over itself - the text would get super thick and black. It was still legible, but it definitely didn't look right.
To resolve that problem, I simply invalidated the window in WM_MOVE to force it to repaint. This resolved that problem perfectly... however it created the screen flashing problem. There were other occurrences of the screen flashing, but this was by far the most dramatic case of it.
The program is laid out in a MDI-ish approach. Each client window is fixed in place, but it is a parent window with a number of client windows... the parent window never has anything to draw, it's all the child windows. And each child window has an object associated with it. Would I possibly be able to reduce the flashing problem by adding an HDC to each object, letting it keep track of when the text has changed, and simply BitBlting the stored DC rather than re-DrawText-ing everything each paint?