News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Flicker Problems

Started by hfheatherfox07, February 07, 2013, 01:22:35 PM

Previous topic - Next topic

hfheatherfox07

Hello All ....
The same ole Flicker Problem.... :(
I tried to apply all that I have learned here to solve it , including erasing the background but it still flickers ...
Any ideas ?


Thank you !

Bounce the Ball
Your code and your skills will be assimilated. Your programming language is irrelevant.
We are the ASM Borg and you will become part of us. Compile and be assembled.

Don57

This article might help.

http://msdn.microsoft.com/en-us/library/windows/desktop/bb206356(v=vs.85).aspx

qWord

- use the WS_CHLIPCHILDREN style for the dialog to avoid flickering of the controls
- set the background color of the dialog to zero or catch WM_ERASEBKGND and return nonzero.
- you may use a memory DC for the whole client area (thus you have only one copy operation to the screen DC)
- AnimB is buggy:
AnimB PROC hWin:DWORD, hBitmap, YPix
LOCAL ps:PAINTSTRUCT
LOCAL hdc:HDC
LOCAL hMemDC:HDC
LOCAL hBmp:HBITMAP ; <--
LOCAL rect:RECT
LOCAL y:BYTE
invoke BeginPaint,hWin,addr ps
mov    hdc,eax
invoke CreateCompatibleDC,hdc
mov    hMemDC,eax
invoke SelectObject,hMemDC,hBitmap
mov hBmp,eax ; <--
invoke GetClientRect,hWin,addr rect
invoke BitBlt,hdc,0,0,rect.right,rect.bottom,hMemDC,0,0,WHITENESS
mov eax, YPix
mov eax, dword ptr [eax]
invoke BitBlt,hdc,35,eax,rect.right,rect.bottom,hMemDC,0,0,SRCCOPY
invoke SelectObject,hMemDC,hBmp ; <--
invoke DeleteDC,hMemDC
invoke EndPaint,hWin,ADDR ps ; <--
Ret
AnimB EndP

MREAL macros - when you need floating point arithmetic while assembling!

hfheatherfox07

thanks qWord ..
the WS_CHLIPCHILDREN worked great on the controls , but the rest still flickers ...
Sorry a bit messy ...tried a few things
I was going to create layer like in those star fields
Your code and your skills will be assimilated. Your programming language is irrelevant.
We are the ASM Borg and you will become part of us. Compile and be assembled.

hfheatherfox07

What you are saying to do is the same as here :
http://www.catch22.net/tuts/flicker-free-drawing

But it is still not working  :(

Your code and your skills will be assimilated. Your programming language is irrelevant.
We are the ASM Borg and you will become part of us. Compile and be assembled.

hfheatherfox07

Quote from: qWord on February 08, 2013, 10:29:08 AM
- set the background color of the dialog to zero or catch WM_ERASEBKGND and return nonzero.

I don't think I understand that ... I undersatnd returning non zero ,I added return macro and ...
return 1
i don't understand "background color of the dialog to zero"
Here is an example that used the same background color that I used to create to scrolling text ....
I added ...
invoke GetClientRect,hWin,ADDR rect
mov hdc,FUNC(GetDC,hWin)
mov hMemDC,FUNC(CreateCompatibleDC,hdc); creats window
mov hbmp,FUNC(CreateCompatibleBitmap,hdc,rect.right,rect.bottom); creats window
    invoke SelectObject,hMemDC,addr ps
mov rClientWindow.top,1
mov rClientWindow.left,1
m2m rClientWindow.right,rect.right
m2m rClientWindow.bottom,rect.bottom   
dec rClientWindow.bottom
dec rClientWindow.right
invoke FillRect,hMemDC,ADDR rect,NULL ; color for window


5:25 AM time to sleep LOL
Your code and your skills will be assimilated. Your programming language is irrelevant.
We are the ASM Borg and you will become part of us. Compile and be assembled.

qWord

Quote from: hfheatherfox07 on February 08, 2013, 09:25:14 PMi don't understand "background color of the dialog to zero"
sorry, I meant the background brush (handle). However, for dialogs it might be more applicable to catch WM_ERASEBKGND.

If it still flickers, use a memory DC for the whole client area that is copy to the screen while WM_PAINT. Drawing the ball on the mem. DC could be done while handling WM_TIEMR.

EDIT: you draw twice: for timer 1 and while handleing WM_PAINT. See attachemnt.
MREAL macros - when you need floating point arithmetic while assembling!

dedndave

sometimes, the background being re-drawn, then everything being painted on top of it causes flicker
it's like a paint, then re-paint action

by using 0 for the class background brush, no background is drawn
that leaves the responsibility for updating it up to you
as qWord said, this can also be accomplished by handling WM_ERASEBKGND messages

you can handle it by creating a DIB section for the entire client area and filling in the background, then painting
when you blit over to the window hDC, you blit only the part that is requested in the PAINTSTRUCT structure
this prevents updating the entire client area when only a small part is required

jj2007

Erasing a non-white background is likely to cause flicker if done for the whole client area. The proper procedure would be to invalidate only the rectangle that the ball just left behind, and let the OS do the job.

hfheatherfox07

Quote from: qWord on February 08, 2013, 10:14:34 PM
Quote from: hfheatherfox07 on February 08, 2013, 09:25:14 PMi don't understand "background color of the dialog to zero"
sorry, I meant the background brush (handle). However, for dialogs it might be more applicable to catch WM_ERASEBKGND.

If it still flickers, use a memory DC for the whole client area that is copy to the screen while WM_PAINT. Drawing the ball on the mem. DC could be done while handling WM_TIEMR.

EDIT: you draw twice: for timer 1 and while handleing WM_PAINT. See attachemnt.

Thanks qWord!!!!
I am still trying to wrap my head around all that and actually try to understand it so I can use it in other situations
Thank you again! :biggrin:
Your code and your skills will be assimilated. Your programming language is irrelevant.
We are the ASM Borg and you will become part of us. Compile and be assembled.

hfheatherfox07

Quote from: jj2007 on February 09, 2013, 03:35:35 AM
Erasing a non-white background is likely to cause flicker if done for the whole client area. The proper procedure would be to invalidate only the rectangle that the ball just left behind, and let the OS do the job.

I tried that with the first example but I was not successful ...
I tried ...

invoke InvalidateRect,hWin,addr rect,FALSE
invoke RedrawWindow, hWin, 0,0,RDW_INVALIDATE
Your code and your skills will be assimilated. Your programming language is irrelevant.
We are the ASM Borg and you will become part of us. Compile and be assembled.