------------------------------------------------------------
                         [BUG/PRB.] VFP 9.0 FIX - FONT PROPERTY PAGE
                                 January 2024
                 ------------------------------------------------------------
                                     CCB



1. BUG:

     If the ActiveX control uses the stock Font property,
     usually we can open the Font Property Page to set the control's Font property,
     but sometimes we can not open the Font Property Page.

     There is the same problem for the Color Property Page and the Picture Property Page.


2. CAUSE:

     In Visual C++ 6.0 (Visual Studio 98), the MFC ActiveX control uses the class CFontPropPage to set the control's Font property,
     it needs the MFC library file mfc40.dll to run.

     In Visual C++ 7.0 (Visual Studio .NET) or later, the MFC ActiveX control uses the class StockFontPage to set the control's Font property,
     it needs the MFC library file mfc40.dll and the file msstkprp.dll to run.

     There is no the file msstkprp.dll in Visual C++ 7.0 (Visual Studio .NET) or later,
     so we need to copy the file msstkprp.dll from Visual C++ 6.0 (Visual Studio 98) to the Windows system folder,
     and run the command regsvr32 c:\windows\system32\msstkprp.dll to register it,
     and then we can use the class StockFontPage to set the control's Font property.

     There is no the file msstkprp.dll 64-bit version too.

     We can use the class CFontPropPage instead of the class StockFontPage to set the control's Font property,
     and use the class CColorPropPage instead of the class StockColorPage to set the control's Color property,
     and use the class CPicturePropPage instead of the class StockPicturePage to set the control's Picture property,
     so it does not need the file msstkprp.dll, it only needs the MFC library file mfc40.dll to run.


3. RESOLUTION:

     We can write some code to fix the BUG.
 
     vfpa_olecreatepropertyframeindirect :: ; proc near

             push ebp
             mov ebp,esp
             sub esp,04h
             push ebx
             push esi
             push edi

             mov esi,dword ptr [ebp+08h]
             test esi,esi
             je vfpa_olecreatepropertyframeindirect_end

             mov ecx,dword ptr [esi+1Ch]
             test ecx,ecx
             je vfpa_olecreatepropertyframeindirect_end

             mov eax,dword ptr [esi+20h]
             test eax,eax
             je vfpa_olecreatepropertyframeindirect_end

     vfpa_olecreatepropertyframeindirect_loop:

     vfpa_olecreatepropertyframeindirect_font_start:
             ; {7EBDAAE0-8120-11CF-899F-00AA00688B10}, StockFontPage ("MS Stock Font Property Page Object")
             ; {0BE35200-8F91-11CE-9DE3-00AA004BB851}, CFontPropPage ("Font Property Page")
             cmp dword ptr [eax],07EBDAAE0h
             jne vfpa_olecreatepropertyframeindirect_font_end
             cmp dword ptr [eax+04h],011CF8120h
             jne vfpa_olecreatepropertyframeindirect_font_end
             cmp dword ptr [eax+08h],0AA009F89h
             jne vfpa_olecreatepropertyframeindirect_font_end
             cmp dword ptr [eax+0Ch],0108B6800h
             jne vfpa_olecreatepropertyframeindirect_font_end
             mov dword ptr [eax],00BE35200h
             mov dword ptr [eax+04h],011CE8F91h
             mov dword ptr [eax+08h],0AA00E39Dh
             mov dword ptr [eax+0Ch],051B84B00h
             jmp vfpa_olecreatepropertyframeindirect_end0
     vfpa_olecreatepropertyframeindirect_font_end:

     vfpa_olecreatepropertyframeindirect_color_start:
             ; {7EBDAAE1-8120-11CF-899F-00AA00688B10}, StockColorPage ("MS Stock Color Property Page Object")
             ; {0BE35201-8F91-11CE-9DE3-00AA004BB851}, CColorPropPage ("Color Property Page")
             cmp dword ptr [eax],07EBDAAE1h
             jne vfpa_olecreatepropertyframeindirect_color_end
             cmp dword ptr [eax+04h],011CF8120h
             jne vfpa_olecreatepropertyframeindirect_color_end
             cmp dword ptr [eax+08h],0AA009F89h
             jne vfpa_olecreatepropertyframeindirect_color_end
             cmp dword ptr [eax+0Ch],0108B6800h
             jne vfpa_olecreatepropertyframeindirect_color_end
             mov dword ptr [eax],00BE35201h
             mov dword ptr [eax+04h],011CE8F91h
             mov dword ptr [eax+08h],0AA00E39Dh
             mov dword ptr [eax+0Ch],051B84B00h
             jmp vfpa_olecreatepropertyframeindirect_end0
     vfpa_olecreatepropertyframeindirect_color_end:

     vfpa_olecreatepropertyframeindirect_picture_start:
             ; {7EBDAAE2-8120-11CF-899F-00AA00688B10}, StockPicturePage ("MS Stock Picture Property Page Object")
             ; {0BE35202-8F91-11CE-9DE3-00AA004BB851}, CPicturePropPage ("Picture Property Page")
             cmp dword ptr [eax],07EBDAAE2h
             jne vfpa_olecreatepropertyframeindirect_picture_end
             cmp dword ptr [eax+04h],011CF8120h
             jne vfpa_olecreatepropertyframeindirect_picture_end
             cmp dword ptr [eax+08h],0AA009F89h
             jne vfpa_olecreatepropertyframeindirect_picture_end
             cmp dword ptr [eax+0Ch],0108B6800h
             jne vfpa_olecreatepropertyframeindirect_picture_end
             mov dword ptr [eax],00BE35202h
             mov dword ptr [eax+04h],011CE8F91h
             mov dword ptr [eax+08h],0AA00E39Dh
             mov dword ptr [eax+0Ch],051B84B00h
             jmp vfpa_olecreatepropertyframeindirect_end0
     vfpa_olecreatepropertyframeindirect_picture_end:

     vfpa_olecreatepropertyframeindirect_end0:
             add eax,10h
             dec ecx
             test ecx,ecx
             jne vfpa_olecreatepropertyframeindirect_loop

     vfpa_olecreatepropertyframeindirect_end:
             push esi
             call OleCreatePropertyFrameIndirect
             mov dword ptr [ebp-04h],eax

             pop edi
             pop esi
             pop ebx
             mov eax,dword ptr [ebp-04h]
             mov esp,ebp
             pop ebp
             ret 04h

     ; vfpa_olecreatepropertyframeindirect endp

     We can use the vfpa_olecreatepropertyframeindirect() function instead of the OleCreatePropertyFrameIndirect Windows API,
     so we can use the class CFontPropPage to set the control's Font property,
     and use the class CColorPropPage to set the control's Color property,
     and use the class CPicturePropPage to set the control's Picture property.


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, microsoft.com:
     https://msdn.microsoft.com/en-us/library/w1sc4t4k(v=vs.90).aspx
     https://social.technet.microsoft.com/Forums/en-US/2c80771b-eb63-4a85-a57c-bffe2d3035cb/class-not-registered?forum=excel
     https://social.msdn.microsoft.com/Forums/en-US/f7c9d4d2-dbfa-44bd-a804-9f2fa1d27093/vs6-to-vs2010-font?forum=vclanguage

     3, stackoverflow.com:
     http://stackoverflow.com/questions/10524676/is-there-a-x64-version-of-msstkprp-dll

     4, codeguru.com:
     http://www.codeguru.com/cpp/com-tech/activex/controls/article.php/c2647/Undocumented-MS-Stock-Property-Pages-In-VC5.htm


6. OTHER:

     For reference only, there is no guarantees.

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