I am displaying 256 boxes on a dialog using FillRec.
When the dialog is first displayed the whole dialog shimmers, but if I move the dialog it stops and is the display is OK.
Any ideas how I can stop this?
Thanks,
David
Shimmering colours
Shimmering colours
For more complete information about compiler optimizations, see our Optimization Notice.
Jugoslav,
Here is the code for drawing the 256 colours (in fact 16 colours drawn 16 times at present). The main call are CreateSolidBrush, FillRect & DeteObject - all the rest is drawing the rectangles in the correct place.
grad_inc & the *.gcb files contain global variables.
Regards,
David
IMO it's quite incommon to do the drawing directly on
dialog's hDC. Even as you wrote it, its atypical for standard
WM_PAINT handling. You can try two things:
1) Add
(also remove line hDcClr=GetDC(...))
I think that dialog shimmers because noone has ever
validated the update region, so Windows keep on
sending WM_PAINT until the region is validated another
way. ValidateRect documentation says that, quote,
"The BeginPaint function automatically validates the entire client area. Neither the ValidateRect nor ValidateRgn function should be called if a portion of the update region must be validated before the next WM_PAINT message is generated. Windows continues to generate WM_PAINT messages until the current update region is validated."
b) Nevertheless, I think it's clearer to do the drawing in an owner-
drawn static control. So, make IDC_COLOURS an owner-drawn static control
Unfortunately, Visual Studio 5 (nor 6, as I checked) does not have "Owner drawn" check-box for static control on property sheet. You have to edit .rc file manually later - add SS_OWNERDRAW style to your control:
CONTROL "",IDC_COLOURS,"Static",SS_OWNERDRAW,11,16,116,120
then, instead of WM_PAINT, process WM_DRAWITEM in SetColourProc:
and leave the rest of the code more or less the same.
Owner-drawn controls are very powerful for obtaining nice
effects with controls.
HTH
Jugoslav
Jugoslav
www.xeffort.com
Thanks, I used the BeginPaint / EndPaint and the colours are now OK.
David



