Solved

Print screen and file

Posted on 2000-03-30
14
244 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
  • 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

776 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