Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to disable print icon in printer preview
Message
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Miscellaneous
Thread ID:
00712086
Message ID:
00712202
Views:
14
Hi Allan,

Try this code:
MartinJ
DECLARE INTEGER SetParent IN USER32 INTEGER, INTEGER
DECLARE INTEGER GetParent IN USER32 INTEGER
DECLARE         _fpreset IN msvcrt20.dll

DECLARE INTEGER CreateWindowExA IN USER32 INTEGER, STRING @, STRING @, INTEGER, INTEGER, INTEGER,;
                                INTEGER, INTEGER, INTEGER, INTEGER, INTEGER, STRING
DECLARE INTEGER GetClassName IN USER32 INTEGER, STRING @, INTEGER
DECLARE INTEGER GetWindowLong IN USER32 INTEGER, INTEGER
DECLARE INTEGER SetWindowLong IN USER32 INTEGER, INTEGER, INTEGER
DECLARE INTEGER ShowWindow IN USER32 INTEGER, INTEGER
DECLARE INTEGER DestroyWindow IN USER32 INTEGER
DECLARE INTEGER MoveWindow IN USER32 INTEGER, INTEGER,INTEGER, INTEGER,INTEGER, INTEGER
DECLARE INTEGER SetWindowPos IN USER32 INTEGER, INTEGER,INTEGER, INTEGER,INTEGER, INTEGER, INTEGER
DECLARE INTEGER IsWindowVisible IN USER32 INTEGER



#define WS_OVERLAPPED       0x00000000
#define WS_POPUP            0x80000000
#define WS_CHILD            0x40000000
#define WS_MINIMIZE         0x20000000
#define WS_VISIBLE          0x10000000
#define WS_DISABLED         0x08000000
#define WS_CLIPSIBLINGS     0x04000000
#define WS_CLIPCHILDREN     0x02000000
#define WS_MAXIMIZE         0x01000000
#define WS_CAPTION          0x00C00000
#define WS_BORDER           0x00800000
#define WS_DLGFRAME         0x00400000
#define WS_VSCROLL          0x00200000
#define WS_HSCROLL          0x00100000
#define WS_SYSMENU          0x00080000
#define WS_THICKFRAME       0x00040000
#define WS_GROUP            0x00020000
#define WS_TABSTOP          0x00010000

#define WS_MINIMIZEBOX      0x00020000
#define WS_MAXIMIZEBOX      0x00010000


#define WS_EX_DLGMODALFRAME     0x00000001
#define WS_EX_NOPARENTNOTIFY    0x00000004
#define WS_EX_TOPMOST           0x00000008
#define WS_EX_ACCEPTFILES       0x00000010
#define WS_EX_TRANSPARENT       0x00000020
#define WS_EX_MDICHILD          0x00000040
#define WS_EX_TOOLWINDOW        0x00000080
#define WS_EX_WINDOWEDGE        0x00000100
#define WS_EX_CLIENTEDGE        0x00000200
#define WS_EX_CONTEXTHELP       0x00000400

#define WS_EX_RIGHT             0x00001000
#define WS_EX_LEFT              0x00000000
#define WS_EX_RTLREADING        0x00002000
#define WS_EX_LTRREADING        0x00000000
#define WS_EX_LEFTSCROLLBAR     0x00004000
#define WS_EX_RIGHTSCROLLBAR    0x00000000

#define WS_EX_CONTROLPARENT     0x00010000
#define WS_EX_STATICEDGE        0x00020000
#define WS_EX_APPWINDOW         0x00040000


#define WS_EX_OVERLAPPEDWINDOW  (WS_EX_WINDOWEDGE + WS_EX_CLIENTEDGE)
#define WS_EX_PALETTEWINDOW     (WS_EX_WINDOWEDGE + WS_EX_TOOLWINDOW + WS_EX_TOPMOST)


#DEFINE GWL_HINSTANCE       (-6)
#define GWL_STYLE           (-16)
#define GWL_EXSTYLE         (-20)
#DEFINE SW_NORMAL           1
#define SW_SHOWNOACTIVATE   4

SET LIBRARY TO Foxtools.fll

*LOCAL lotmr,lcPath,lcAlias 
*lcAlias=SYS(2015)
*lcPath=SYS(16)
*lcPath=IIF(RAT("\",lcPath)>0,LEFT(lcPath,RAT("\",lcPath)),lcPath)
*
*USE (lcPath+"XXT900") ALIAS (lcAlias) IN 0
* Use table


lotmr=CREATEOBJECT("_tmr")
lotmr.Enabled=.T.
REPORT FORM (lcPath+"xxr000") PREVIEW

RELE lotmr


*USE IN (lcAlias)


SET LIBRARY TO 
RETURN

**********************************************

DEFINE CLASS _tmr AS timer
   Name="_tmr"
   Enabled=.F.
   Interval=100
  
   DIME aPos(8,2), bPos(8,2)

   * Array for VFP5/6
   aPos(1,1)=229 && 259
   aPos(1,2)=5
   aPos(2,1)=229 && 257
   aPos(2,2)=5
   aPos(3,1)=95 && 137
   aPos(3,2)=30
   aPos(4,1)=34 && 118
   aPos(4,2)=55
   aPos(5,1)=34 && 85
   aPos(5,2)=80
   aPos(6,1)=33 && 66
   aPos(6,2)=105
   aPos(7,1)=4 && 35
   aPos(7,2)=147
   aPos(8,1)=-40
   aPos(8,2)=0

   * Array for VFP7
   bPos(1,1)=246 && 300
   bPos(1,2)=4
   bPos(2,1)=237 && 267
   bPos(2,2)=4
   bPos(3,1)=99 && 141
   bPos(3,2)=34
   bPos(4,1)=37 && 120
   bPos(4,2)=61
   bPos(5,1)=34 && 87
   bPos(5,2)=92
   bPos(6,1)=34 && 66
   bPos(6,2)=120
   bPos(7,1)=4 && 35
   bPos(7,2)=171
   bPos(8,1)=-40
   bPos(8,2)=0

   hPP=0 && Handle window Print Preview
   hTW=0 && Handle working window

   vhPP=0 && VFP Handle okna Print Preview
   vhTW=0 && VFP Handle working window 

   nTW = "" && Name working window
   pTW = "" && Name of object reference window

   iIndex=0
   * Ehm..., custom title window
   cTitle="+++ Bìží liška k Táboru, nese pytel zázvoru."+;
          " Bìž, zajíèku, bìž za ní, pober jí to koøení."+;
          " +++ Ema solí. Ela mele. Pepa láme. Míla lepí."+;
          " +++ Náš Kudrna bìží z Brna, pøed ním skáèe hnìdá skvrna, velká jako malá srna."+;
          " Je to skvrna nebo srna? Poví nám to Kudrna, až se vrátí z Brna."+;
          " +++ Paci, paci pacièky, máma koupí botièky a tatínek pásek za myší ocásek."
   dTitle="Print Preview" && Title toolbar "Print Preview"
   
   OWidth=0

   * Close working window
   PROCEDURE Destroy
      =DestroyWindow(This.hTW)
   ENDPROC

   * Create working window
   PROCEDURE Init
      =_fpreset()

      * Vytvoø okno pomocí WIN API
      LOCAL lcClass,lii
      lcClass=SPACE(254)
      =GetClassName(MAINHWND(),@lcClass,LEN(lcClass))

      This.hTW=CreateWindowExA(0, ;
               ("STATIC"),.NULL.,;
               WS_CHILD,;
               0,0,100,100,MAINHWND(),0,GetWindowLong(MAINHWND(),GWL_HINSTANCE),.NULL.)


      IF This.hTW=0
         This.Destroy()
      ELSE
         lii=GetWindowLong(This.hTW,GWL_STYLE)
         =SetWindowLong(This.hTW,GWL_STYLE,lii+WS_DISABLED-WS_CHILD)
      ENDIF

      RETURN This.hTW>0
   ENDPROC

   PROCEDURE Timer
      =_fpreset()

      * Get handle toolbar "Print Preview"
      IF This.vhPP=0
         This.vhPP=_WFINDTITL(This.dTitle)
         This.hPP=IIF(This.vhPP<=0,0,_WHTOHWND(This.vhPP))
      ENDIF

      IF This.hPP<=0
         RETURN
      ENDIF
      LOCAL lcPom,liLeft,liTop,lii

* Custom tittle
*      This.iIndex=This.iIndex+1
*      lcPom=SUBS(This.cTitle,This.iIndex,30)
*      IF LEN(This.cTitle)-This.iIndex<30
*         lcPom=lcPom+" "+LEFT(This.cTitle,30-(LEN(This.cTitle)-This.iIndex-1))
*      ENDIF
*      =_WSETTITLE(This.vhPP,This.dTitle+" - "+lcPom)
*      IF This.iIndex>LEN(This.cTitle)
*         This.iIndex=0
*      ENDIF

      liWidth=_WWIDTHP(This.vhPP)
      IF liWidth=This.OWidth
         RETURN
      ENDIF         
      IF IsWindowVisible(This.hTW)=0
         =SetParent(This.hTW,This.hPP)
         =ShowWindow(This.hTW,SW_SHOWNOACTIVATE)
      ENDIF

      This.OWidth=liWidth
      lcPom=STRTRAN(SUBS(VERSION(),LEN("Visual FoxPro ")+1,2),"0","")
      IF lcPom<="6"
         lii=IIF(liWidth=259,1,;
             IIF(liWidth=257,2,;
             IIF(liWidth=137,3,;
             IIF(liWidth=118,4,;
             IIF(liWidth=85,5,;
             IIF(liWidth=66,6,;
             IIF(liWidth=35,7,8)))))))
         liLeft=This.aPos(lii,1)
         liTop=This.aPos(lii,2)
      ELSE
         lii=IIF(liWidth>267,1,;
             IIF(liWidth=267,2,;
             IIF(liWidth=141,3,;
             IIF(liWidth=120,4,;
             IIF(liWidth=87,5,;
             IIF(liWidth=66,6,;
             IIF(liWidth=35,7,8)))))))
         liLeft=This.bPos(lii,1)
         liTop=This.bPos(lii,2)
      ENDIF
      =MoveWindow(This.hTW,liLeft,liTop,24,22,8)
   ENDPROC
ENDDEFINE
>This project is in VFP 5.
>I tried the steps in the MS KB.
>I paste and run the first prg. I right click on the preview title and customize pops up. The print preview is not on the categories in the customization pop up.
>
>>See HOWTO: Remove Buttons from the Print Preview Toolbar mskb #Q317466 and Providing Toolbars in Your App FAQ #7876.
>>
>>>Is it possible to disable the printer icon in a print preview * or * have the output to the printer not print?
>>>I am trying to disable the ability to print (preview is OK) if my software is in DEMO mode versus a registered version.
>>>I tried 'set printer to nul' but the print icon still sends the output to the printer.
>>>Thanks in advance.
"Navision is evil that needs to be erazed... to the ground"

Jabber: gorila@dione.zcu.cz
Jabber? Jabbim
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform