>>>It's not a bug. Your assumption that shape is centered horizontaly from the beginning is incorrect.
>>
>>Where I have written this ???????
>
>DEBUGOUT "start centered", ...
>
If top and bottom margin are equal, it is centered !
>>
>>>The shape center is one pixel closer to the top border of the form than to the bottom.
>>
>>Sergey, please,
>>run the code with NNHEIGHT 1, 2 and 3, 4
>>With 2 it is ok,
>>with 1 it is not moved
>>with 3 it is moved to a incorrect position
>>with 4 it is correct
>>......
>
>It's moved to the correct position according to Anchor = 512 and original position of the shape center. The problem is that center of the shape with odd height is 1 pixel closer to it's top border than the bottom one.
Sergey,
- run this,
- look outputs
- run with NSIZE 3
Now, I hope you can see the bug.
ACTIVATE WINDOW "debug output"
#DEFINE NSIZE 4
PUBLIC oform1
oform1=NEWOBJECT("form1")
oform1.Show
RETURN
DEFINE CLASS form1 AS form
Top = 0
Left = 0
BACKCOLOR = 255
Height = NSIZE + 2
Width = 130+ NSIZE + 2
DoCreate = .T.
Caption = ""
Name = "Form1"
resizable = .F.
ADD OBJECT shape1 AS shape WITH ;
Top = 1, ;
Left = 1, ;
Height = NSIZE , ;
Width = 130+NSIZE , ;
Anchor = 512+256, ;
Name = "Shape1",;
ENABLED = .f.
PROCEDURE shape1.Init
DEBUGOUT "top Border",this.top,"bottom border",thisform.Height-this.Height-this.top
DEBUGOUT "left Border",this.Left,"right border",thisform.Width-this.Width-this.left
ENDPROC
PROCEDURE shape1.Move ( nLeft, nTop, nWidth, nHeight )
DEBUGOUT "top",ntop,"left",nLeft;
,"bottom",thisform.Height-nHeight-ntop;
,"Right",thisform.Width-nWidth-nleft
ENDPROC
PROCEDURE Activate
FOR K=1 TO 200
this.Move(0,0,thisform.Width+2,thisform.Height+2)
this.draw
NEXT
ENDDEFINE
If you are not able to see,
ask to yourself this issue:
I can anchor a even sized to the center of the container,
but for a odd sized object i cannot
then => bug on computation.
Fabio