• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 252
  • Last Modified:

Print screen and file

I need to put the print screen of my Vb6 forms in a Txt file, How can i do this.

I the file don't exist, I create this file, else I add at the end of the file the print screen of my forms.

Thanks for your help
0
ceb102298
Asked:
ceb102298
  • 4
  • 4
  • 2
  • +3
1 Solution
 
Erick37Commented:
PrintScreen takes a bitmap snapshot of the screen.  To get the text contained in the form, you need to write the Text or Caption of each control to disk.  Here is an example using the Controls collection.

Private Sub Command1_Click()
    Dim sBuffer As String
    Dim c As Control
    Dim ff As Integer
    'Loop thru the controls and grab the
    'text from each control you want
    For Each c In Controls
        If TypeOf c Is TextBox Then
            sBuffer = sBuffer & c.Text & vbCrLf
        ElseIf TypeOf c Is Label Then
            sBuffer = sBuffer & c.Caption & vbCrLf
        End If
    Next
    'Append the buffer to file
    ff = FreeFile
    On Error GoTo FILEERR
    Open "c:\prntscrn.txt" For Append As #ff
    Print #ff, sBuffer
    Close #ff
    Exit Sub
FILEERR:
    MsgBox Err.Description
End Sub
0
 
ceb102298Author Commented:
I can't put the text of each control in my text file...

I have many forms.

If I can't put the print screen in a text files.....Can i create another type of file with my print screen and some text

Thanks
0
 
Erick37Commented:
You can create a bitmap image of the forms and view them either in a graphics editor, or in your own application with a picturebox.

If you need to save the text of certain controls on the form, you can use the Tag property of the controls as a marker to ID them.  For example, for each control you need to read, set its Tag property to "ReadMe." Then in the loop which reads the controls, if c.Tag = "ReadMe" Then add the text to the file.

Can you explain a little better exactly what you want to see in the text file?  What information is important?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
TheMaskCommented:
Hi Ceb, every form in your project is saved as a .frm file for example form1.frm and so on
This format is a Text format, you can open it with NotePad and you will see it contains every information about your form
0
 
FoyalCommented:
I'm not sure if I get just what you mean. If you want to get the complete data for all the controls you can load all the project files into a file list box then go through the list and parse each file to get all the info.

Sub AppendOuputText(S as string)
   
    'you should know how to do this

End Sub

Sub ParseFormFile(FileName as String)

    Dim v as integer
    Dim strLastData as string
    Dim strNewData as string

    v = FreeFile
   
    Open FileName For Input As #v
   
        Do While Not EOF(v)        
            Line Input #v, strNewData
            If Mid(strNewData,1,15) <> "Option Explicit" Then Exit Do
            AppendOutputText strNewData

        Loop

     Close #v

End Sub
           
0
 
FoyalCommented:
Oooops....

strLastData not used

If Mid(strNewData,1,15) = "Option Explicit" Then Exit Do

0
 
Erick37Commented:
:o Good point TheMask...

ceb, are you talking about runtime forms or development code?
0
 
cymbolicCommented:
You can't really put images of screens in a text file, they aren't text.  If you are just creating documentation, you can use Alt-PrtSc and then paste the images into say, a microsoft word document.  Does this help any, or are we all off base here?
0
 
ceb102298Author Commented:
It's a realy big application. This application as been deliver to the customer.  But i have some bug.

When i have an error, i wan't to do a print screen of my form to see the data enter by the client and the status of the screen.

For example:

I have an error in my application.

I do a printscreen of my actual forms, I put this printscreen in a file rich text format with another text(The description of the error) and save this file on c:\.

Do you have an idea

Thanks

Eric
0
 
j3877Commented:
The only solution I can see is if you were to merely loop through all the controls in the currentform (I can't remember how 2 do it), and then u just have to save it to disk - that, or to use some OCR software on your screenshot... But I don't think that's wot you're talking about...
0
 
j3877Commented:
..WHY NOT USE THE DETAILS OF THE CONTROLS TO CREATE THE .FRM LAYOUT? THEN YOU COULD LOAD IT FROM VB... AND IT WOULD SEEM LIKE PART OF A PROJECT, & WOULD BE EASY TO MODIFY, OR I TOTALLY OFF THE POINT...
0
 
ceb102298Author Commented:
If i can't put my printscreen in a text file....can i create in VB a BMP or a JPG files and put the printscreen of my forms???
0
 
Erick37Commented:
You can copy the bitmap image of your form to the clipboard using code demonstated in this MS article:

"Q240653 - HOWTO: Copy the Screen or Active Window to the Clipboard from Visual Basic"
http://support.microsoft.com/support/kb/articles/Q240/6/53.ASP

Then you can paste the image into a RichTextBox, and save the file to disk.

Two problems to overcome:
1) In order to paste the clipboard data into a rtb control, the control must have focus and you must paste it using SendKeys "^v" (at least that's the only way I could get it to work).
2) The files become very large.  The resulting rtf file I tested was ~450K with only one bitmap.
0
 
ceb102298Author Commented:
Thanks for your help.

Eric
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 4
  • 4
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now