Hi everybody!
Recently I was checking out the "Show contents while dragging" option of Win98. I'm sure everybody is familiar with it: when either you drag the window or resize it the client area is redrawn. I'm sure this is just a matter of repeatedly sending WM_PAINT messages to the client.
Anyways, I noticed some programs get some bad shearing while repainting and other programs do the repainting really good. In particular I noticed that Notepad is pretty bad while My Computer (or explorer...) is pretty good even though the latter is drawing icons and instead of just plain text.
So.. my question is, how do programs paint faster? I had a couple ideas I was wondering if anyone can tell me what they think:

-CS_OWNDC style. Tried it... didn't seem to make a difference with a little game I was doing. My frame count stayed the same. However, what I was doing before was grabbing a DC in WM_CREATE and not releasing it until WM_DESTROY
-BeginPaint and EndPaint. Can these be replaced with simpler API calls?
-DrawText,TextOut,ExtTextOut. I read in the WinAPI that text outputs get converted to ExtTextOut so this should be the fastest.
-Memory DC. Is it faster to draw to memory and then blit to the screen? I know it's true for graphics, but what about documents or windows that need to be resized a lot?
-GetClientRect. Should I ever bother calling this, or when I get a WM_SIZE message should I just save the value of client width and height at that point and use those as reliable values?
-FillRect and Rectangle. Which will draw a solid rectangle faster? Should I use one of these in WM_ERASEBKGND instead of the class background brush?
-How does CreateSolidBrush work? Does it just add 1 to the RGB triplet? I know a lot of WinAPI calls need one added to a colour before they draw it.
-Anyone know of a quick way to change the current font to bold?

I'm currently looking into all of these options for my program.. but wondered if anyone knew of a "for sure" statement regarding any of these

Thanks

--Chorus
Posted on 2002-04-10 09:25:37 by chorus
ok.. checked the CreateSolidBrush funtion and it returns a different handle everytime it's called for the same colour, so I guess that answers that question.

I also checked out using the WM_SIZE message to track the client rectangle and it works fine, so I'm no longer calling GetClientRect.

And my WinAPI says that DrawText, TabbedTextOut and TextOut are all converted to one or more calls of ExtTextOut.


--Chorus
Posted on 2002-04-10 10:59:45 by chorus
I dont think that most of the points you wrote, have a visible effect to the redraw speed. There are only two major points:

1. dont erase the background
put a zero brush into the window class during RegisterClass or skip the WM_ERASE message.
This leads to much more flickerfree redrawing

2. using a memory dc for painting and a finally bitblt to the main window avoids
that the single painting instructions (TextOut, etc.) are done one after each other.

I think, BeginPaint, EndPaint, GetClientRect or DrawText are really fast enough.
Posted on 2002-04-10 13:02:08 by beaster