Hi guys,

I have this problem. When my dialog (modeless) is minimised then restored, it will end up looking like the attached image. When I forcely request for it to repaint, drag a window over the dialog etc, it look okay. So my question is what caused it?

Here;s my code for the dialog. (Just 211 lines long) It's fasm btw.



proc MessageWindow,hwnddlg, msg, wparam, lparam
.hList rd 1
.h1011 rd 1
.h1012 rd 1
.h1013 rd 1
.h1014 rd 1
.h1015 rd 1
.h1016 rd 1
enter
push ebx
push edi
mov eax, [msg]
cmp eax, WM_INITDIALOG
jz .wminitdialog_msg
cmp eax, WM_COMMAND
je .wmcommand_msg
cmp eax, WM_CLOSE
jz .wmclose_msg
cmp eax, WM_SETCLASS
jz .wmsetclass_msg
cmp eax, WM_RECVMSG
jz .wmrecvmsg_msg
cmp eax, WM_SIZE
je .wmsize_msg
cmp eax, WM_NCACTIVATE
je .wmncactivate_msg
.end_msg:
xor eax, eax
pop edi
pop ebx
return
.wmclose_msg:
invoke DestroyWindow,[hwnddlg]
jmp .end_msg
.wmncactivate_msg:
mov eax, [hwnddlg]
mov [htemp],eax
jmp .end_msg
.wminitdialog_msg:
mov eax, [hwnddlg]
mov [htemp],eax
invoke GetDlgItem, [hwnddlg],1012
invoke SetWindowLong,eax,GWL_WNDPROC,EditProc
mov [hDefEditProc],eax
invoke LoadIcon, hinstance, 16
invoke PostMessage, [hwnddlg],WM_SETICON, ICON_SMALL, eax
jmp .end_msg
.wmcommand_msg:
mov eax, [wparam]
cmp eax,1014
je .wmclose_msg
cmp eax, 1013
je .wmsend_msg
jmp .end_msg
.wmsetclass_msg:
mov ebx, [lparam]
invoke SetWindowLong, [hwnddlg], DWL_USER, ebx
stdcall FindByUin, ebx
cmp eax, -1
jnz @F
stdcall dwtoa, ebx, cookie
jmp .settext
@@:
mov [lvi.mask], LVIF_TEXT
mov [lvi.iItem], eax
mov [lvi.pszText], cookie
mov [lvi.cchTextMax], 30h
invoke SendMessage,[hList],LVM_GETITEM,0,lvi
.settext:
invoke SendMessage,[hwnddlg],WM_SETTEXT,0,cookie
jmp .end_msg
.wmrecvmsg_msg:
invoke GetWindowLong, [hwnddlg], DWL_USER
xchg eax, ebx
stdcall FindByUin, ebx
cmp eax, -1
jnz @F
stdcall dwtoa, ebx, cookie
jmp .addmsg
@@:
mov [lvi.mask], LVIF_TEXT+LVIF_PARAM
mov [lvi.iItem], eax
mov [lvi.pszText], cookie
mov [lvi.cchTextMax], 30h
invoke SendMessage,[hList],LVM_GETITEM,0,lvi
.addmsg:
invoke GetDlgItem,[hwnddlg],1011
xchg eax, edi
;Add text into editbox
push -2
push -1
invoke SendMessage,edi, EM_EXSETSEL,0,esp
add esp, 8
invoke SendMessage,edi, EM_REPLACESEL,0,cookie
invoke SendMessage,edi, EM_REPLACESEL,0,formatting
invoke SendMessage,edi, EM_REPLACESEL,0,[lparam]
invoke SendMessage,edi, EM_REPLACESEL,0,formatting+1
invoke SendMessage,edi, WM_VSCROLL,SB_ENDSCROLL,0
invoke SetFocus,edi
invoke GetDlgItem,[hwnddlg],1012
invoke SetFocus,eax
invoke FlashWindow, [hwnddlg], 1
jmp .end_msg
.wmsend_msg:
;build snac 4,6 to send to server
mov edi, buffer2
stdcall StringCopy2, edi, clientsendmsg1, sizeclientsendmsg1
add edi, sizeclientsendmsg1
call GetSequence
mov word[buffer2+2], ax
invoke GetWindowLong, [hwnddlg], DWL_USER
stdcall dwtoa,eax, buffer3
stdcall StrLen, buffer3
stosb
stdcall StringCopy2, edi, buffer3, eax
lea edi, [edi+eax]
stdcall StringCopy2, edi, clientsendmsg2, sizeclientsendmsg2
add edi, sizeclientsendmsg2
invoke GetDlgItemText, [hwnddlg], 1012, buffer3, 200h
or eax, eax
jz .end_msg
push eax
add eax, 4
xchg al, ah
stosw
add ah, 0dh - 4
adc al, 0
mov [edi-11],ax
xor eax, eax
stosd
pop eax
stdcall StringCopy2, edi, buffer3, eax
add edi, eax
stdcall StringCopy2, edi, clientsendmsg3, sizeclientsendmsg3
mov eax, edi
sub eax, buffer2-sizeclientsendmsg3
lea ecx, [eax-6]
xchg cl, ch
mov word[buffer2+4], cx
invoke ws_send, [hSock], buffer2, eax, 0
invoke SendDlgItemMessage,[hwnddlg], 1012, WM_SETTEXT,0,0
invoke GetDlgItem,[hwnddlg], 1011
xchg eax, edi
;Add text into editbox
push -2
push -1
invoke SendMessage,edi, EM_EXSETSEL,0,esp
add esp, 8
invoke SendMessage,edi, EM_REPLACESEL,0,nick
invoke SendMessage,edi, EM_REPLACESEL,0,formatting
invoke SendMessage,edi, EM_REPLACESEL,0,buffer3
invoke SendMessage,edi, EM_REPLACESEL,0,formatting+1
invoke SendMessage,edi, WM_VSCROLL,SB_ENDSCROLL,0
invoke SetFocus,edi
invoke GetDlgItem,[hwnddlg],1012
invoke SetFocus,eax
jmp .end_msg
.wmsize_msg:
;begin - resize message dialog
invoke GetDlgItem,[hmsg],1011
mov [.h1011],eax
invoke GetDlgItem,[hmsg],1012
mov [.h1012],eax
invoke GetDlgItem,[hmsg],1013
mov [.h1013],eax
invoke GetDlgItem,[hmsg],1014
mov [.h1014],eax
invoke GetDlgItem,[hmsg],1015
mov [.h1015],eax
invoke GetDlgItem,[hmsg],1016
mov [.h1016],eax
invoke GetClientRect,[hmsg],rect
mov eax,[rect.right]
mov ecx,[rect.bottom]
sub ecx,164
sub eax,22
invoke MoveWindow,[.h1011],11,11,eax,ecx,0
invoke GetClientRect,[hmsg],rect
mov ecx,[rect.bottom]
sub ecx,152
invoke MoveWindow,[.h1016],11,ecx,50,14,1
invoke GetClientRect,[hmsg],rect
mov eax,[rect.right]
sub eax,22
mov ecx,[rect.bottom]
sub ecx,138
invoke MoveWindow,[.h1012],11,ecx,eax,94,0
invoke GetClientRect,[hmsg],rect
mov eax,[rect.left]
add eax,12
mov ecx,[rect.bottom]
sub ecx,34
invoke MoveWindow,[.h1015],eax,ecx,75,23,1
invoke GetClientRect,[hmsg],rect
mov eax,[rect.right]
sub eax,85
mov ecx,[rect.bottom]
sub ecx,34
invoke MoveWindow,[.h1013],eax,ecx,75,23,1
invoke GetClientRect,[hmsg],rect
mov eax,[rect.right]
sub eax,163
mov ecx,[rect.bottom]
sub ecx,34
invoke MoveWindow,[.h1014],eax,ecx,75,23,1
invoke GetDlgItem,[hwnddlg], 1011
xchg eax, edi
invoke SendMessage,edi,WM_VSCROLL,SB_ENDSCROLL,0 ; does not seem to work
;end - resize msg dialog
jmp .end_msg
endp
Posted on 2004-06-24 09:53:58 by roticv
What I usually do is in the WM_SIZE message I move all my windows using MoveWindow and the repaint flag set to FALSE (you have some false, some true), then at the end of the wm_size handler I insert a InvalidateRect repainting the whole thing in one go.

Hope that helps.
Posted on 2004-06-24 10:07:11 by JimmyClif
Thanks mate. You have pointed me in the correct direction. When I changed all to TRUE, it looks perfect now. Thanks!
Posted on 2004-06-24 10:11:24 by roticv