|
-
Aug 12th, 2010, 03:58 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] printform method - how to save a file?
I am using the printform method eg. Form2.printform.
This seems a beautifully simple and effective way to produce a printed output from a vb6 program. The form can be schemed at design time and/or modified at runtime, and printed. Works a treat.
My question is how to save as a file what was printed by this method, such that it might subsequently be called up / referred to?
According to my VB6 books, the printform method sends a bitmap image to the printer of adequate but not outstanding definition (however the definition level is just fine for my purpose, which is simple text).
How please is it possible also to save this bitmap file - presumably as a .bmp (or otherwise) to the hard drive for subsequent reference? I could turn it into a .txt file, but to do so would be quite a grind. If vb6 passes it as a .bmp file to the Windows printer, can it not be stored somehow en-route?
Suggestions appreciated.
camoore
Wales, UK
-
Aug 13th, 2010, 04:40 AM
#2
Re: printform method - how to save a file?
Do you need the window client area only or do you need the whole window including caption bar, menu etc.?
-
Aug 13th, 2010, 06:00 AM
#3
Thread Starter
Hyperactive Member
Re: printform method - how to save a file?
Hi Merri, I need only the client area and specifically not the caption bar, menu etc.(although if they were included in the saved image it would not matter).
I wonder if you are thinking of a printscreen process which will result in a .jpg file? That could be a solution, but I was hoping that the relatively low resolution .bmp file which, according to my book, is passed to the Windows printer would be much smaller, and thus occupy less memory.
-
Aug 13th, 2010, 06:04 AM
#4
Re: printform method - how to save a file?
Try this
vb Code:
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, _
ByVal bScan As Byte, _
ByVal dwFlags As Long, _
ByVal dwExtraInfo As Long)
Private Const VK_SNAPSHOT = &H2C
Private Function SaveScreen(ByVal theFile As String) As Boolean
'To get the Entire Screen
'Call keybd_event(vbKeySnapshot, 1, 0, 0) 'from what you say you don't want this, but I give it in
'case you may want it sometime
'To get the Active Window
Call keybd_event(vbKeySnapshot, 0, 0, 0) 'this sounds like it is what you are after
SavePicture Clipboard.GetData(vbCFBitmap), theFile
SaveScreen = True
End Function
Private Sub Command1_Click()
Call SaveScreen("C:\camoore\Form1.bmp")
End Sub
-
Aug 13th, 2010, 04:18 PM
#5
Thread Starter
Hyperactive Member
Re: printform method - how to save a file?
Thank you, Merri and Hack, for your replies.
You both reminded me of the screensave approach to this problem whereas I had my mind concentrated on trying to intercept the .bmp file which VB passes (according to my book) to the Windows printer.
I am sure that Hack's approach will suit many future more complex applications, but for the present it would for me be overkill. My need is to save one page of straightforward text. It will be easier to write a routine to place the text into a String variable and then to print that to a .txt file. The application requires that memory space occupied be minimised, so a .txt file save will probably be best. There will be no graphics.
Thank you both for your rapid replies. I have saved Hack's code in my code archive for future use.
I will mark the thread as resolved.
Regards,
camoore Wales, UK
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|