Smooth drawing for a window ?(win CE)
-
When you move a dialog (or a CWnd object) your dialog's background will be repainted. It make some unsmooth effects when you have to move your Window too much times (for example you build a drop down window). Have any solutions for this problem ?
Nothing Is Impossible !
-
When you move a dialog (or a CWnd object) your dialog's background will be repainted. It make some unsmooth effects when you have to move your Window too much times (for example you build a drop down window). Have any solutions for this problem ?
Nothing Is Impossible !
This isn't an easy question to answer, because it depends on how your application is structured. Fundamentally, you need to minimize the amount of painting you do. If you implement a
WM_PAINT
handler to paint the dialog's surface yourself, you should look into theGetUpdateRect
orGetUpdateRgn
functions to determine the area of the surface which actually needs to be repainted, and only perform painting operations that affect this area. (Windows clips painting to this area anyway, so any painting operations which go outside this area simply waste time). You can find out whether a rectangle will be drawn using theRectVisible
function. Alternatively, useIntersectRect
to find out if any part of one rectangle is within another (and the area that is within both),RectInRegion
to find out if any part of a rectangle is in that region, orPtInRect
andPtInRegion
to check whether a point is in the rectangle or region. If doing your own painting, it may be better to do as much painting as possible with one set of graphics objects rather than constantly swapping between different objects (for example, if you want two black lines and a red line, select a black pen, draw the two black lines, then select a red pen and draw the red line, rather than drawing the red line in between the two black ones). If you're overpainting the entire background of the window, consider implementing a handler forWM_ERASEBKGND
and returningTRUE
. This prevents some flicker generated by Windows painting the window background with the default background brush, then your painting code painting the actual desired result over the top. If you're not doing your own painting, consider reducing the number of controls on your dialog. When Windows has an invalid region on the screen, it has to generate aWM_PAINT
for every window that intersects the invalid region. The overhead can cause the overall painting operation to take a long time. You should ensure that any controls that aren't visible because another control is obscuring them are actually hidden (callShowWindow
with theSW_HIDE
flag). If these are controls that are part of the dialog template, hide any controls not initially active in the template.Stability. What an interesting concept. -- Chris Maunder