----------------------------------------------------------------------------------------------
                      [ENHANCED] VFP 9.0 FIX - SAVE NEGATIVE COORDINATES FOR THE MAIN VISUAL FOXPRO WINDOW
                                 January 2024
                 ----------------------------------------------------------------------------------------------
                                     CCB



1. BUG:

     In VFP Advanced 32-bit, we can set the saving negative coordinates for the main Visual FoxPro window in the windows registry:
     HKEY_CURRENT_USER\Software\Microsoft\VisualFoxPro\10\Options\SaveDesktopNegativeCoordinates.

     In VFP Advanced 64-bit, we can set the saving negative coordinates for the main Visual FoxPro window in the windows registry:
     HKEY_CURRENT_USER\Software\Microsoft\VisualFoxPro64\10\Options\SaveDesktopNegativeCoordinates.


2. CAUSE:

     There are some BUGs in the following code.


3. RESOLUTION:

     We can write some code to fix the BUG.

     Fun553dc9 :: ; proc near
             push ebp                                                        ;0x00553dc9 :        55
             mov ebp , esp                                                   ;0x00553dca :        8bec
             sub esp , 06Ch                                                  ;0x00553dcc :        83ec6c
             cmp  dword ptr [ Data93bb60 ] , 00h                             ;0x00553dcf :        833d60bb930000
             mov eax ,  dword ptr [ Data937090 ]                             ;0x00553dd6 :        a190709300
             mov  dword ptr [ ebp - 4 ] , eax                                ;0x00553ddb :        8945fc
             jne Label553eaf                                                 ;0x00553dde :        0f85cb000000
             mov eax ,  dword ptr [ Data937794 ]                             ;0x00553de4 :        a194779300
             push esi                                                        ;0x00553de9 :        56
             push edi                                                        ;0x00553dea :        57
             lea esi ,  dword ptr [ ebp - 108 ]                              ;0x00553deb :        8d7594
             call Fun54fea1                                                  ;0x00553dee :        e8aec0ffff
             mov edi , offset Data91d4e4                                              ;0x00553df3 :        bfe4d49100
             call Fun42e3a0                                                  ;0x00553df8 :        e8a3a5edff
             mov edi , eax                                                   ;0x00553dfd :        8bf8
             test edi , edi                                                  ;0x00553dff :        85ff
             je Label553ead                                                  ;0x00553e01 :        0f84a6000000
             mov  eax , dword ptr [ebx]                                      ;0x00553e07 :        8b03
             mov  eax , dword ptr [ eax + 68 ]                               ;0x00553e09 :        8b4044
             shr eax , 03h                                                   ;0x00553e0c :        c1e803
             and eax , 01h                                                   ;0x00553e0f :        83e001
             push eax                                                        ;0x00553e12 :        50
             pushd 09418h                                                    ;0x00553e13 :        6818940000
             push edi                                                        ;0x00553e18 :        57
             call Fun553d4a                                                  ;0x00553e19 :        e82cffffff
             mov eax , ebx                                                   ;0x00553e1e :        8bc3
             call Fun54fea1                                                  ;0x00553e20 :        e87cc0ffff


     ;
     ;                 -----------------------------------------------------------------------------------
     ;                      VFP 9.0 FIX - SAVE NEGATIVE COORDINATES FOR THE MAIN VISUAL FOXPRO WINDOW
     ;                                 January 2022
     ;                 -----------------------------------------------------------------------------------
     ;                                     CCB
     ;
     ; Save negative coordinates for the main Visual FoxPro window.
     ; If the Top property of the main Visual FoxPro window (_VFP.Top) < 0, vfp will set the value of the registry key "Row" to 0.
     ;
     ; 2022/1/4, by ccb
     ;

     ;         push  dword ptr [ ebp - 104 ]                                   ;0x00553e25 :        ff7598

             mov eax , dword ptr [ ebp - 104 ]
             cmp dword ptr vfpa_sys9073_data,00h
             jne Label553e25
             cmp eax , 00h
             jge Label553e25
             mov eax , 00h
     Label553e25 ::
             push eax


             pushd 09419h                                                    ;0x00553e28 :        6819940000
             push edi                                                        ;0x00553e2d :        57
             call Fun553d4a                                                  ;0x00553e2e :        e817ffffff


     ;
     ;                 -----------------------------------------------------------------------------------
     ;                      VFP 9.0 FIX - SAVE NEGATIVE COORDINATES FOR THE MAIN VISUAL FOXPRO WINDOW
     ;                                 January 2022
     ;                 -----------------------------------------------------------------------------------
     ;                                     CCB
     ;
     ; Save negative coordinates for the main Visual FoxPro window.
     ; If the Left property of the main Visual FoxPro window (_VFP.Left) < 0, vfp will set the value of the registry key "Column" to 0.
     ;
     ; 2022/1/4, by ccb
     ;

     ;         push  dword ptr [ ebp - 108 ]                                   ;0x00553e33 :        ff7594

             mov eax , dword ptr [ ebp - 108 ]
             cmp dword ptr vfpa_sys9073_data,00h
             jne Label553e33
             cmp eax , 00h
             jge Label553e33
             mov eax , 00h
     Label553e33 ::
             push eax


             pushd 0941Ah                                                    ;0x00553e36 :        681a940000
             push edi                                                        ;0x00553e3b :        57
             call Fun553d4a                                                  ;0x00553e3c :        e809ffffff
             mov  eax , dword ptr [ ebp - 96 ]                               ;0x00553e41 :        8b45a0
             sub  eax , dword ptr [ ebp - 104 ]                              ;0x00553e44 :        2b4598
             push eax                                                        ;0x00553e47 :        50
             pushd 0941Bh                                                    ;0x00553e48 :        681b940000
             push edi                                                        ;0x00553e4d :        57
             call Fun553d4a                                                  ;0x00553e4e :        e8f7feffff
             mov  eax , dword ptr [ ebp - 100 ]                              ;0x00553e53 :        8b459c
             sub  eax , dword ptr [ ebp - 108 ]                              ;0x00553e56 :        2b4594
             push eax                                                        ;0x00553e59 :        50
             pushd 0941Ch                                                    ;0x00553e5a :        681c940000
             push edi                                                        ;0x00553e5f :        57
             call Fun553d4a                                                  ;0x00553e60 :        e8e5feffff
             lea eax ,  dword ptr [ ebp - 92 ]                               ;0x00553e65 :        8d45a4
             push eax                                                        ;0x00553e68 :        50
             mov edx , ebx                                                   ;0x00553e69 :        8bd3
             call Fun42ea61                                                  ;0x00553e6b :        e8f1abedff
             call Fun4308bf                                                  ;0x00553e70 :        e84acaedff
             pushd 0941Dh                                                    ;0x00553e75 :        681d940000
             push edi                                                        ;0x00553e7a :        57
             lea ecx ,  dword ptr [ ebp - 92 ]                               ;0x00553e7b :        8d4da4
             call Fun55421e                                                  ;0x00553e7e :        e89b030000
             mov eax ,  dword ptr [ Data93b96c ]                             ;0x00553e83 :        a16cb99300
             test eax , eax                                                  ;0x00553e88 :        85c0
             je Label5779f8                                                  ;0x00553e8a :        0f84683b0200

     Label553e90 ::
             lea ecx ,  dword ptr [ ebp - 92 ]                               ;0x00553e90 :        8d4da4
             push ecx                                                        ;0x00553e93 :        51
             call Fun4308bf                                                  ;0x00553e94 :        e826caedff
             pushd 0941Eh                                                    ;0x00553e99 :        681e940000
             push edi                                                        ;0x00553e9e :        57
             lea ecx ,  dword ptr [ ebp - 92 ]                               ;0x00553e9f :        8d4da4
             call Fun55421e                                                  ;0x00553ea2 :        e877030000
             push edi                                                        ;0x00553ea7 :        57
             call Fun43d889                                                  ;0x00553ea8 :        e8dc99eeff

     Label553ead ::
             pop edi                                                         ;0x00553ead :        5f
             pop esi                                                         ;0x00553eae :        5e

     Label553eaf ::
             mov  ecx , dword ptr [ ebp - 4 ]                                ;0x00553eaf :        8b4dfc
             call Fun42bf1d                                                  ;0x00553eb2 :        e86680edff
             leave                                                           ;0x00553eb7 :        c9
             ret                                                             ;0x00553eb8 :        c3


4. APPLIES TO:

     VFP 7.0.0.9262
     VFP 7.0.0.9465 (SP1)

     VFP 8.0.0.2521
     VFP 8.0.0.3117 (SP1)

     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_vfp9fix201.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix131.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix132.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix133.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix134.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix135.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix136.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix137.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix138.asp

     2, tek-tips.com:
     https://www.tek-tips.com/viewthread.cfm?qid=1802202
     https://www.tek-tips.com/viewthread.cfm?qid=1801815

     3, foxite.com:
     https://www.foxite.com/archives/command-window-disappeared-0000473575.htm

     4, microsoft.com:
     https://social.msdn.microsoft.com/Forums/en-US/1d09b809-b60f-4140-b2e4-9ff211e5c0a3/foxpro-only-displays-command-window-not-main-window

     5, west-wind.com:
     https://www.west-wind.com/wconnect/weblog/ShowEntry.blog?id=836


6. OTHER:

     For reference only, there is no guarantees.

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