Solved

Print screen and file

Posted on 2000-03-30
14
245 Views
Last Modified: 2012-05-04
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
Comment
Question by:ceb102298
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 2
  • +3
14 Comments
 
LVL 32

Expert Comment

by:Erick37
ID: 2669707
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
 

Author Comment

by:ceb102298
ID: 2669744
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
 
LVL 32

Expert Comment

by:Erick37
ID: 2669874
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
Industry Leaders: 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!

 

Expert Comment

by:TheMask
ID: 2669887
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
 
LVL 3

Expert Comment

by:Foyal
ID: 2669890
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
 
LVL 3

Expert Comment

by:Foyal
ID: 2669898
Oooops....

strLastData not used

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

0
 
LVL 32

Expert Comment

by:Erick37
ID: 2669932
:o Good point TheMask...

ceb, are you talking about runtime forms or development code?
0
 
LVL 9

Expert Comment

by:cymbolic
ID: 2670408
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
 

Author Comment

by:ceb102298
ID: 2670511
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
 
LVL 1

Expert Comment

by:j3877
ID: 2670609
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
 
LVL 1

Expert Comment

by:j3877
ID: 2670619
..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
 

Author Comment

by:ceb102298
ID: 2673035
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
 
LVL 32

Accepted Solution

by:
Erick37 earned 200 total points
ID: 2673625
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
 

Author Comment

by:ceb102298
ID: 2674037
Thanks for your help.

Eric
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question