---------------------------------------------------------------------------------
                      [BUG/PRB.] VFP 9.0 FIX - INITIALIZE THE RETURN VALUE OF THE VALID EVENT
                                December 2024
                 ---------------------------------------------------------------------------------
                                     CCB



1. BUG:

     If we enable initializing the return value of the Valid event in Visual FoxPro Advanced,
     VFP will initialize the return value of the Valid event to true (.T.) and 0 (Zero).
     It is the startup default for Visual FoxPro Advanced.

     If we disable initializing the return value of the Valid event in Visual FoxPro Advanced,
     sometimes the Valid event returns a BIG random number, VFP will enter an infinite loop.
     It is the same as Visual FoxPro 9.0 and earlier versions.

     The bug occurs for the ComboBox control, it does not occur for other controls.

     The bug occurs in the Valid event, the Click event and the KeyPress event.


2. CAUSE:

     There are some BUGs in the following code.


3. RESOLUTION:

     We can write some code to fix the BUG.

     Label5ef55d ::


     ;
     ;                 ----------------------------------------------------------------------
     ;                      VFP 9.0 FIX - INITIALIZE THE RETURN VALUE OF THE VALID EVENT
     ;                                December 2024
     ;                 ----------------------------------------------------------------------
     ;                                     CCB
     ;
     ; In vfp9, sometimes the Valid event returns a BIG random number, VFP will enter an infinite loop.
     ; In VFP Advanced, VFP will initialize the return value of the Valid event to true (.T.) and 0 (Zero) to fix the BUG.
     ;
     ; 2024/12/16, by ccb
     ;

             cmp dword ptr vfpa_sys9178_data,00h
             je Label5ef55e
             mov  ecx , dword ptr [ Data9370f0 ]
             mov  byte ptr [ ecx + 44 ] , 04Ch
             mov  dword ptr [ ecx + 52 ] , 01h
             mov  dword ptr [ ecx + 56 ] , 00h


     Label5ef55e ::
             pushd 00h                                                       ;0x005ef55d :        6a00
             pushd 018Dh                                                     ;0x005ef55f :        688d010000
             push ebx                                                        ;0x005ef564 :        53
             call Fun450463                                                  ;0x005ef565 :        e8f90ee6ff
             mov  esi , dword ptr [ Data9370f0 ]                             ;0x005ef56a :        8b35f0709300
             mov ebp , eax                                                   ;0x005ef570 :        8be8
             add esi , 02Ch                                                  ;0x005ef572 :        83c62c
             cmp ebp , 01h                                                   ;0x005ef575 :        83fd01
             mov ecx , 0Bh                                                   ;0x005ef578 :        b90b000000
             lea edi ,  dword ptr [ esp + 40 ]                               ;0x005ef57d :        8d7c2428
             mov  dword ptr [ esp + 96 ] , ebp                               ;0x005ef581 :        896c2460
             rep movsd                                                       ;0x005ef585 :        f3a5
             jne Label5ef596                                                 ;0x005ef587 :        750d
             mov edi , ebx                                                   ;0x005ef589 :        8bfb
             call Fun485794                                                  ;0x005ef58b :        e80462e9ff
             mov ebp , eax                                                   ;0x005ef590 :        8be8
             mov  dword ptr [ esp + 96 ] , ebp                               ;0x005ef592 :        896c2460

     Label5ef596 ::
             cmp ebp , 02h                                                   ;0x005ef596 :        83fd02
             je Label4edce3                                                  ;0x005ef599 :        0f8444e7efff
             push ebx                                                        ;0x005ef59f :        53
             lea edi ,  dword ptr [ esp + 44 ]                               ;0x005ef5a0 :        8d7c242c
             call Fun8c8208                                                  ;0x005ef5a4 :        e85f8c2d00
             test eax , eax                                                  ;0x005ef5a9 :        85c0
             jne Label4edce3                                                 ;0x005ef5ab :        0f8532e7efff
             cmp ebp , 08h                                                   ;0x005ef5b1 :        83fd08
             je Label4edce3                                                  ;0x005ef5b4 :        0f8429e7efff
             push eax                                                        ;0x005ef5ba :        50
             pushd 0195h                                                     ;0x005ef5bb :        6895010000
             push ebx                                                        ;0x005ef5c0 :        53
             call Fun450463                                                  ;0x005ef5c1 :        e89d0ee6ff
             mov  dword ptr [ esp + 96 ] , eax                               ;0x005ef5c6 :        89442460
             mov eax , ebx                                                   ;0x005ef5ca :        8bc3
             call Fun485ccc                                                  ;0x005ef5cc :        e8fb66e9ff
             mov  eax , dword ptr [ esp + 96 ]                               ;0x005ef5d1 :        8b442460
             pop edi                                                         ;0x005ef5d5 :        5f
             pop esi                                                         ;0x005ef5d6 :        5e
             pop ebp                                                         ;0x005ef5d7 :        5d
             pop ebx                                                         ;0x005ef5d8 :        5b
             add esp , 044h                                                  ;0x005ef5d9 :        83c444
             ret 010h                                                        ;0x005ef5dc :        c21000


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_vfp9fix367.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix16.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix365.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix366.asp


6. OTHER:

     For reference only, there is no guarantees.

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