Solved

Print screen and file

Posted on 2000-03-30
14
242 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 

Expert Comment

by:TheMask
Comment Utility
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
Comment Utility
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
Comment Utility
Oooops....

strLastData not used

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

0
 
LVL 32

Expert Comment

by:Erick37
Comment Utility
:o Good point TheMask...

ceb, are you talking about runtime forms or development code?
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 9

Expert Comment

by:cymbolic
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
..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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks for your help.

Eric
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now