-------------------------------------------------------------------------------------------
                      [BUG/PRB.] VFP 9.0 FIX - THE DIRECTION OF THE CASCADING SUBMENU OF THE POPUP MENU
                                 January 2026
                 -------------------------------------------------------------------------------------------
                                     CCB



1. BUG:

     In vfp6, for the popup menu, when we click a menu bar to activate a cascading submenu,
     the cascading submenu is always shown on the right of the popup menu.

     In vfp7, vfp8 and vfp9, for the popup menu, when we click a menu bar to activate a cascading submenu,
     sometimes the cascading submenu is shown on the left of the popup menu.

     The bug occurs in vfp7, vfp8 and vfp9, it does not occur in vfp6.

     The bug occurs when SYSMETRIC(3)>8 (the width of sizable window frame), it does not occur when SYSMETRIC(3)<=8.

     The bug occurs on Windows 10 when set scaling to greater than 100% (and then SYSMETRIC(3)>8),
     it also occurs on Windows XP, Windows 7, Windows 8 and Windows 8.1 when SYSMETRIC(3)>8,
     it does not occur on Windows Vista (always SYSMETRIC(3)=4).

     The bug occurs for the popup menu created with the SHORTCUT keyword (shortcut menu).

     Please refer to the picture testpopupmenu-vfp9.png:

     In VFP Advanced, for the popup menu, when we click a menu bar to activate a cascading submenu,
     the cascading submenu is shown on the left or right of the popup menu automatically,
     and we we can set the cascading submenu is always shown on the left of the popup menu,
     or the cascading submenu is always shown on the right of the popup menu.

     Please refer to the picture testpopupmenu-vfpa.png:


2. CAUSE:

     There are some BUGs in the following code.


3. RESOLUTION:

     We can write some code to fix the BUG.

     Label5a067e ::
             test  byte ptr cl , 08h                                         ;0x005a067e :        f6c108
             jne Label471a6d                                                 ;0x005a0681 :        0f85e613edff
             mov ecx , 02h                                                   ;0x005a0687 :        b902000000
             call Fun42e572                                                  ;0x005a068c :        e8e1dee8ff
             test eax , eax                                                  ;0x005a0691 :        85c0
             jne Label471a6d                                                 ;0x005a0693 :        0f85d413edff
             mov eax , ebp                                                   ;0x005a0699 :        8bc5
             call Fun78947a                                                  ;0x005a069b :        e8da8d1e00
             mov  ecx , dword ptr [eax]                                      ;0x005a06a0 :        8b08
             mov  ecx , dword ptr [ ecx + 48 ]                               ;0x005a06a2 :        8b4930
             test ecx , ecx                                                  ;0x005a06a5 :        85c9
             je Label5a06ab                                                  ;0x005a06a7 :        7402
             mov eax , ecx                                                   ;0x005a06a9 :        8bc1

     Label5a06ab ::
             mov  eax , dword ptr [eax]                                      ;0x005a06ab :        8b00
             mov  ecx , dword ptr [ eax + 0A8h ]                             ;0x005a06ad :        8b88a8000000
             mov  eax , dword ptr [ eax + 0ACh ]                             ;0x005a06b3 :        8b80ac000000
             sub ebx , ecx                                                   ;0x005a06b9 :        2bd9
             sub esi , eax                                                   ;0x005a06bb :        2bf0
             jmp Label471a6d                                                 ;0x005a06bd :        e9ab13edff

     Label5a06c2 ::
             mov  edx , dword ptr [edi]                                      ;0x005a06c2 :        8b17
             mov  ecx , dword ptr [ edx + 16 ]                               ;0x005a06c4 :        8b4a10
             test  byte ptr ch , 040h                                        ;0x005a06c7 :        f6c540
             je Label471a7e                                                  ;0x005a06ca :        0f84ae13edff
             mov  edx , dword ptr [ eax + 098h ]                             ;0x005a06d0 :        8b9098000000
             mov  eax , dword ptr [edx]                                      ;0x005a06d6 :        8b02
             mov  rbp , GetWindowRect                          ;0x005a06d8 :        8b2d40739100
             lea ecx ,  dword ptr [ esp + 32 ]                               ;0x005a06de :        8d4c2420
             push ecx                                                        ;0x005a06e2 :        51
             mov  ecx , dword ptr [eax]                                      ;0x005a06e3 :        8b08
             push ecx                                                        ;0x005a06e5 :        51
             call ebp                                                        ;0x005a06e6 :        ffd5
             mov  edx , dword ptr [edi]                                      ;0x005a06e8 :        8b17
             mov  edi , dword ptr [ edx + 098h ]                             ;0x005a06ea :        8bba98000000
             test edi , edi                                                  ;0x005a06f0 :        85ff
             je Label5a0740                                                  ;0x005a06f2 :        744c
             mov  ecx , dword ptr [edi]                                      ;0x005a06f4 :        8b0f
             mov  edx , dword ptr [ecx]                                      ;0x005a06f6 :        8b11
             lea eax ,  dword ptr [ esp + 16 ]                               ;0x005a06f8 :        8d442410
             push eax                                                        ;0x005a06fc :        50
             push edx                                                        ;0x005a06fd :        52
             call ebp                                                        ;0x005a06fe :        ffd5
             mov  eax , dword ptr [edi]                                      ;0x005a0700 :        8b07
             mov  ebp , dword ptr [ eax + 52 ]                               ;0x005a0702 :        8b6834
             test ebp , ebp                                                  ;0x005a0705 :        85ed
             je Label5a0723                                                  ;0x005a0707 :        741a
             mov ecx , 01h                                                   ;0x005a0709 :        b901000000
             mov eax , edi                                                   ;0x005a070e :        8bc7
             call Fun42e572                                                  ;0x005a0710 :        e85ddee8ff
             test eax , eax                                                  ;0x005a0715 :        85c0
             je Label5a0723                                                  ;0x005a0717 :        740a
             push ebp                                                        ;0x005a0719 :        55
             lea edi ,  dword ptr [ esp + 20 ]                               ;0x005a071a :        8d7c2414
             call Fun439f42                                                  ;0x005a071e :        e81f98e9ff

     Label5a0723 ::
             mov  ecx , dword ptr [ esp + 24 ]                               ;0x005a0723 :        8b4c2418
             add ecx , 0FFFFFFF8h                                            ;0x005a0727 :        83c1f8


     ;
     ;                 --------------------------------------------------------------------------------
     ;                      VFP 9.0 FIX - THE DIRECTION OF THE CASCADING SUBMENU OF THE POPUP MENU
     ;                                  August 2025
     ;                 --------------------------------------------------------------------------------
     ;                                     CCB
     ;
     ; The direction of the cascading submenu of the popup menu.
     ;
     ; 2025/8/26, by ccb
     ;

             cmp dword ptr vfpa_sys9192_data,01h
             je Label5a072e
             cmp dword ptr vfpa_sys9192_data,02h
             je Label5a0740
             add ecx , 0FFFFFFF8h
             cmp esi , ecx
             jnl Label5a0740
             pushd 020h
             call GetSystemMetrics
             mov  ecx , dword ptr [ esp + 24 ]
             sub ecx , eax
             add ecx , 0FFFFFFFCh


             cmp esi , ecx                                                   ;0x005a072a :        3bf1
             jnl Label5a0740                                                 ;0x005a072c :        7d12

     Label5a072e ::
             mov  eax , dword ptr [ esp + 40 ]                               ;0x005a072e :        8b442428
             mov  edx , dword ptr [ esp + 32 ]                               ;0x005a0732 :        8b542420
             sub edx , eax                                                   ;0x005a0736 :        2bd0
             mov  eax , dword ptr [ esp + 16 ]                               ;0x005a0738 :        8b442410
             lea esi ,  dword ptr [ edx + eax + 8 ]                          ;0x005a073c :        8d740208

     Label5a0740 ::
             mov  ebp , dword ptr [ esp + 52 ]                               ;0x005a0740 :        8b6c2434
             jmp Label471a7e                                                 ;0x005a0744 :        e93513edff


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_vfp9fix390.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix63.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix64.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix360.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix361.asp


6. OTHER:

     For reference only, there is no guarantees.

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