View Full Version : Print Screen
Analog Kid
12-18-2003, 09:08 AM
I'm wanting to "Print Screen" within AutoPlay. I have tried playing with javascript window.print in several places but no luck.
I want the project will have a button that says "print this page". When the user clicks it, their print dialog box pops up, they select the printer and click print and a screen capture is sent to their printer.
I've seen ways of doing this by having a screen capture saved as a .jpg and telling the program to print that but there must be an easier way. There are many pages with info and I'd rather let the user print what he wants instead of setting up all of those commands.
Any help would be great. Thank you!
TJ_Tigger
12-18-2003, 09:39 AM
Is there something specific on the page that you are trying to print, like a web object or a paragraph object? There are two actions in AMS for printing, File.Print and Web.Print, these are the built in options. You can always grab the information from a paragraph object and write it to a text file in _TempFolder and print that particular file, or if you have a web object you can print that directly. Is it possible that you could duplicate your page as an html page, or use a web object to hold the information, that would solve your printing needs.
If you are on Win XP or later, the User32.dll has a PrintWindow function. Here is the description:
The PrintWindow function copies a visual window into the specified device context (DC), typically a printer DC.
I don't know how to call the functions from the dll yet, but some of the programmers here, like Worm, may be able to help in that departmenth.
Tigg
EDIT
BTW here is the example from the API guide, the red portion is what you would probably call from AMS, and it looks like you would need to get the window handle for the AMS window.
Private Declare Function PrintWindow Lib "user32" (ByVal hWnd As Long, ByVal hdcBlt As Long, ByVal nFlags As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Sub Form_Load()
'KPD-Team 2001
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
Dim mWnd As Long
'launch notepad
Shell "notepad.exe", vbNormalNoFocus
DoEvents
'set the graphics mode to persistent
Me.AutoRedraw = True
'search the handle of the notepad window
mWnd = FindWindow("Notepad", vbNullString)
If mWnd = 0 Then
Me.Print "NotePad window not found!"
Else
'draw the image of the notepad window on our form
PrintWindow mWnd, Me.hDC, 0
End If
End Sub
Analog Kid
12-18-2003, 10:05 AM
Thanks for responding. And very fast, I might add.
No, there is nothing specific I wish to print. Just what appears on the screen.
When you hit "Print Screen" on your keyboard, open something like PhotoShop and select New from clipboard you see the screen capture. That's what I want to print. It would stand to reason that just hitting Print Sceen would send the image to your printer and not the clipboard but I know that's not how it works.
I guess that's what I'm asking. How do I write a command that will take a screen capture (print screen) and send that to my printer.
The user gets a print out of exactly what he/she sees on the screen.
Thanks
TJ_Tigger
12-18-2003, 10:08 AM
If the page is static (not changing) you could take a screen capture and store it in your project, then have a button on the page that states [print screen] that will then print the image file. Of course this will only work if the items on your page do not change.
Analog Kid
12-18-2003, 10:21 AM
I've thought of that. Two reasons I'd like a work around are I'd have to do all the pages that way if I wanted them to be able to print any page they'd like and what if the info isn't static? Input boxes that have replies popping up or user controled flashes.
Surely there's a way to print a screen capture. I keep going back to JavaScript since that would make since but I can't find anything.
Any other ideas?
Thanks
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.