Solved

Printing bitmaps with RichTextBox

Posted on 1997-12-21
4
196 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

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!

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

747 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

13 Experts available now in Live!

Get 1:1 Help Now