Solved

Printing bitmaps with RichTextBox

Posted on 1997-12-21
4
199 Views
Last Modified: 2011-10-03
The RichTextBox can display OLE objects and pictures but not print them. How can I print them?
0
Comment
Question by:aktis
  • 2
4 Comments
 
LVL 8

Accepted Solution

by:
mrmick earned 100 total points
ID: 1446424
You can use the PictureBox PaintPicture method.
0
 
LVL 4

Expert Comment

by:rantanen
ID: 1446425
mrmick, what does that mean????

The only reasonable way I have found around this problem is to use OLE automation or ShellExecute to print the contents. Not very nice, but works.

An example:

' To forms general section
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

'Eg to a button
Private Sub btnPrint_Click()
    Dim RTFString As Object
    Dim lResult As Long
   
    ' Creates a file to receive the RTF information from the control.
    Open "C:\RTFText.rtf" For Output As 1
   
    ' Places the RTF information from the control into the file and
    ' closes the file.
    Print #1, RichTextBox1.TextRTF
    Close 1
   
    ' Opens the new file in program associated with rtf-extension and prints it.
    lResult = ShellExecute(Me.hwnd, "print", "c:\rtftext.rtf", "", "c:\", 0&)
End Sub

0
 
LVL 1

Author Comment

by:aktis
ID: 1446426
I have a rtf text and inside the text is a picture.
0
 
LVL 8

Expert Comment

by:mrmick
ID: 1446427
Sorry, I figured that out with rantanen's help... at the first glance, I thought you were using a RichTextBox control to display pictures.  Give rantanen's suggestion a try.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
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…
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…

821 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