.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 21st, 2005, 05:10 AM
Silje Silje is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Posts: 1 Silje User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m
Reputation Power: 0
Display picture and image in the same component

Hello

I need a little help with some text and image problems.

- How can I display image and text in the same component and print both.

I have tried to do like this:
Insert image and text into a richTextBox

Sub InsertImageIntoRtb(ByVal rtb As RichTextBox, ByVal img As Image)
Clipboard.SetDataObject(img)
rtb.Paste()
End Sub

Sub InsertImageIntoRtb(ByVal rtb As RichTextBox, ByVal imgPath As String)
Try
Dim img As New System.Drawing.Bitmap(imgPath)
InsertImageIntoRtb(rtb, img)
Catch ex As Exception

End Try
End Sub

Insert image
InsertImageIntoRtb(ricUtleie, Application.StartupPath() & "\xxx.gif")

It works ok, but when I try to print I only get the text on the paper and not my image.

I use this code to print.

PrintDocument1.Print()

Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
'PrintPage is the foundational printing event. This event gets fired for every
' page that will be printed
Static intCurrentChar As Int32
' declaring a static variable to hold the position of the last printed char
Dim font As New Font("Verdana", 14)
' initializing the font to be used for printing
Dim PrintAreaHeight, PrintAreaWidth, marginLeft, marginTop As Int32
With PrintDocument1.DefaultPageSettings
' initializing local variables that contain the bounds of the printing area rectangle
PrintAreaHeight = .PaperSize.Height - .Margins.Top - .Margins.Bottom
PrintAreaWidth = .PaperSize.Width - .Margins.Left - .Margins.Right
' initializing local variables to hold margin values that will serve
' as the X and Y coordinates for the upper left corner of the printing
' area rectangle.
marginLeft = .Margins.Left
marginTop = .Margins.Top
' X and Y coordinate
End With

If PrintDocument1.DefaultPageSettings.Landscape Then
Dim intTemp As Int32
intTemp = PrintAreaHeight
PrintAreaHeight = PrintAreaWidth
PrintAreaWidth = intTemp
' if the user selects landscape mode, swap the printing area height and width
End If

Dim intLineCount As Int32 = CInt(PrintAreaHeight / font.Height)
' calculating the total number of lines in the document based on the height of
' the printing area and the height of the font
Dim rectPrintingArea As New RectangleF(marginLeft, marginTop, PrintAreaWidth, PrintAreaHeight)
' initializing the rectangle structure that defines the printing area
Dim fmt As New StringFormat(StringFormatFlags.LineLimit)
'instantiating the StringFormat class, which encapsulates text layout information
Dim intLinesFilled, intCharsFitted As Int32
e.Graphics.MeasureString(Mid(ricUtleie.Text, intCurrentChar + 1), font, New SizeF(PrintAreaWidth, PrintAreaHeight), fmt, intCharsFitted, intLinesFilled)

' calling MeasureString to determine the number of characters that will fit in
' the printing area rectangle
e.Graphics.DrawString(Mid(ricUtleie.Text, intCurrentChar + 1), font, Brushes.Black, rectPrintingArea, fmt)
' print the text to the page
intCurrentChar += intCharsFitted
'advancing the current char to the last char printed on this page
If intCurrentChar < ricUtleie.Text.Length Then
e.HasMorePages = True
'HasMorePages tells the printing module whether another PrintPage event should be fired
Else
e.HasMorePages = False
intCurrentChar = 0
End If
End Sub

Thanks for you help in advance

Silje

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgramming.NET Development > Display picture and image in the same component


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT