------------------------------------------------------
                      VFP 9.0 FIX - LISTBOX CONTROL PICTURES COUNT
                                  March 2017
                 ------------------------------------------------------
                                     CCB



1. BUG:

     In vfp9 (and vfp6, vfp7, vfp8), the ListBox Control only can display <= 500 pictures when the RowSourceType = 5 (Array),
     now it can display <= 65000 pictures.

     The bug was reported by Simon White.


2. CAUSE:

     There are some BUGs in the following code.


3. RESOLUTION:

     We can write some code to fix the BUG.

     Fun482682 :: ; proc near
             sub esp , 08h                                                   ;0x00482682 :        83ec08
             push ebx                                                        ;0x00482685 :        53
             push ebp                                                        ;0x00482686 :        55
             push esi                                                        ;0x00482687 :        56
             mov esi , ecx                                                   ;0x00482688 :        8bf1
             mov  eax , dword ptr [esi]                                      ;0x0048268a :        8b06
             mov  ecx , dword ptr [ eax + 60 ]                               ;0x0048268c :        8b483c
             push edi                                                        ;0x0048268f :        57
             mov ebx , edx                                                   ;0x00482690 :        8bda
             mov  dword ptr [ esp + 20 ] , ecx                               ;0x00482692 :        894c2414
             xor edi , edi                                                   ;0x00482696 :        33ff
             push edi                                                        ;0x00482698 :        57
             mov edx , 01h                                                   ;0x00482699 :        ba01000000
             mov ecx , esi                                                   ;0x0048269e :        8bce
             mov  dword ptr [ esp + 20 ] , ebx                               ;0x004826a0 :        895c2414
             call Fun43ab3b                                                  ;0x004826a4 :        e89284fbff
             mov  eax , dword ptr [ esp + 28 ]                               ;0x004826a9 :        8b44241c
             cmp eax , edi                                                   ;0x004826ad :        3bc7
             mov  edx , dword ptr [esi]                                      ;0x004826af :        8b16
             mov  dword ptr [ edx + 0ACh ] , eax                             ;0x004826b1 :        8982ac000000
             je Label44ff00                                                  ;0x004826b7 :        0f8443d8fcff


     ;
     ;                 ------------------------------------------------------
     ;                      VFP 9.0 FIX - LISTBOX CONTROL PICTURES COUNT
     ;                                  March 2017
     ;                 ------------------------------------------------------
     ;                                     CCB
     ;
     ; In vfp9, the ListBox Control only can display <= 500 pictures when the RowSourceType = 5 (Array),
     ; now it can display <= 65000 pictures.
     ;
     ; 2017/3/29, by ccb
     ;

     ;         cmp ebx , 01F4h                                                 ;0x004826bd :        81fbf4010000
             cmp ebx , 0FDE8h                                                 ;0x004826bd :        81fbf4010000


             jnl Label44ff5d                                                 ;0x004826c3 :        0f8d94d8fcff

     Label4826c9 ::
             mov edi , ebx                                                   ;0x004826c9 :        8bfb
             imul edi , edi , 059h                                           ;0x004826cb :        6bff59
             pushd 00h                                                       ;0x004826ce :        6a00
             lea ecx ,  dword ptr [ edi + 0160h ]                            ;0x004826d0 :        8d8f60010000
             push esi                                                        ;0x004826d6 :        56
             call Fun42c2c4                                                  ;0x004826d7 :        e8e89bfaff
             mov  edx , dword ptr [esi]                                      ;0x004826dc :        8b16
             mov ecx , edi                                                   ;0x004826de :        8bcf
             mov ebp , ecx                                                   ;0x004826e0 :        8be9
             shr ecx , 02h                                                   ;0x004826e2 :        c1e902
             add edx , 0100h                                                 ;0x004826e5 :        81c200010000
             xor eax , eax                                                   ;0x004826eb :        33c0
             mov edi , edx                                                   ;0x004826ed :        8bfa
             rep stosd                                                       ;0x004826ef :        f3ab
             mov ecx , ebp                                                   ;0x004826f1 :        8bcd
             and ecx , 03h                                                   ;0x004826f3 :        83e103
             xor ebp , ebp                                                   ;0x004826f6 :        33ed
             test ebx , ebx                                                  ;0x004826f8 :        85db
             rep stosb                                                       ;0x004826fa :        f3aa
             jle Label48270e                                                 ;0x004826fc :        7e10
             mov eax , ebx                                                   ;0x004826fe :        8bc3
             mov ebp , ebx                                                   ;0x00482700 :        8beb

     Label482702 ::
             mov  dword ptr [edx] , 0FFFFFFFFh                               ;0x00482702 :        c702ffffffff
             add edx , 059h                                                  ;0x00482708 :        83c259
             dec eax                                                         ;0x0048270b :        48
             jne Label482702                                                 ;0x0048270c :        75f4

     Label48270e ::
             mov  ecx , dword ptr [esi]                                      ;0x0048270e :        8b0e
             mov  eax , dword ptr [ esp + 16 ]                               ;0x00482710 :        8b442410
             mov  dword ptr [ ecx + 68 ] , eax                               ;0x00482714 :        894144
             mov  edx , dword ptr [esi]                                      ;0x00482717 :        8b16
             mov  dword ptr [ edx + 0ECh ] , ebx                             ;0x00482719 :        899aec000000
             mov  ecx , dword ptr [esi]                                      ;0x0048271f :        8b0e
             mov  dword ptr [ ecx + 56 ] , 0FFFFFFFFh                        ;0x00482721 :        c74138ffffffff
             mov  ecx , dword ptr [ esp + 20 ]                               ;0x00482728 :        8b4c2414
             cmp eax , ecx                                                   ;0x0048272c :        3bc1
             mov  edx , dword ptr [esi]                                      ;0x0048272e :        8b16
             mov  dword ptr [ edx + 92 ] , 00h                               ;0x00482730 :        c7425c00000000
             jle Label482740                                                 ;0x00482737 :        7e07
             mov eax , ecx                                                   ;0x00482739 :        8bc1
             mov  ecx , dword ptr [esi]                                      ;0x0048273b :        8b0e
             mov  dword ptr [ ecx + 60 ] , eax                               ;0x0048273d :        89413c

     Label482740 ::
             mov  eax , dword ptr [esi]                                      ;0x00482740 :        8b06
             mov  ecx , dword ptr [ eax + 12 ]                               ;0x00482742 :        8b480c
             or ecx , 040010h                                                ;0x00482745 :        81c910000400
             xor edi , edi                                                   ;0x0048274b :        33ff

     Label48274d ::
             mov  dword ptr [ eax + 12 ] , ecx                               ;0x0048274d :        89480c
             mov ecx , esi                                                   ;0x00482750 :        8bce
             call Label42ff55                                                ;0x00482752 :        e8fed7faff
             mov  eax , dword ptr [esi]                                      ;0x00482757 :        8b06
             cmp  dword ptr [ eax + 32 ] , edi                               ;0x00482759 :        397820
             jne Label5a1930                                                 ;0x0048275c :        0f85cef11100

     Label482762 ::
             pop edi                                                         ;0x00482762 :        5f
             pop esi                                                         ;0x00482763 :        5e
             pop ebp                                                         ;0x00482764 :        5d
             pop ebx                                                         ;0x00482765 :        5b
             add esp , 08h                                                   ;0x00482766 :        83c408
             ret 04h                                                         ;0x00482769 :        c20400


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

     2, tek-tips.com:
     http://www.tek-tips.com/viewthread.cfm?qid=1731941


6. OTHER:

     For reference only, there is no guarantees.

     Any questions or suggestions, please e-mail to ccb2000@163.com.