----------------------------------------------------------
                      [BUG/PRB.] VFP 9.0 FIX - FIX THE ANCHOR PROPERTY
                                  January 2022
                 ----------------------------------------------------------
                                     CCB



1. BUG:

     In vfp9, the Anchor property can only work fine when the Form.ScaleMode property is 3 (Pixels),
     it can not work fine when the Form.ScaleMode property is 0 (Foxels).

     The bug only occurs when the Form.ScaleMode property is 0 (Foxels).

     The bug only occurs when the Anchor property includes the following flags:
     4 (Bottom Absolute), 8 (Right Absolute), 16 (Top Relative), 32 (Left Relative),
     64 (Bottom Relative), 128 (Right Relative), 256 (Horizontal Fixed Size), 512 (Vertical Fixed Size).

     The bug also occurs for the PageFrame control when we set the TabOrientation property.

     In vfp9, the Anchor property can not work fine when the Form.ScaleMode property is 0 (Foxels), please refer to the picture testanchor-vfp9.jpg:


2. CAUSE:

     In vfp9, when Form.ScaleMode property is 0 (Foxels), 
     it ALWAYS calls the Move() Method with Pixel values,
     it will NOT convert Pixel values to Foxel values.

     For example,
     in the caller:
     THIS.Move(10,20) && nLeft = 10 Pixels, nTop = 20 Pixels
     in the callee:
     nLeft = 10 Foxels, nTop = 20 Foxels
     they are incorrect!

     In VFP Advanced, when Form.ScaleMode property is 0 (Foxels), 
     it will convert Pixel values to Foxel values,
     and then the object will be displayed normal.


3. RESOLUTION:

     We can write some code to fix the BUG.

     Label50641a ::
             xor eax , eax                                                   ;0x0050641a :        33c0
             mov  dword ptr [ ebp + 64 ] , 01h                               ;0x0050641c :        c7454001000000
             call Fun42c118                                                  ;0x00506423 :        e8f05cf2ff
             mov  esi , dword ptr [ Data9370c4 ]                             ;0x00506428 :        8b35c4709300
             mov eax , ebx                                                   ;0x0050642e :        8bc3
             imul eax , eax , 02Ch                                           ;0x00506430 :        6bc02c
             mov ecx , esp                                                   ;0x00506433 :        8bcc
             sub ecx , esi                                                   ;0x00506435 :        2bce
             cmp ecx , eax                                                   ;0x00506437 :        3bc8
             jle Label5bc9e4                                                 ;0x00506439 :        0f8ea5650b00
             add eax , 07h                                                   ;0x0050643f :        83c007
             and eax , 0FFFFFFF8h                                            ;0x00506442 :        83e0f8
             call Fun42c118                                                  ;0x00506445 :        e8ce5cf2ff
             mov edi , esp                                                   ;0x0050644a :        8bfc

     Label50644c ::
             test edi , edi                                                  ;0x0050644c :        85ff
             mov  dword ptr [ ebp + 84 ] , edi                               ;0x0050644e :        897d54
             je Label5bc9eb                                                  ;0x00506451 :        0f8494650b00
             test ebx , ebx                                                  ;0x00506457 :        85db
             jbe Label502a79                                                 ;0x00506459 :        0f861ac6ffff
             mov esi , ebx                                                   ;0x0050645f :        8bf3
             imul esi , esi , 0FFFFFFD4h                                     ;0x00506461 :        6bf6d4

     Label506464 ::
             mov  ecx , dword ptr [ Data9370f0 ]                             ;0x00506464 :        8b0df0709300
             push edi                                                        ;0x0050646a :        57
             lea edx ,  dword ptr [ esi + ecx + 44 ]                         ;0x0050646b :        8d540e2c
             push edx                                                        ;0x0050646f :        52
             call Fun505990                                                  ;0x00506470 :        e81bf5ffff
             add edi , 02Ch                                                  ;0x00506475 :        83c72c
             add esi , 02Ch                                                  ;0x00506478 :        83c62c
             dec ebx                                                         ;0x0050647b :        4b


     ;
     ;                 -------------------------------------------------
     ;                       VFP 9.0 FIX - FIX THE ANCHOR PROPERTY
     ;                                September 2021
     ;                 -------------------------------------------------
     ;                                     CCB
     ;
     ; In vfp9, the Anchor property can only work fine when the Form.ScaleMode property is 3 (Pixels),
     ; it can not work fine when the Form.ScaleMode property is 0 (Foxels).
     ; Now the Anchor property can work fine when the Form.ScaleMode property is 3 (Pixels) or 0 (Foxels).
     ;
     ; 2021/9/18, by ccb
     ;

     ;         je Label502a79                                                  ;0x0050647c :        0f84f7c5ffff
     ;         jmp Label506464                                                 ;0x00506482 :        ebe0

             jne Label506464                                                 ;0x00506482 :        ebe0
             cmp dword ptr vfpa_sys9070_data,00h
             je Label502a79
             cmp dword ptr vfpa_movemethod_inmovemethod,00h
             je Label502a79
             cmp dword ptr [ ebp + 92 ] , 0107h
             jne Label502a79
             cmp dword ptr [ ebp + 116 ] , 04h
             jne Label502a79
             mov  eax , dword ptr [ ebp + 84 ]
             cmp byte ptr [eax] , 49h
             jne Label502a79
             add eax , 2Ch
             cmp byte ptr [eax] , 49h
             jne Label502a79
             add eax , 2Ch
             cmp byte ptr [eax] , 49h
             jne Label502a79
             add eax , 2Ch
             cmp byte ptr [eax] , 49h
             jne Label502a79

             push edi
             mov  edi , dword ptr [ ebp + 96 ]
             call Fun4f1526
             pop edi
             cmp eax , 00h
             jne Label502a79

             sub esp , 10h
             lea eax ,  dword ptr [ esp ]
             push eax
             mov  eax , dword ptr [ ebp + 96 ]
             call Fun507352

             mov  ecx , dword ptr [ ebp + 84 ]
             fild dword ptr [ ecx + 12 ]
             mov  edx , dword ptr [eax]
             movzx edx ,word ptr [ edx + 0160h ]
             mov  dword ptr [ esp ] , edx
             fild dword ptr [ esp ]
             fdivr st(0) , st(1)
             fstp qword ptr [ ecx + 16 ]
             mov  byte ptr [ecx] , 04Eh
             mov  dword ptr [ ecx + 4 ] , 0Fh
             mov  dword ptr [ ecx + 8 ] , 02h
             fstp st(0)

             add ecx , 2Ch
             fild dword ptr [ ecx + 12 ]
             mov  edx , dword ptr [eax]
             movzx edx ,word ptr [ edx + 0162h ]
             mov  dword ptr [ esp ] , edx
             fild dword ptr [ esp ]
             fdivr st(0) , st(1)
             fstp qword ptr [ ecx + 16 ]
             mov  byte ptr [ecx] , 04Eh
             mov  dword ptr [ ecx + 4 ] , 0Fh
             mov  dword ptr [ ecx + 8 ] , 02h
             fstp st(0)

             add ecx , 2Ch
             fild dword ptr [ ecx + 12 ]
             mov  edx , dword ptr [eax]
             movzx edx ,word ptr [ edx + 0160h ]
             mov  dword ptr [ esp ] , edx
             fild dword ptr [ esp ]
             fdivr st(0) , st(1)
             fstp qword ptr [ ecx + 16 ]
             mov  byte ptr [ecx] , 04Eh
             mov  dword ptr [ ecx + 4 ] , 0Fh
             mov  dword ptr [ ecx + 8 ] , 02h
             fstp st(0)

             add ecx , 2Ch
             fild dword ptr [ ecx + 12 ]
             mov  edx , dword ptr [eax]
             movzx edx ,word ptr [ edx + 0162h ]
             mov  dword ptr [ esp ] , edx
             fild dword ptr [ esp ]
             fdivr st(0) , st(1)
             fstp qword ptr [ ecx + 16 ]
             mov  byte ptr [ecx] , 04Eh
             mov  dword ptr [ ecx + 4 ] , 0Fh
             mov  dword ptr [ ecx + 8 ] , 02h
             fstp st(0)
             add esp , 10h
             jmp Label502a79

     Now in VFP Advanced, the Anchor property can work fine when the Form.ScaleMode property is 3 (Pixels) or 0 (Foxels).
     Please refer to the picture testanchor-vfpa.jpg:


4. APPLIES TO:

     VFP 9.0.0.2412
     VFP 9.0.0.3504 (SP1)
     VFP 9.0.0.4611 (SP2)
     VFP 9.0.0.5015 (SP2)
     VFP 9.0.0.5411 (SP2)
     VFP 9.0.0.5721 (SP2)
     VFP 9.0.0.5815 (SP2)
     VFP 9.0.0.6303 (SP2)
     VFP 9.0.0.6602 (SP2)
     VFP 9.0.0.7423 (SP2)

     The bug has been fixed in VFP Advanced.


5. REFERENCE WEBSITES:

     1, baiyujia.com:
     http://www.baiyujia.com
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix196.asp

     2, foxite.com:
     https://www.foxite.com/archives/items-on-form-disappear-0000376871.htm


6. OTHER:

     For reference only, there is no guarantees.

     Any questions or suggestions, please send me an email at ccb2000@163.com.