--------------------------------------------------------------------------------
                      [ENHANCED] VFP 9.0 FIX - THE PRINT BUTTON IN THE PRINT PREVIEW TOOLBAR
                                 January 2024
                 --------------------------------------------------------------------------------
                                     CCB



1. BUG:

     In vfp9 (and vfp6, vfp7, vfp8), it will ALWAYS enable the Print button in the Print Preview toolbar.


2. CAUSE:

     There are some BUGs in the following code.


3. RESOLUTION:

     We can write some code to fix the BUG.

     Label623f4e ::
             lea edx ,  dword ptr [ ebp + 100 ]                              ;0x00623f4e :        8d5564
             lea eax ,  dword ptr [ ebp - 60 ]                               ;0x00623f51 :        8d45c4
             call Fun42c27f                                                  ;0x00623f54 :        e82683e0ff
             push esi                                                        ;0x00623f59 :        56
             push eax                                                        ;0x00623f5a :        50
             call Fun42c2be                                                  ;0x00623f5b :        e85e83e0ff
             cmp eax , esi                                                   ;0x00623f60 :        3bc6
             pop ecx                                                         ;0x00623f62 :        59
             pop ecx                                                         ;0x00623f63 :        59
             mov  dword ptr [ ebp + 112 ] , eax                              ;0x00623f64 :        894570
             jne Label623f96                                                 ;0x00623f67 :        752d


     ;
     ;                  ---------------------------------------------------------------------
     ;                       VFP 9.0 FIX - THE PRINT BUTTON IN THE PRINT PREVIEW TOOLBAR
     ;                                 October 2018
     ;                  ---------------------------------------------------------------------
     ;                                     CCB
     ;
     ; In vfp9, it will ALWAYS enable the Print button in the Print Preview toolbar.
     ; In VFP Advanced, it can enable or disable the Print button in the Print Preview toolbar.
     ;
     ; 2018/10/10, by ccb
     ;

             cmp dword ptr vfpa_reportform_isreportform,00h
             je Label623f69
             cmp  byte ptr [ Data93c280 ] , 05Ah
             jae Label623f69
             call vfpa_setprintbutton


     Label623f69 ::
             push esi                                                        ;0x00623f69 :        56
             pushd 0FFFFB106h                                                ;0x00623f6a :        6806b1ffff
             push edi                                                        ;0x00623f6f :        57
             call Fun4a082d                                                  ;0x00623f70 :        e8b8c8e7ff
             push esi                                                        ;0x00623f75 :        56
             pushd 0FFFFB111h                                                ;0x00623f76 :        6811b1ffff
             push edi                                                        ;0x00623f7b :        57
             call Fun4a082d                                                  ;0x00623f7c :        e8acc8e7ff
             push  dword ptr [ ebp + 104 ]                                   ;0x00623f81 :        ff7568
             mov  eax , dword ptr [ ebp + 124 ]                              ;0x00623f84 :        8b457c
             push  dword ptr [ eax + 01F8h ]                                 ;0x00623f87 :        ffb0f8010000
             push eax                                                        ;0x00623f8d :        50
             call Fun6237ca                                                  ;0x00623f8e :        e837f8ffff
             mov  dword ptr [ ebp + 120 ] , eax                              ;0x00623f93 :        894578

     Now In VFP Advanced, it can enable or disable the Print button in the Print Preview toolbar.

     In vfp9 and VFP Advanced, if we set ReportBehavior 90,
     we can also use the ReportPreview.AllowPrintfromPreview property to enable or disable the Print button in the Print Preview toolbar.


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_vfp9fix52.asp

     2, microsoft.com:
     https://social.msdn.microsoft.com/forums/en-US/4cd61f4c-bc29-4f86-839b-ac8afa278149/print-preview-toolbar-vfp6
     https://support.microsoft.com/zh-cn/help/895279/how-to-prevent-printing-from-a-report-preview-in-visual-foxpro-9-0
     https://social.msdn.microsoft.com/Forums/en-US/416cc5fb-34ab-4945-a028-7d5327409550/close-button-on-print-preview-toolbar

     3, foxite.com:
     http://weblogs.foxite.com/vfpimaging/2008/04/11/how-to-disable-print-button-in-report-preview/
     https://www.foxite.com/archives/vfp-6-print-preview-toolbar-0000016389.htm
     https://www.foxite.com/archives/remove-print-button-in-preview-toolbar-0000199754.htm
     https://www.foxite.com/archives/control-print-preview-toolbar-0000163281.htm
     https://www.foxite.com/archives/how-to-find-out-whether-a-report-is-printed-in-vfp-0000030631.htm
     https://www.foxite.com/archives/hide-print-button-on-preview-toolbar-0000326680.htm
     https://www.foxite.com/archives/hide-print-icon-from-print-preview-tool-0000157331.htm
     https://www.foxite.com/archives/how-to-disable-print-features-from-print-preview-0000058156.htm
     https://www.foxite.com/archives/how-to-remove-printer-icon-in-printer-preview-0000043652.htm

     4, computer-programming-forum.com:
     http://computer-programming-forum.com/2-vfp/32bed8f6a57d74fc.htm

     5, devx.com:
     http://www.devx.com/tips/Tip/24552


6. OTHER:

     For reference only, there is no guarantees.

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