--------------------------------------------------------------------------------------
                      [BUG/PRB.] VFP 9.0 FIX - FIX THE CHECKBOX CAPTIONS ARE DISPLAYED WITH SHADOW
                                  August 2021
                 --------------------------------------------------------------------------------------
                                     CCB



1. BUG:

     In vfp9 (and vfp6, vfp7, vfp8), if we set the CheckBox.BackStyle property to 0 (Transparent), sometimes the checkbox captions are displayed with shadow.

     The bug only occurs when the CheckBox.BackStyle property is 0 (Transparent), it does not occur when the CheckBox.BackStyle property is 1 (Opaque).

     The bug only occurs for some fonts, for example,
     Arial, Consolas, Courier New, Impact, Lucida Console, Microsoft Sans Serif, Segoe UI, Symbol, Tahoma, Times New Roman, Simfang, Simhei, Simkai, Msyh,
     it does not occur for other fonts, for example,
     Courier, Fixedsys, MS Sans Serif, MS Serif, Modern, Roman, Script, Small Fonts, System, Terminal, Simsun.

     The bug only occurs when we select the "Turn on ClearType" checkbox in the Windows Control Panel,
     it does not occur when we don't select the "Turn on ClearType" checkbox in the Windows Control Panel.

     The bug was reported by Ravil.

     In vfp9, sometimes the checkbox captions are displayed with shadow, please refer to the picture testcheckboxbackstyle-vfp9.jpg:


2. CAUSE:

     There are some BUGs in the following code.


3. RESOLUTION:

     We can write some code to fix the BUG.

     Label4e5ef1 ::
             push ebp                                                        ;0x004e5ef1 :        55
             lea ebp ,  dword ptr [ esp - 116 ]                              ;0x004e5ef2 :        8d6c248c
             sub esp , 0190h                                                 ;0x004e5ef6 :        81ec90010000
             mov eax ,  dword ptr [ Data937090 ]                             ;0x004e5efc :        a190709300
             push ebx                                                        ;0x004e5f01 :        53
             mov  ebx , dword ptr [ ebp + 124 ]                              ;0x004e5f02 :        8b5d7c
             push esi                                                        ;0x004e5f05 :        56
             push edi                                                        ;0x004e5f06 :        57
             mov edx , ecx                                                   ;0x004e5f07 :        8bd1
             mov  dword ptr [ ebp + 112 ] , eax                              ;0x004e5f09 :        894570
             pushd 057h                                                      ;0x004e5f0c :        6a57
             xor eax , eax                                                   ;0x004e5f0e :        33c0
             pop ecx                                                         ;0x004e5f10 :        59
             lea edi ,  dword ptr [ ebp + 0FFFFFF14h ]                       ;0x004e5f11 :        8dbd14ffffff
             rep stosd                                                       ;0x004e5f17 :        f3ab
             mov  eax , dword ptr [ ebx + 32 ]                               ;0x004e5f19 :        8b4320
             mov  dword ptr [ ebp + 0FFFFFF14h ] , eax                       ;0x004e5f1c :        898514ffffff
             lea esi ,  dword ptr [ ebx + 36 ]                               ;0x004e5f22 :        8d7324
             lea edi ,  dword ptr [ ebp + 0FFFFFF18h ]                       ;0x004e5f25 :        8dbd18ffffff
             movsd                                                           ;0x004e5f2b :        a5
             movsd                                                           ;0x004e5f2c :        a5
             movsd                                                           ;0x004e5f2d :        a5
             lea eax ,  dword ptr [ ebx + 084h ]                             ;0x004e5f2e :        8d8384000000
             movzx ecx ,word ptr [eax]                                       ;0x004e5f34 :        0fb708
             movsd                                                           ;0x004e5f37 :        a5
             push edx                                                        ;0x004e5f38 :        52
             mov  dword ptr [ ebp + 0FFFFFF10h ] , edx                       ;0x004e5f39 :        899510ffffff
             mov  dword ptr [ ebp + 44 ] , ecx                               ;0x004e5f3f :        894d2c
             mov  dword ptr [ ebp + 100 ] , edx                              ;0x004e5f42 :        895564
             call Fun4e379e                                                  ;0x004e5f45 :        e854d8ffff
             test eax , eax                                                  ;0x004e5f4a :        85c0
             jne Label5e9b63                                                 ;0x004e5f4c :        0f85113c1000

     Label4e5f52 ::
             mov  ecx , dword ptr [ ebp + 0FFFFFF10h ]                       ;0x004e5f52 :        8b8d10ffffff
             pushd 04h                                                       ;0x004e5f58 :        6a04
             pop edi                                                         ;0x004e5f5a :        5f
             lea eax ,  dword ptr [ ebp + 124 ]                              ;0x004e5f5b :        8d457c
             push eax                                                        ;0x004e5f5e :        50
             lea eax ,  dword ptr [ ebp + 0FFFFFF0Ch ]                       ;0x004e5f5f :        8d850cffffff
             push eax                                                        ;0x004e5f65 :        50
             pushd 010h                                                      ;0x004e5f66 :        6a10
             pop edx                                                         ;0x004e5f68 :        5a
             mov  dword ptr [ ebp + 124 ] , edi                              ;0x004e5f69 :        897d7c
             call Fun41993a                                                  ;0x004e5f6c :        e8c939f3ff
             cmp eax , edi                                                   ;0x004e5f71 :        3bc7
             jne Label5e9b6f                                                 ;0x004e5f73 :        0f85f63b1000

     Label4e5f79 ::
             push  dword ptr [ ebp + 0FFFFFF10h ]                            ;0x004e5f79 :        ffb510ffffff
             mov esi , ebx                                                   ;0x004e5f7f :        8bf3
             call Fun4e5e4a                                                  ;0x004e5f81 :        e8c4feffff
             mov  ecx , dword ptr [ ebp + 0FFFFFF10h ]                       ;0x004e5f86 :        8b8d10ffffff
             mov  dword ptr [ ebp + 48 ] , eax                               ;0x004e5f8c :        894530
             mov  eax , dword ptr [ebx]                                      ;0x004e5f8f :        8b03
             or  byte ptr [ ebp + 49 ] , 080h                                ;0x004e5f91 :        804d3180
             shr eax , 03h                                                   ;0x004e5f95 :        c1e803
             xor  eax , dword ptr [ ebp + 64 ]                               ;0x004e5f98 :        334540
             mov esi , 0100h                                                 ;0x004e5f9b :        be00010000
             and eax , edi                                                   ;0x004e5fa0 :        23c7
             xor  dword ptr [ ebp + 64 ] , eax                               ;0x004e5fa2 :        314540
             lea eax ,  dword ptr [ ebp + 0FFFFFEF4h ]                       ;0x004e5fa5 :        8d85f4feffff
             push eax                                                        ;0x004e5fab :        50
             lea eax ,  dword ptr [ ebp + 0FFFFFF28h ]                       ;0x004e5fac :        8d8528ffffff
             push eax                                                        ;0x004e5fb2 :        50
             pushd 03Ah                                                      ;0x004e5fb3 :        6a3a
             pop edx                                                         ;0x004e5fb5 :        5a
             mov  byte ptr [ ebp + 40 ] , 01h                                ;0x004e5fb6 :        c6452801
             mov  dword ptr [ ebp + 0FFFFFEF4h ] , esi                       ;0x004e5fba :        89b5f4feffff
             call Fun41993a                                                  ;0x004e5fc0 :        e87539f3ff
             test eax , eax                                                  ;0x004e5fc5 :        85c0
             je Label4e6ca3                                                  ;0x004e5fc7 :        0f84d60c0000
             mov  eax , dword ptr [ ebp + 0FFFFFEF4h ]                       ;0x004e5fcd :        8b85f4feffff
             cmp eax , esi                                                   ;0x004e5fd3 :        3bc6
             jnb Label5e9b7b                                                 ;0x004e5fd5 :        0f83a03b1000
             mov  byte ptr [ ebp + eax + 0FFFFFF28h ] , 00h                  ;0x004e5fdb :        c6840528ffffff00

     Label4e5fe3 ::
             mov  ecx , dword ptr [ ebp + 0FFFFFF10h ]                       ;0x004e5fe3 :        8b8d10ffffff
             lea eax ,  dword ptr [ ebp + 0FFFFFF08h ]                       ;0x004e5fe9 :        8d8508ffffff
             push eax                                                        ;0x004e5fef :        50
             lea eax ,  dword ptr [ ebp + 124 ]                              ;0x004e5ff0 :        8d457c
             push eax                                                        ;0x004e5ff3 :        50
             mov edx , 0172h                                                 ;0x004e5ff4 :        ba72010000
             mov  dword ptr [ ebp + 0FFFFFF08h ] , edi                       ;0x004e5ff9 :        89bd08ffffff
             call Fun41993a                                                  ;0x004e5fff :        e83639f3ff
             cmp eax , edi                                                   ;0x004e6004 :        3bc7
             jne Label5e9b84                                                 ;0x004e6006 :        0f85783b1000

     Label4e600c ::
             xor eax , eax                                                   ;0x004e600c :        33c0
             cmp  dword ptr [ ebp + 124 ] , 01h                              ;0x004e600e :        837d7c01
             sete al                                                         ;0x004e6012 :        0f94c0
             test  byte ptr [ ebp + 50 ] , 01h                               ;0x004e6015 :        f6453201
             lea eax ,  dword ptr [ 8 * eax + 01h ]                          ;0x004e6019 :        8d04c501000000
             mov  dword ptr [ ebp + 124 ] , eax                              ;0x004e6020 :        89457c
             jne Label4e602e                                                 ;0x004e6023 :        7509
             cmp eax , 09h                                                   ;0x004e6025 :        83f809
             je Label4e8e66                                                  ;0x004e6028 :        0f84382e0000

     Label4e602e ::
             mov  ax , word ptr [ ebp + 0FFFFFF0Ch ]                         ;0x004e602e :        668b850cffffff
             mov  word ptr [ ebp + 70 ] , ax                                 ;0x004e6035 :        66894546

     Label4e6039 ::
             push  dword ptr [ ebp + 124 ]                                   ;0x004e6039 :        ff757c
             mov  edi , dword ptr [ ebp + 0FFFFFF10h ]                       ;0x004e603c :        8bbd10ffffff
             lea esi ,  dword ptr [ ebx + 08Ch ]                             ;0x004e6042 :        8db38c000000
             lea eax ,  dword ptr [ ebp + 0FFFFFF14h ]                       ;0x004e6048 :        8d8514ffffff
             call Fun4e5d8c                                                  ;0x004e604e :        e839fdffff
             cmp  dword ptr [ ebp + 124 ] , 09h                              ;0x004e6053 :        837d7c09
             je Label4e8f87                                                  ;0x004e6057 :        0f842a2f0000
             mov  ecx , dword ptr [ ebp + 0FFFFFF10h ]                       ;0x004e605d :        8b8d10ffffff
             pushd 00h                                                       ;0x004e6063 :        6a00
             mov edx , 0231h                                                 ;0x004e6065 :        ba31020000
             call Fun436ddb                                                  ;0x004e606a :        e86c0df5ff
             test  byte ptr [ ebp + 48 ] , 040h                              ;0x004e606f :        f6453040
             mov  word ptr [ ebp + 68 ] , ax                                 ;0x004e6073 :        66894544
             je Label4e60b6                                                  ;0x004e6077 :        743d
             lea esi ,  dword ptr [ ebp + 83 ]                               ;0x004e6079 :        8d7553
             lea edi ,  dword ptr [ ebp + 0FFFFFF04h ]                       ;0x004e607c :        8dbd04ffffff
             movsw                                                           ;0x004e6082 :        66a5
             movsb                                                           ;0x004e6084 :        a4
             lea esi ,  dword ptr [ ebp + 83 ]                               ;0x004e6085 :        8d7553
             lea edi ,  dword ptr [ ebp + 0FFFFFF07h ]                       ;0x004e6088 :        8dbd07ffffff
             lea eax ,  dword ptr [ ebp + 0FFFFFF04h ]                       ;0x004e608e :        8d8504ffffff
             movsw                                                           ;0x004e6094 :        66a5
             push eax                                                        ;0x004e6096 :        50
             push  dword ptr [ ebp + 0FFFFFF14h ]                            ;0x004e6097 :        ffb514ffffff
             lea eax ,  dword ptr [ ebp + 0FFFFFF18h ]                       ;0x004e609d :        8d8518ffffff
             movsb                                                           ;0x004e60a3 :        a4
             call Fun425f5f                                                  ;0x004e60a4 :        e8b6fef3ff
             and  dword ptr [ ebp + 64 ] , 0FFFFFFFBh                        ;0x004e60a9 :        836540fb
             test  byte ptr [ebx] , 02h                                      ;0x004e60ad :        f60302
             jne Label5e9c1d                                                 ;0x004e60b0 :        0f85673b1000

     Label4e60b6 ::
             mov  ecx , dword ptr [ ebp + 0FFFFFF10h ]                       ;0x004e60b6 :        8b8d10ffffff
             pushd 04h                                                       ;0x004e60bc :        6a04
             pop esi                                                         ;0x004e60be :        5e
             lea eax ,  dword ptr [ ebp + 0FFFFFF08h ]                       ;0x004e60bf :        8d8508ffffff
             push eax                                                        ;0x004e60c5 :        50
             lea eax ,  dword ptr [ ebp + 124 ]                              ;0x004e60c6 :        8d457c
             push eax                                                        ;0x004e60c9 :        50
             mov edx , 022Ch                                                 ;0x004e60ca :        ba2c020000
             mov  dword ptr [ ebp + 0FFFFFF08h ] , esi                       ;0x004e60cf :        89b508ffffff
             call Fun41993a                                                  ;0x004e60d5 :        e86038f3ff
             cmp eax , esi                                                   ;0x004e60da :        3bc6
             jne Label5e9c30                                                 ;0x004e60dc :        0f854e3b1000

     Label4e60e2 ::
             cmp  dword ptr [ ebp + 124 ] , 00h                              ;0x004e60e2 :        837d7c00
             jne Label5e9c39                                                 ;0x004e60e6 :        0f854d3b1000

     Label4e60ec ::


     ;
     ;                 ---------------------------------------------------------------------------
     ;                      VFP 9.0 FIX - FIX THE CHECKBOX CAPTIONS ARE DISPLAYED WITH SHADOW
     ;                                  August 2021
     ;                 ---------------------------------------------------------------------------
     ;                                     CCB
     ;
     ; If we set the CheckBox.BackStyle property to 0 (Transparent), sometimes the checkbox captions are displayed with shadow.
     ;
     ; 2021/8/14, by ccb
     ;

             mov dword ptr vfpa_checkboxcaption_ischeckboxcaption,00h

             cmp dword ptr vfpa_sys9066_data,00h
             je Label4e60ee

             mov  eax , dword ptr [ ebp + 0FFFFFF10h ]
             mov  ecx , dword ptr [ Data9388dc ]
             lea eax ,  dword ptr [ eax + 4 * eax ]
             shl eax , 05h
             cmp  word ptr [ eax + ecx + 16 ] , 0334h
             jne Label4e60ee

             push edi
             mov edi , dword ptr [ ebp + 0FFFFFF10h ]
             call vfpa_getformvisible
             pop edi
             cmp eax , 00h
             jle Label4e60ee

             sub esp , 10h
             mov dword ptr [ esp + 04h ] , 04h
             mov dword ptr [ esp + 00h ] , 00h
             lea edx ,  dword ptr [ esp + 04h ]
             lea eax ,  dword ptr [ esp + 00h ]
             pushd 0FFFFFFFFh                                                ;0x0046e08f :        6aff
             push edx                                                        ;0x0046e095 :        52
             push eax                                                        ;0x0046e09a :        50
             push 00h                                                        ;0x0046e09b :        55
             pushd 0FFFFFFFFh                                                ;0x0046e09c :        6aff
             pushd 0191h                                                      ;0x0046e09e :        68df000000
             mov  eax , dword ptr [ ebp + 0FFFFFF10h ]
             push eax                                                        ;0x0046e0a3 :        56
             call Fun433a39                                                  ;0x0046e0a4 :        e89059fcff
             add esp , 01Ch                                                  ;0x0046e0a9 :        83c41c
             mov ecx , dword ptr [ esp + 00h ]
             add esp , 10h
             test eax , eax
             je Label4e60ee
             test ecx , ecx
             je Label4e60ee

             sub esp , 10h
             mov dword ptr [ esp + 04h ] , 04h
             mov dword ptr [ esp + 00h ] , 01h
             lea edx ,  dword ptr [ esp + 04h ]
             lea eax ,  dword ptr [ esp + 00h ]
             pushd 0FFFFFFFFh                                                ;0x0046e08f :        6aff
             push edx                                                        ;0x0046e095 :        52
             push eax                                                        ;0x0046e09a :        50
             push 00h                                                        ;0x0046e09b :        55
             pushd 0FFFFFFFFh                                                ;0x0046e09c :        6aff
             pushd 021h                                                      ;0x0046e09e :        68df000000
             mov  eax , dword ptr [ ebp + 0FFFFFF10h ]
             push eax                                                        ;0x0046e0a3 :        56
             call Fun433a39                                                  ;0x0046e0a4 :        e89059fcff
             add esp , 01Ch                                                  ;0x0046e0a9 :        83c41c
             mov ecx , dword ptr [ esp + 00h ]
             add esp , 10h
             test eax , eax
             je Label4e60ee
             test ecx , ecx
             jne Label4e60ee

             mov dword ptr vfpa_checkboxcaption_ischeckboxcaption,01h


     Label4e60ee ::
             lea eax ,  dword ptr [ ebp + 0FFFFFF14h ]                       ;0x004e60ec :        8d8514ffffff
             push eax                                                        ;0x004e60f2 :        50
             call Fun46e887                                                  ;0x004e60f3 :        e88f87f8ff


     ;
     ;                 ---------------------------------------------------------------------------
     ;                      VFP 9.0 FIX - FIX THE CHECKBOX CAPTIONS ARE DISPLAYED WITH SHADOW
     ;                                  August 2021
     ;                 ---------------------------------------------------------------------------
     ;                                     CCB
     ;
     ; If we set the CheckBox.BackStyle property to 0 (Transparent), sometimes the checkbox captions are displayed with shadow.
     ;
     ; 2021/8/14, by ccb
     ;

     Label4e60f7 ::
             mov dword ptr vfpa_checkboxcaption_ischeckboxcaption,00h


     Label4e60f8 ::
             test  byte ptr [ ebp + 48 ] , 04h                               ;0x004e60f8 :        f6453004
             jne Label5e9cf7                                                 ;0x004e60fc :        0f85f53b1000
             and  dword ptr [ebx] , 0FFFFFFFDh                               ;0x004e6102 :        8323fd

     Label4e6105 ::
             mov  ecx , dword ptr [ ebp + 112 ]                              ;0x004e6105 :        8b4d70
             pop edi                                                         ;0x004e6108 :        5f
             pop esi                                                         ;0x004e6109 :        5e
             pop ebx                                                         ;0x004e610a :        5b
             call Fun42bf1d                                                  ;0x004e610b :        e80d5ef4ff
             add ebp , 074h                                                  ;0x004e6110 :        83c574
             leave                                                           ;0x004e6113 :        c9
             ret 04h                                                         ;0x004e6114 :        c20400

     Now in VFP Advanced, the checkbox captions are displayed without shadow, it is normal.
     Please refer to the picture testcheckboxbackstyle-vfpa.jpg:


4. APPLIES TO:

     VFP 6.0.8167.0
     VFP 6.0.8961.0 (SP5)

     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_vfp9fix188.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix184.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix185.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix190.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix191.asp

     2, microsoft.com:
     https://social.technet.microsoft.com/Forums/windows/en-US/3d60cb6f-4845-4f52-84cb-b57a67fa6029/captions-of-checkbox-labels-and-optionbuttons-gets-darker
     https://devblogs.microsoft.com/oldnewthing/20060614-00/?p=30873

     3, foxite.com:
     https://www.foxite.com/archives/form-labels-get-increasingly-smudged-0000227347.htm
     https://www.foxite.com/archives/bug-with-transparents-labels-0000316393.htm
     https://www.foxite.com/archives/strange-repaintrefresh-with-win10-0000477579.htm

     4, wikis.com:
     https://fox.wikis.com/wc.dll?Wiki~TransparentLabelsBoldedDuringScreenUpdates


6. OTHER:

     For reference only, there is no guarantees.

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