Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Click on the report's printer button 1

Status
Not open for further replies.

wrov

Programmer
Nov 1, 2002
43
0
0
PY
Hello

If I have this instruction:

report form MyReport preview

There is some way to know if the user has clicked the printer button or just saw the report in the screen ?

Thank you in advance

Walter.

 
If I understand what you're asking, you want to know if there is something environmental that you can detect from within your application when a user clicks the printer icon in the print preview toolbar window. Not that I could ever find.

The solution I came to was to detect a mouse click in that window, within the coordinates of that icon. Got a bit tricky since the print preview window dimensions can be altered by the user, but it can be done, if that's what you're up against.
 
I'll give credit to rgbean (I think) for this one:
"Yes! The usual technique used is to create a UDF() that looks for the
distinctive "Printing..." Window and call it in the report title or summary,
depending on whether you want to know if the printing was completely send to
the printer (spooler more accurately). Something like:
*** wasprinted.prg
IF WEXIST("Printing...")
g_lPrintedDuringPreview = .T.
ENDIF

Of course g_lPrintedDuringPreview is "global" to the print process and was
set to .F. before the REPORT ... TO PRINTER PREVIEW, and you check the value
after the report has completed"[endquote]

The idea is to determine if the "Printing..." window appeared while the user previewed the report. Of course this doesn't account if the printer is on, or the system crashed etc...It just means the "Printing..." window appeared.

You could also remove the print icon from the preview tollbar, to prevent the user from printing in a preview mode.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first
 
wrov

If you remove the Print button from the preview toolbar as suggested by Mike, you also remove the problems associated with it, such the question you have raised.

If you want more than one copy, the user has to hit the button n times.

How do you know the user has selected the appropriate printer, page size, etc, etc?
FAQ184-2483 - the answer to getting answered.​

Chris [pc2]
 
You can remove the print icon from the print preview toolbar window? How?
 
Zog1

You can remove the print icon from the print preview toolbar window? How?

Look at faq184-1933
Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first
 
Thanks, Mike, but I was looking for a way to conditionally remove that icon during runtime. It would be a boon to my life if I could do that.
 
Thanks, Mike, but I was looking for a way to conditionally remove that icon during runtime. It would be a boon to my life if I could do that.

I guess you could hack the foxuser.dbf file where the information is stored at runtime.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first
 
Guess this is a 'wish-list' thing for me then. Thanks again, Mike.
 
zog1

Guess this is a 'wish-list' thing for me then. Thanks again, Mike.

No you can hack the resource file by using:
USE SYS(2005) SHARED AGAIN IN 0
SELECT FILTER TO ID = "TTOOLBAR"
GO BOTTOM

But the problem is the information in stored in binary. I'm not sure how to change it.
Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first
 
Zog1

Remove the button as per faq184-1933 and copy foxuser.bdf to noprintbutton.dbf and delete all records except the one with FOXUSER.name = [Print Preview]

Then in the application :-

SET RESO OFF
USE SYS(5) + ADDBS(SYS(2003)) + [foxuser.dbf] IN 0
LOCATE FOR name = [Print Preview]
DELETE
PACK
APPE FROM SYS(5) + ADDBS(SYS(2003)) + [noprintbutton.dbf]
USE
SET RESO TO SYS(5) + ADDBS(SYS(2003)) + [foxuser.dbf]

If you maintain printbutton.dbf and noprintbutton.dbf, you can switch between print button or no print button.
FAQ184-2483 - the answer to getting answered.​

Chris [pc2]
 
ChrisRChamberlain

Remove the button as per FAQ184-1933 and copy foxuser.bdf to noprintbutton.dbf and delete all records except the one with FOXUSER.name = [Print Preview]

Now why didn't I think of that! Good work. Star worthy!
Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first
 
Mike

Thanks for your generosity.

I have not tested the code but I can see a code omission, (somehow sounds better than a typo!) :-

lcAlias = ALIAS()
SET RESO OFF
USE SYS(5) + ADDBS(SYS(2003)) + [foxuser.dbf] IN 0
SELE FOXUSER
LOCATE FOR name = [Print Preview]
DELETE
PACK
APPE FROM SYS(5) + ADDBS(SYS(2003)) + [noprintbutton.dbf]
USE
SET RESO TO SYS(5) + ADDBS(SYS(2003)) + [foxuser.dbf]
SELE (lcAlias)
FAQ184-2483 - the answer to getting answered.​

Chris [pc2]
 
Thanks a lot to Mike and Chris

Now, I know how to resolve it.

Walter.
 
Bravo! Got to ponder the problems this might introduce for the users, but it sounds promising. I'll give it a run tomorrow and let you know what I decide. Of course I'd prefer being able to either directly alter(correctly) the Data memo or call a FoxPro function(wish-list item).

Again, thanks for the ideas!
 
Well, okay, I'm stupid.

But I can't figure out any way to remove the printer icon from the print preview toolbar. I read the FAQ and the FoxPro help topic. I followed the instructions, dragging the printer icon off. All that did was create a new toolbar. Had another programmer give it a go, and he couldn't figure it out either. Two stupid programmers!

Do you know how to do this?
 
Zog1

[ol][li]Copy the FoxUser files somewhere else on your computer and rename them to myNewFox.dbf.[/li]
[li]Open VFP and open that myNewFox.dbf exclusive and zap the records and close it.[/li]
[li]In the command window use: SET RESOURCE TO <full path> myNewFox.dbf[/li]
[li] Do the steps in the FAQ. So now you have a Resource file that remembers you don't have a print button in your toolbar. You may want to set the files to read-only in the windows explorer.[/li]
[li]When you want to use it, you have to use: SET RESOURCE TO <full path> myNewFox.dbf[/li]
Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first
 
Everything's just fine except for step 4 of your instructions, Mike.

From the FAQ: You can modify the toolbar by choosing 'View / Toolbars...' from the menu. Now you can select the toolbar, and with the customize button you can modify it.

Yep, I want to modify it alright. However, I cannot find any way to remove the printer icon from the Print Preview toolbar. Do you know how this is done?
 
HI Zog1,

You have gone upto CUSTOMISE TOOLBAR.. fine..
Then.. as next step..
Drag the icons you want from the PrintPreview Toolbar to a bare location on the screen one by one and it to the new toolbar box (except the printer icon). Beware of the name ToolBar1 auto provided.

Another way is instead of clicking customise.. click on New. provide a name PrintPreview without space (since the standard one has a space between the words). Now drag the icons one by one as in above step and leave it on the new one you are creating.

Now click on close.

Again open the View->ToolBar .. unclick on all except the one you created one and close.
Quit FoxPro.
From the Windows browser or from DOS prompt.. copy the FoxUser.* as myPrintUser.* and change its attribute to +R read only.

Now you are ready to go thru..

in your report commands.. you can..

SET RESOURCE TO myPrintUser
REPORT FORM..... etc..
SET RESOURCE TO DEFAULT && or whatever

:) ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top