I have this problem when drawing rectangles; when i resize the window gaps appear between the rectangles.
assemble and slowly resize the window and you'll see the gaps
i'm sure i saw somewhere how to fix this but don't remember where
[attachment deleted by admin]
Hi raneti,
Welcome on board. I downloaded and built the app and while it flickers like mad on resize, I cannot duplicate the effect, the line thickness between some of the rectangles varies a bit but I cannot get any spaces. Clicking in each square alternately displays a diagonal cross done the the MoveToEx(), LineTo() functions.
Change this line,
mov wc.hbrBackground, COLOR_WINDOW+1
to
mov wc.hbrBackground, NULL
and this will fix the flicker problem.
The slight variation with the rectangle location may be an effect of tolerance from the FP calculations.
with COLOR+1
(http://img180.imageshack.us/img180/2585/gapcolor1et6.jpg)
with NULL
(http://img180.imageshack.us/img180/1686/gapnullli1.jpg)
with NULL less gaps appear, border changes from 1 pixel to 2 and back as usual.
This C code(attached) does the same with no gaps.
The only difference is
wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
and perhaps consistency in the way it treats fractional numbers(perhaps my code rounds while C truncs?)
[attachment deleted by admin]
This is the solution, courtesy of arafel:
; child windows 1..4
mov temp2, 4
fld1 ; 1
fild temp2 ; 4, 1
fdivp ST(1), ST(0) ; 1/4
fild cxClient ; cxClient, (1/4)
fmulp ST(1), ST(0) ; cxClient * (1/4)
fistp temp2 ; temp2 = ST(0), FPU stack balanced
mov temp3, 7
fld1 ; 1
fild temp3 ; 7, 1
fdivp ST(1), ST(0) ; 1/7
fild cyClient ; cxClient, (1/7)
fmulp ST(1), ST(0) ; cxClient * (1/7)
fistp temp3 ; temp3 = ST(0), FPU stack balanced
mov ecx, 4
push esi
xor esi, esi
push edi
xor edi, edi
label2::
mov eax, temp2
imul eax, edi
mov temp1, eax
cmp edi, 3 ; in case when window's width doesn't divide equally - set last child's width manually.
jne @f
mov eax, [cxClient]
sub eax, temp1
mov temp2, eax
@@:
push ecx
invoke MoveWindow, [ChildHandlesArray+esi], temp1, 0, temp2, temp3, TRUE
inc edi
add esi, 4
pop ecx
loop label2
mov eax, temp2
mov temp4, eax ; cxClient * (1/4)
Alltough i don't understand the "why and how"yet, it works.
EDIT: DELETED: I finally got it.