Visual Basic Problem??

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Aug 2008
Posts: 30
Reputation: ChroNoS is an unknown quantity at this point 
Solved Threads: 0
ChroNoS ChroNoS is offline Offline
Light Poster

Visual Basic Problem??

 
0
  #1
Sep 15th, 2008
I have written a program that reads a text file and then saves it as an image file.Although the program is reading the file but its having errors saving it as an image file. Please Help!
Option Explicit

Private Const SRCCOPY = &HCC0020
Private Const MERGEPAINT = &HBB0226
Private Const SRCAND = &H8800C6
Private Const DIB_RGB_COLORS = 0
Private Const DIB_PAL_COLORS = 1

Private Declare Function BitBlt Lib "gdi32" _
  (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, _
  ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, _
  ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long

Dim nRet As Long
Private Sub Command1_Click()
'Outline:- Asks the user for a file.
'- Reads all the data into Text1.

Dim FilePath As String
Dim Data As String

FilePath = InputBox("Enter the path for a text file", "The Two R's", _
"D:\address.txt")
'Asks the user for some input via an inp
' ut box.

Open FilePath For Input As #1
'Opens the file given by the user.

Do Until EOF(1)
'Does this loop until ' f>End Of File(' >EOF) for file number 1.
Line Input #1, Data
'Read one line and puts it into the vari
' ble Data.
Text1.Text = Text1.Text & vbCrLf & Data
'Adds the read line into Text1.
MsgBox EOF(1)
Loop

Close #1
'Closes this file.
End Sub

Private Sub Command2_Click()

  pic.Visible = True
  pic.Height = Text1.Height
  pic.Width = Text1.Width

nRet = BitBlt(pic.hDC, 0, 0, Text1.Width - 2, Text1.Height - 2, Me.hDC, Text1.Left + 1, Text1.Top + 1, SRCCOPY)
  pic.Picture = pic.Image
  SavePicture pic.Image, "text.bmp"
  pic.Visible = False
  Text1.SetFocus
  
End Sub
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 71
Reputation: venkatramasamy is an unknown quantity at this point 
Solved Threads: 12
venkatramasamy's Avatar
venkatramasamy venkatramasamy is offline Offline
Junior Poster in Training

Re: Visual Basic Problem??

 
0
  #2
Sep 16th, 2008
HI,

Kindly Furnish the error Details...

-venkat
I Learned from my Mistakes and I learned Lot!
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 30
Reputation: ChroNoS is an unknown quantity at this point 
Solved Threads: 0
ChroNoS ChroNoS is offline Offline
Light Poster

Re: Visual Basic Problem??

 
0
  #3
Sep 16th, 2008
Originally Posted by venkatramasamy View Post
HI,

Kindly Furnish the error Details...

-venkat
There are no errors. Its just that I want to capture the details in the textbox and it is capturing the portion of the screen somewhere out of it.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 530
Reputation: selvaganapathy is an unknown quantity at this point 
Solved Threads: 91
selvaganapathy's Avatar
selvaganapathy selvaganapathy is offline Offline
Posting Pro

Re: Visual Basic Problem??

 
0
  #4
Sep 16th, 2008
Hi, Instead of using BitBlt() function,you can directly print inside the picture box (using pic.print method) when you reading from the file. Also set AutoRedraw property to true.
Selva
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 30
Reputation: ChroNoS is an unknown quantity at this point 
Solved Threads: 0
ChroNoS ChroNoS is offline Offline
Light Poster

Re: Visual Basic Problem??

 
0
  #5
Sep 16th, 2008
Originally Posted by selvaganapathy View Post
Hi, Instead of using BitBlt() function,you can directly print inside the picture box (using pic.print method) when you reading from the file. Also set AutoRedraw property to true.
Okay, Can you tell me how am I supposed to do that?
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 530
Reputation: selvaganapathy is an unknown quantity at this point 
Solved Threads: 91
selvaganapathy's Avatar
selvaganapathy selvaganapathy is offline Offline
Posting Pro

Re: Visual Basic Problem??

 
0
  #6
Sep 16th, 2008
Ok, I give an example.

In a form
> Draw a Picture box (Picture1)
> Draw a Command Button (Command1)

  1. Private Sub Command1_Click()
  2. Picture1.AutoRedraw = True
  3.  
  4. Picture1.Print "Welcome"
  5. Picture1.Print "To"
  6. Picture1.Print "VB6"
  7.  
  8. SavePicture Picture1.Image,"C:\Test.jpg"
  9. End Sub
Selva
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 30
Reputation: ChroNoS is an unknown quantity at this point 
Solved Threads: 0
ChroNoS ChroNoS is offline Offline
Light Poster

Re: Visual Basic Problem??

 
0
  #7
Sep 16th, 2008
Originally Posted by selvaganapathy View Post
Ok, I give an example.

In a form
> Draw a Picture box (Picture1)
> Draw a Command Button (Command1)

  1. Private Sub Command1_Click()
  2. Picture1.AutoRedraw = True
  3.  
  4. Picture1.Print "Welcome"
  5. Picture1.Print "To"
  6. Picture1.Print "VB6"
  7.  
  8. SavePicture Picture1.Image,"C:\Test.jpg"
  9. End Sub
Thanx!!!!!!!! That just solved my problem. But there is one last thing
I want to put a lot of text in the textbox which is supposed to be captured. But the textbox does not resize to the text, Although it can show scrollbars. I want it to grow as big to fit the whole text on the screen no matter how big the text is.
Is there any way it can resize itself automatically to fit the whole text?
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 530
Reputation: selvaganapathy is an unknown quantity at this point 
Solved Threads: 91
selvaganapathy's Avatar
selvaganapathy selvaganapathy is offline Offline
Posting Pro

Re: Visual Basic Problem??

 
0
  #8
Sep 16th, 2008
Do you mean ? When you give large amount of text, Its font size should be adjusted to fit into it?
Selva
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 30
Reputation: ChroNoS is an unknown quantity at this point 
Solved Threads: 0
ChroNoS ChroNoS is offline Offline
Light Poster

Re: Visual Basic Problem??

 
0
  #9
Sep 17th, 2008
Originally Posted by selvaganapathy View Post
Do you mean ? When you give large amount of text, Its font size should be adjusted to fit into it?
Yeah, that should do
And also if i give small text the picture box should adjust its size according to the text so to fit it.
Last edited by ChroNoS; Sep 17th, 2008 at 7:43 am.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 530
Reputation: selvaganapathy is an unknown quantity at this point 
Solved Threads: 91
selvaganapathy's Avatar
selvaganapathy selvaganapathy is offline Offline
Posting Pro

Re: Visual Basic Problem??

 
0
  #10
Sep 17th, 2008
May be Picture1.TextHeight() and Picture1.TextWidth() help you to predict the font size
Selva
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum


Views: 1841 | Replies: 12
Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC