Results 1 to 5 of 5

Thread: [RESOLVED] printform method - how to save a file?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    403

    Resolved [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

  2. #2
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    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.?

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    403

    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.

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: printform method - how to save a file?

    Try this
    vb Code:
    1. Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, _
    2. ByVal bScan As Byte, _
    3. ByVal dwFlags As Long, _
    4. ByVal dwExtraInfo As Long)
    5.  
    6. Private Const VK_SNAPSHOT = &H2C
    7.  
    8.  
    9. Private Function SaveScreen(ByVal theFile As String) As Boolean
    10.  
    11. 'To get the Entire Screen
    12. 'Call keybd_event(vbKeySnapshot, 1, 0, 0) 'from what you say you don't want this, but I give it in
    13.                                           'case you may want it sometime
    14.  
    15. 'To get the Active Window
    16. Call keybd_event(vbKeySnapshot, 0, 0, 0) 'this sounds like it is what you are after
    17.  
    18. SavePicture Clipboard.GetData(vbCFBitmap), theFile
    19.  
    20. SaveScreen = True
    21. End Function
    22.  
    23. Private Sub Command1_Click()
    24. Call SaveScreen("C:\camoore\Form1.bmp")
    25. End Sub

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    403

    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
  •  



Click Here to Expand Forum to Full Width