Hi !

I have a little problem with two controls created as child of a "CreateWindow"ed main window...

On this main window, as a background, I fill the color with white and put a bitmap in the center of the window using double buffering...
All works rather nicely without too much noticeable flickering...

Now, I have a toolbar and a statusbar at the top and at the bottom of this window and when the user resizes the window, these controls flickers a lot !

If I remove the wndclass.style = CS_HREDRAW | CS_VREDRAW; there is no flickering, but I need these styles to receive the WM_SIZE messages... otherwise, the background won't get recentered/updated...

In my window, I return FALSE to the WM_ERASEBKGND message to avoid flickering with bitmap...

Maybe double buffer these toolbar and statusbar controls ? But I don't have much idea how to do it... I am not a GDI guru and I assume I will have all the drawing of the control to do by myself, which is not very nice...

I don't know what to do to remove this flicker... suggestions, and better solutions would really be appreciated. ;-)

Thanks !
Posted on 2003-03-17 12:59:49 by JCP
If I remeber correctly the CS_VREDRAW/HREDRAW style bits will invalidate the whole window if user resizes the window. It has nothing to do with WM_SIZE message. You will get it in any case. So I would suggest to remove this style bits and do any recalculations in WM_SIZE handler routine.
Posted on 2003-03-17 14:15:18 by japheth
Don't know if this will help. There is a WS_CLIPCHILDREN option for styles. Apply it to the main window when you create it.
Posted on 2003-03-17 14:19:01 by tenkey
You should still be getting the WM_SIZE messages without though styles. Try calling the repainting proc directly from inside the WM_SIZE message. Basically whatever you would do during a WM_PAINT message also do in the WM_SIZE message.

That should sort the bitmap. Note if you'll want to resize the controls as the main window resizes use MoveWindow on them with the repaint flag set to -1 (thats TRUE isn't it? Seem to have completly slipped out of my mind :) )

One final thing. If the back buffer needs to be resized each time the main window resizes then I recommend you always round the buffer size up to the next 32 pixels or so. This will reduce the amount of times the buffer needs to be recreated.

Its a bit of a mess but if you look at the source for the library I was working on in, the InitGC proc in the file Amethyst.asm, you'll see what I mean.
Posted on 2003-03-17 14:22:28 by Eóin
You are right, I still receive WM_SIZE messages, but the window is not invalidated : that this...

So, I left my code like it is, I only removed the CS_VREDRAW and CS_HREDRAW style (replaced them by 0) and called



InvalidateRect(hWndMain, NULL, TRUE);


In the WM_SIZE handler and everything seems to work fine without flicker...
Still has some testing to do but it is much better anyway...

I also tried the WS_CLIPCHILDREN style before asking, but it absolutely did nothing... :(

Thanks !

*EDIT* : I removed the WS_CLIPCHILDREN style and it flickers again: so both WS_CLIPCHILDREN style and what is before this are needed...
Posted on 2003-03-17 15:03:20 by JCP
Hi, Radiosys,

I think you can solve it by keeping the CS_HREDRAW or CS_VREDRAW flags, because you will still receive WM_SIZE messages, but whenever you process a WM_SIZE message, make sure you invalidate the client rectangle of the main window and send a WM_PAINT message to it. This should work for you, I used it.
But maybe I am more forgiving of flicker.

Now that you mentioned tollbars and status bar, I have a problem with these:
the toolbar covers the top of the main window's client area. Statuis bar covers the bottom.

How do I change the size and position of the client rectangle?

I posted this question on the message board but so far I only got one message that dosn't really apply.
I would appreciate it if you could send me a reply. My post is called "Changing client area size".

Best regards,
VVV
Posted on 2003-03-19 20:08:36 by VVV

[...]and send a WM_PAINT message to it.

I hope you don't mean manually SendMessage'ing WM_PAINT :P
Posted on 2003-03-20 01:59:12 by f0dder

Hi, Radiosys,

Now that you mentioned tollbars and status bar, I have a problem with these:
the toolbar covers the top of the main window's client area. Statuis bar covers the bottom.

How do I change the size and position of the client rectangle?


Hi,

I am not sure to get exactly what you want : you want to resize the toolbar and the status bar to the parent window's size when the user resizes it ?

Regards,
Posted on 2003-03-20 03:42:12 by JCP
Hi, Readiosys,

Here is the actual code I am using. I was wrong about sending the WM_PAINT message explicitly. Instead, I call the UpdateWindow function which in return will will send the WM_PAINT message. Also, note that when I invalidate the rectangle, the background redraw flag (last parameter) is FALSE. That prevents the background from being erased before repainting. I tested this and it makes a great deal of difference. The window is not exacly flicker-free, but there is very little flicker, to my opinion. The CS_VREDRAW and CS_HREDRAW are also NULL in my case.

add eax, OFFSET RW_Buffer ;calculate offset of first byte to be displayed
FILLBUFF Linecount,eax,OFFSET Buffer,OFFSET ConvTable,Counter ;fill the required # of lines in display buffer
invoke InvalidateRect,hWnd,ADDR rect,FALSE ;invalidate rect
invoke UpdateWindow,hWnd ;update window
RETURN_0 ;return 0, as we should
;-----------------------------------------------------------------

Ignore the first two lines. It's the last three that you need in your code.

Good luck.
Posted on 2003-03-20 20:15:00 by VVV
Hi, there,

Please take a look at the attachment. Note how the scrollbar actually overlaps the toolbar and the status bar. You can see at the top I am losing 1 1/2 lines of text, because the toolbar covers the top of the window's client area. Similar thing at the bottom, because of the status bar.

Best regards,
VVV
Posted on 2003-03-20 20:33:04 by VVV