flat assembler
Message board for the users of flat assembler.

Index > Windows > dialogbox control flicker problem

Author
Thread Post new topic Reply to topic
dave_30



Joined: 15 Dec 2012
Posts: 14
dave_30 15 Dec 2012, 12:16
i'm working on the new interface for my program and i'm using dialogbox just to make my work just a little bit easier.
i'm using dib for the animations (drawing the stuff first into another dc) and then bitblt to copy it to the original dc everything seems to be fine except i if i add any control to my dialogbox control itself starts to flicker!but i found out that the redrawwindow windows api causes this since that's what i've used to update the window after doing the animations.
here is the code:

Code:
proc DlgProc uses ebx esi edi,hwndDlg,uMsg,wParam,lParam

local dummy dd ?

mov eax,[uMsg]
mov ebx,[wParam]
cmp eax,WM_INITDIALOG
je InitlizeApp
cmp eax,WM_CLOSE
je EndApp
cmp eax,WM_LBUTTONDOWN
je DragApp
cmp eax,WM_RBUTTONUP
je EndApp
cmp eax,WM_PAINT
je Paint
cmp eax,WM_TIMER
je Timer
cmp eax,WM_COMMAND
je BtnClk
cmp eax,WM_ERASEBKGND
je ProcessedMsg
xor eax,eax
jmp Finish

InitlizeApp:
push [hwndDlg]
pop [hwnd]
invoke SetTimer,[hwnd],1,1,0
invoke SetTimer,[hwnd],2,100,0
;stdcall uFMOD_PlaySong,Song,0,XM_RESOURCE
stdcall InitlizeGFX
jmp ProcessedMsg

DragApp:
stdcall DragObj,[hwnd]
jmp ProcessedMsg

Timer:
.if ebx = 1
stdcall DrawGFX
.elseif ebx = 2
stdcall TrnOptions
.endif
jmp ProcessedMsg

Paint:
stdcall CpyGFX
jmp ProcessedMsg

EndApp:
stdcall GFXShutDown
;stdcall uFMOD_PlaySong,0,0,0
invoke EndDialog,[hwnd],0

BtnClk:
cmp bx,1
jne ProcessedMsg

ProcessedMsg:
mov eax,1

Finish:
ret

endp

proc CpyGFX

local ps PAINTSTRUCT

mov ebx,[hwnd]
lea esi,[ps]
invoke BeginPaint,ebx,esi
invoke BitBlt,[hdc],0,0,ScreenWidth,ScreenHeight,[CanvasDc],0,0,SRCCOPY
invoke EndPaint,ebx,esi
ret

endp

proc DrawGFX

mov edi,[CanvasBuf]
mov ecx,ScreenWidth * ScreenHeight
xor eax,eax
repe stosd
call DrawStars
stdcall SetText,180,87,PrText,[bmpFont],0
stdcall DrawBitmapImg,0,0,[MainImgData],0,0
invoke GetClientRect,[hwnd],rc       
invoke RedrawWindow,[hwnd],rc,0,RDW_INVALIDATE
ret

endp    


is there anyway to fix the flicker problem on the controls?

edit by revolution: placed code tags
Post 15 Dec 2012, 12:16
View user's profile Send private message Reply with quote
nmake



Joined: 13 Sep 2012
Posts: 192
nmake 15 Dec 2012, 12:24
WS_CLIPCHILDREN and WS_CLIPSIBLINGS is your friend. Also engage WM_ERASEBKGND and return TRUE from it. Set hbrBackground brush to 0 in the WNDCLASSEX window structure (if using a non-dialog), and of course do double buffering if necessary in WM_PAINT. Spend as little time as possible doing calculations in WM_PAINT, do all calculations outside of WM_PAINT to save time in the WM_PAINT handler. Things you can do, create a dib section that is as large as the entire screen so you dont have to re-create it every time the window resizes. You save time that way.
Post 15 Dec 2012, 12:24
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2909
Location: 0x77760000
typedef 15 Dec 2012, 18:39
TIP: Your code formatting is eye straining.
Post 15 Dec 2012, 18:39
View user's profile Send private message Reply with quote
dave_30



Joined: 15 Dec 2012
Posts: 14
dave_30 16 Dec 2012, 18:44
nmake wrote:
WS_CLIPCHILDREN and WS_CLIPSIBLINGS is your friend. Also engage WM_ERASEBKGND and return TRUE from it. Set hbrBackground brush to 0 in the WNDCLASSEX window structure (if using a non-dialog), and of course do double buffering if necessary in WM_PAINT. Spend as little time as possible doing calculations in WM_PAINT, do all calculations outside of WM_PAINT to save time in the WM_PAINT handler. Things you can do, create a dib section that is as large as the entire screen so you dont have to re-create it every time the window resizes. You save time that way.

i've added WS_CLIPCHILDREN and now flicker is gone,thx.
Post 16 Dec 2012, 18:44
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.