-----------------------------------------------------------------------
                      [BUG/PRB.] VFP 9.0 FIX - FIX THE REPORT OBJECTS ARE TOO LARGE
                                 January 2024
                 -----------------------------------------------------------------------
                                     CCB



1. BUG:

     In vfp9, if we set ReportBehavior 90, the report objects are too large when set scaling to greater than 100% on Windows 10.

     The bug occurs on Windows 8.1 and Windows 10, it also occurs when we uncheck the checkbox "Use Windows XP Style DPI Scaling"
     on Windows Vista, Windows 7 and Windows 8, it does not occur on early Windows XP.

     The bug only occurs when set ReportBehavior 90, it does not occur when set ReportBehavior 80.

     The bug was reported by John Ryan.

     In vfp9, when we set scaling to 100%, the report objects are normal, please refer to the picture testscaling100-vfp9.jpg:

     In vfp9, when we set scaling to 125%, the report objects are too large, please refer to the picture testscaling125-vfp9.jpg:


2. CAUSE:

     There are some BUGs in the following code.


3. RESOLUTION:

     We can write some code to fix the BUG.

     Fun495aaa :: ; proc near
             push ebp                                                        ;0x00495aaa :        55
             mov ebp , esp                                                   ;0x00495aab :        8bec
             sub esp , 050h                                                  ;0x00495aad :        83ec50
             push esi                                                        ;0x00495ab0 :        56
             push edi                                                        ;0x00495ab1 :        57
             mov esi , eax                                                   ;0x00495ab2 :        8bf0
             pushd 08h                                                       ;0x00495ab4 :        6a08
             lea eax ,  dword ptr [ ebp - 28 ]                               ;0x00495ab6 :        8d45e4
             call Fun4a2b78                                                  ;0x00495ab9 :        e8bad00000
             lea eax ,  dword ptr [ ebp - 76 ]                               ;0x00495abe :        8d45b4
             mov  dword ptr [ ebp - 32 ] , eax                               ;0x00495ac1 :        8945e0
             mov  eax , dword ptr [ ebx + 03BCh ]                            ;0x00495ac4 :        8b83bc030000
             mov  dword ptr [ ebp - 4 ] , eax                                ;0x00495aca :        8945fc
             mov  eax , dword ptr [ ebx + 03C0h ]                            ;0x00495acd :        8b83c0030000
             mov  dword ptr [ ebp - 8 ] , eax                                ;0x00495ad3 :        8945f8
             lea eax ,  dword ptr [ ebp + 8 ]                                ;0x00495ad6 :        8d4508
             push eax                                                        ;0x00495ad9 :        50
             lea edx ,  dword ptr [ ebp - 32 ]                               ;0x00495ada :        8d55e0
             call Fun49e575                                                  ;0x00495add :        e8938a0000
             xor edi , edi                                                   ;0x00495ae2 :        33ff
             push edi                                                        ;0x00495ae4 :        57
             push  dword ptr [ ebp - 32 ]                                    ;0x00495ae5 :        ff75e0
             xor ecx , ecx                                                   ;0x00495ae8 :        33c9
             lea eax ,  dword ptr [ ebp - 28 ]                               ;0x00495aea :        8d45e4
             call Fun4a28ba                                                  ;0x00495aed :        e8c8cd0000
             mov  eax , dword ptr [esi]                                      ;0x00495af2 :        8b06
             add  eax , dword ptr [ ebp - 4 ]                                ;0x00495af4 :        0345fc


     ;
     ;                 ------------------------------------------------------------
     ;                      VFP 9.0 FIX - FIX THE REPORT OBJECTS ARE TOO LARGE
     ;                                  August 2018
     ;                 ------------------------------------------------------------
     ;                                     CCB
     ;
     ; In vfp9, if we set ReportBehavior 90, fix the report objects are too large when set scaling to greater than 100% on Windows 10.
     ;
     ; 2018/8/22, by ccb
     ;

             cmp dword ptr vfpa_report_isreportform,00h
             je Label495af7
             cmp  byte ptr [ Data93c280 ] , 05Ah
             jb Label495af7
             cmp dword ptr vfpa_sys9009_data,00h
             je Label495af7
             mov ecx,dword ptr vfpa_getdpiforwindow_dpi
             cmp ecx,dword ptr vfpa_getdpiforsystem_dpi
             jbe Label495af7
             push dword ptr vfpa_getdpiforwindow_dpi
             push dword ptr vfpa_getdpiforsystem_dpi
             push eax
             call MulDiv


     Label495af7 ::
             lea edx ,  dword ptr [ ebp - 32 ]                               ;0x00495af7 :        8d55e0
             mov  dword ptr [ ebp + 8 ] , eax                                ;0x00495afa :        894508
             lea eax ,  dword ptr [ ebp + 8 ]                                ;0x00495afd :        8d4508
             push eax                                                        ;0x00495b00 :        50
             call Fun49e575                                                  ;0x00495b01 :        e86f8a0000
             push edi                                                        ;0x00495b06 :        57
             push  dword ptr [ ebp - 32 ]                                    ;0x00495b07 :        ff75e0
             xor ecx , ecx                                                   ;0x00495b0a :        33c9
             inc ecx                                                         ;0x00495b0c :        41
             lea eax ,  dword ptr [ ebp - 28 ]                               ;0x00495b0d :        8d45e4
             call Fun4a28ba                                                  ;0x00495b10 :        e8a5cd0000
             mov  eax , dword ptr [ esi + 4 ]                                ;0x00495b15 :        8b4604
             add  eax , dword ptr [ ebp - 8 ]                                ;0x00495b18 :        0345f8


     ;
     ;                 ------------------------------------------------------------
     ;                      VFP 9.0 FIX - FIX THE REPORT OBJECTS ARE TOO LARGE
     ;                                  August 2018
     ;                 ------------------------------------------------------------
     ;                                     CCB
     ;
     ; In vfp9, if we set ReportBehavior 90, fix the report objects are too large when set scaling to greater than 100% on Windows 10.
     ;
     ; 2018/8/22, by ccb
     ;

             cmp dword ptr vfpa_report_isreportform,00h
             je Label495b1b
             cmp  byte ptr [ Data93c280 ] , 05Ah
             jb Label495b1b
             cmp dword ptr vfpa_sys9009_data,00h
             je Label495b1b
             mov ecx,dword ptr vfpa_getdpiforwindow_dpi
             cmp ecx,dword ptr vfpa_getdpiforsystem_dpi
             jbe Label495b1b
             push dword ptr vfpa_getdpiforwindow_dpi
             push dword ptr vfpa_getdpiforsystem_dpi
             push eax
             call MulDiv


     Label495b1b ::
             lea edx ,  dword ptr [ ebp - 32 ]                               ;0x00495b1b :        8d55e0
             mov  dword ptr [ ebp + 8 ] , eax                                ;0x00495b1e :        894508
             lea eax ,  dword ptr [ ebp + 8 ]                                ;0x00495b21 :        8d4508
             push eax                                                        ;0x00495b24 :        50
             call Fun49e575                                                  ;0x00495b25 :        e84b8a0000
             push edi                                                        ;0x00495b2a :        57
             push  dword ptr [ ebp - 32 ]                                    ;0x00495b2b :        ff75e0
             lea eax ,  dword ptr [ ebp - 28 ]                               ;0x00495b2e :        8d45e4
             pushd 02h                                                       ;0x00495b31 :        6a02
             pop ecx                                                         ;0x00495b33 :        59
             call Fun4a28ba                                                  ;0x00495b34 :        e881cd0000
             mov  eax , dword ptr [ esi + 8 ]                                ;0x00495b39 :        8b4608
             sub  eax , dword ptr [esi]                                      ;0x00495b3c :        2b06


     ;
     ;                 ------------------------------------------------------------
     ;                      VFP 9.0 FIX - FIX THE REPORT OBJECTS ARE TOO LARGE
     ;                                  August 2018
     ;                 ------------------------------------------------------------
     ;                                     CCB
     ;
     ; In vfp9, if we set ReportBehavior 90, fix the report objects are too large when set scaling to greater than 100% on Windows 10.
     ;
     ; 2018/8/22, by ccb
     ;

             cmp dword ptr vfpa_report_isreportform,00h
             je Label495b3e
             cmp  byte ptr [ Data93c280 ] , 05Ah
             jb Label495b3e
             cmp dword ptr vfpa_sys9009_data,00h
             je Label495b3e
             mov ecx,dword ptr vfpa_getdpiforwindow_dpi
             cmp ecx,dword ptr vfpa_getdpiforsystem_dpi
             jbe Label495b3e
             push dword ptr vfpa_getdpiforwindow_dpi
             push dword ptr vfpa_getdpiforsystem_dpi
             push eax
             call MulDiv


     Label495b3e ::
             lea edx ,  dword ptr [ ebp - 32 ]                               ;0x00495b3e :        8d55e0
             mov  dword ptr [ ebp + 8 ] , eax                                ;0x00495b41 :        894508
             lea eax ,  dword ptr [ ebp + 8 ]                                ;0x00495b44 :        8d4508
             push eax                                                        ;0x00495b47 :        50
             call Fun49e575                                                  ;0x00495b48 :        e8288a0000
             push edi                                                        ;0x00495b4d :        57
             push  dword ptr [ ebp - 32 ]                                    ;0x00495b4e :        ff75e0
             lea eax ,  dword ptr [ ebp - 28 ]                               ;0x00495b51 :        8d45e4
             pushd 03h                                                       ;0x00495b54 :        6a03
             pop ecx                                                         ;0x00495b56 :        59
             call Fun4a28ba                                                  ;0x00495b57 :        e85ecd0000
             mov  eax , dword ptr [ esi + 12 ]                               ;0x00495b5c :        8b460c
             sub  eax , dword ptr [ esi + 4 ]                                ;0x00495b5f :        2b4604


     ;
     ;                 ------------------------------------------------------------
     ;                      VFP 9.0 FIX - FIX THE REPORT OBJECTS ARE TOO LARGE
     ;                                  August 2018
     ;                 ------------------------------------------------------------
     ;                                     CCB
     ;
     ; In vfp9, if we set ReportBehavior 90, fix the report objects are too large when set scaling to greater than 100% on Windows 10.
     ;
     ; 2018/8/22, by ccb
     ;

             cmp dword ptr vfpa_report_isreportform,00h
             je Label495b62
             cmp  byte ptr [ Data93c280 ] , 05Ah
             jb Label495b62
             cmp dword ptr vfpa_sys9009_data,00h
             je Label495b62
             mov ecx,dword ptr vfpa_getdpiforwindow_dpi
             cmp ecx,dword ptr vfpa_getdpiforsystem_dpi
             jbe Label495b62
             push dword ptr vfpa_getdpiforwindow_dpi
             push dword ptr vfpa_getdpiforsystem_dpi
             push eax
             call MulDiv


     Label495b62 ::
             lea edx ,  dword ptr [ ebp - 32 ]                               ;0x00495b62 :        8d55e0
             mov  dword ptr [ ebp + 8 ] , eax                                ;0x00495b65 :        894508
             lea eax ,  dword ptr [ ebp + 8 ]                                ;0x00495b68 :        8d4508
             push eax                                                        ;0x00495b6b :        50
             call Fun49e575                                                  ;0x00495b6c :        e8048a0000
             push edi                                                        ;0x00495b71 :        57
             push  dword ptr [ ebp - 32 ]                                    ;0x00495b72 :        ff75e0
             lea eax ,  dword ptr [ ebp - 28 ]                               ;0x00495b75 :        8d45e4
             pushd 04h                                                       ;0x00495b78 :        6a04
             pop ecx                                                         ;0x00495b7a :        59
             call Fun4a28ba                                                  ;0x00495b7b :        e83acd0000
             mov  eax , dword ptr [ ebp + 16 ]                               ;0x00495b80 :        8b4510
             mov  dword ptr [ ebp + 8 ] , eax                                ;0x00495b83 :        894508
             lea eax ,  dword ptr [ ebp + 8 ]                                ;0x00495b86 :        8d4508
             push eax                                                        ;0x00495b89 :        50
             lea edx ,  dword ptr [ ebp - 32 ]                               ;0x00495b8a :        8d55e0
             call Fun49e575                                                  ;0x00495b8d :        e8e3890000
             push edi                                                        ;0x00495b92 :        57
             push  dword ptr [ ebp - 32 ]                                    ;0x00495b93 :        ff75e0
             lea eax ,  dword ptr [ ebp - 28 ]                               ;0x00495b96 :        8d45e4
             pushd 05h                                                       ;0x00495b99 :        6a05
             pop ecx                                                         ;0x00495b9b :        59
             call Fun4a28ba                                                  ;0x00495b9c :        e819cd0000
             push edi                                                        ;0x00495ba1 :        57
             push  dword ptr [ ebp + 12 ]                                    ;0x00495ba2 :        ff750c
             lea eax ,  dword ptr [ ebp - 28 ]                               ;0x00495ba5 :        8d45e4
             pushd 06h                                                       ;0x00495ba8 :        6a06
             pop ecx                                                         ;0x00495baa :        59
             call Fun4a28ba                                                  ;0x00495bab :        e80acd0000
             lea eax ,  dword ptr [ ebp + 20 ]                               ;0x00495bb0 :        8d4514
             push eax                                                        ;0x00495bb3 :        50
             lea edx ,  dword ptr [ ebp - 32 ]                               ;0x00495bb4 :        8d55e0
             call Fun49e575                                                  ;0x00495bb7 :        e8b9890000
             push edi                                                        ;0x00495bbc :        57
             push  dword ptr [ ebp - 32 ]                                    ;0x00495bbd :        ff75e0
             lea eax ,  dword ptr [ ebp - 28 ]                               ;0x00495bc0 :        8d45e4
             pushd 07h                                                       ;0x00495bc3 :        6a07
             pop ecx                                                         ;0x00495bc5 :        59
             call Fun4a28ba                                                  ;0x00495bc6 :        e8efcc0000
             push ecx                                                        ;0x00495bcb :        51
             mov eax , esp                                                   ;0x00495bcc :        8bc4
             mov  dword ptr [eax] , edi                                      ;0x00495bce :        8938
             lea eax ,  dword ptr [ ebp - 28 ]                               ;0x00495bd0 :        8d45e4
             push eax                                                        ;0x00495bd3 :        50
             pushd 0242h                                                     ;0x00495bd4 :        6842020000
             push ebx                                                        ;0x00495bd9 :        53
             call Fun495a89                                                  ;0x00495bda :        e8aafeffff
             lea esi ,  dword ptr [ ebp - 28 ]                               ;0x00495bdf :        8d75e4
             call Fun4a29bc                                                  ;0x00495be2 :        e8d5cd0000
             pop edi                                                         ;0x00495be7 :        5f
             pop esi                                                         ;0x00495be8 :        5e
             leave                                                           ;0x00495be9 :        c9
             ret 010h                                                        ;0x00495bea :        c21000

     Now in VFP Advanced, when we set scaling to 125%, the report objects are normal, please refer to the picture testscaling125-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.

     IMPORTANT NOTE FOR WINDOWS 10:
     The GetDpiForSystem and GetDpiForWindow Windows APIs are only on Windows 10 version 1607 (August 2, 2016) or later,
     the bug has been fixed on Windows 10 version 1607 (August 2, 2016) or later,
     so recommend to upgrade to Windows 10 version 1607 (August 2, 2016) or later.
     If there is no the registry key "HKEY_CURRENT_USER\Control Panel\Desktop\Win8DpiScaling" in the Windows registry,
     the GetDpiForWindow Windows API always returns 96,
     so we MUST create the following registry key:
     [HKEY_CURRENT_USER\Control Panel\Desktop]
     "Win8DpiScaling"=dword:00000000
     and then the GetDpiForWindow Windows API can return correct value.


5. REFERENCE WEBSITES:

     1, baiyujia.com:
     http://www.baiyujia.com
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix56.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix57.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix58.asp

     2, foxite.com:
     https://www.foxite.com/archives/vfp-9-behaves-badly-under-windows-81-0000401619.htm
     https://www.foxite.com/archives/foxypreviewer-problem-on-150-display-0000450022.htm
     https://www.foxite.com/archives/reportlistener-outputpage-crop-0000427655.htm

     3, microsoft.com:
     https://social.msdn.microsoft.com/Forums/en-US/b6b91adb-9720-4e75-82a7-d5ba3ad40c43/vfp9-reports-on-windows-8-with-large-screen-text-issue


6. OTHER:

     For reference only, there is no guarantees.

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