When I resize the window (resize with mouse at right bottom of the program window), the window will flickering.

Anyone can tell me what's wrong with my code?

Posted on 2003-06-24 08:45:36 by QS_Ong
running that app gives me a GPF.

CMMEDIT caused a general protection fault
in module KERNEL32.DLL at 0167:bff73641.
EAX=00000000 CS=0167 EIP=bff73641 EFLGS=00010246
EBX=0054f644 SS=016f ESP=00000010 EBP=0054f610
ECX=00000000 DS=016f ESI=00008668 FS=4737
EDX=00402ca9 ES=016f EDI=00000010 GS=0000
Bytes at CS:EIP:
5f 5e c9 c2 0c 00 52 51 33 c0 48 50 50 65 ff 32
Stack dump:
00700465 f000ff54 f0008008 f000e814 d0000000
0a040028 f000ef6f f000ef6f f000ef6f f000ef6f
0a04009a 00700465 d0700007 f000f84d f000f841 fd6424d7

But I know how to solve the problem.
There are two ways - 1) set the window's hBrush to be 0 (at class-registering time).
2) process WM_ERASEBKGND , returning 0 or 1 immediately.
You can combine them both :)
When the window gets resized, it all (or only the new parts) gets invalidated (marked as 'dirty'). Then windows sends a WM_ERASEBKGND message to this window, and the DefWindowProc() gets the background brush, that is usually grey or white, and paints all the window in white/grey. Immeditely after that, the window gets a WM_PAINT message, and that before the window gets painted, the user sees that ugly void window for a fraction of the second, and this is ugly :).
Posted on 2003-06-24 13:08:10 by Ultrano
Posted on 2003-07-02 00:11:19 by QS_Ong