Link to home
Start Free TrialLog in
Avatar of aomega
aomega

asked on

Print Properties

I've got a RTF (Rich text Box) that I use to print some text I have.
Here's some of the code:

RichTextBox1.TextRTF = string1
CommonDialog1.ShowPrinter
Printer.Print (RichTextBox1.Text)

When I print it,  it looks really really ugly...
How do I adjust the properties so It can print in the margins, and other stuff like that.

Avatar of AzraSound
AzraSound
Flag of United States of America image

Hello aomega,
Please see this article for how to accomplish this task

Good Luck!

http://www.vbweb.co.uk/controls/rich_text_box_wysiwyg.htm
ASKER CERTIFIED SOLUTION
Avatar of Ark
Ark
Flag of Russian Federation image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
'Text from *.hlp file for sample above
'---------------------------
SelPrint Method:
'---------------------------
Sends formatted text in a RichTextBox control to a device for printing.

Syntax

object.SelPrint(hdc)

The SelPrint method syntax has these parts:

Part      Description
object      An object expression that evaluates to an object in the Applies To list.
hdc      The device context of the device you plan to use to print the contents of the control.
Remarks

If text is selected in the RichTextBox control, the SelPrint method sends only the selected text to the target device. If no text is selected, the entire contents of the RichTextBox are sent to the target device.
The SelPrint method does not print text from the RichTextBox control. Rather, it sends a copy of formatted text to a device which can print the text. For example, you can send the text to the Printer object using code as follows:

RichTextBox1.SelPrint(Printer.hDC)

Notice that the hDC property of the Printer object is used to specify the device context argument of the SelPrint method.

Note   If you use the Printer object as the destination of the text from the RichTextBox control, you must first initialize the device context of the Printer object by printing something like a zero-length string.
Hello Ark,
Yes it does have its own print method but it still does not handle margins automatically
Hello AzraSound,
If <RichTextBox1.TextRTF = string1>, I thing, standard method is enough. I didn't check your link yet, but I thing its code base on famous <smile> MS code http://support.microsoft.com/support/kb/articles/Q146/0/22.asp. All samples I've seen at the Web are the same with some additional controls (buttons, checkboxes etc.)
Cheers
Indeed Ark it is an extract from the MS article.  However experience I have had with RTF requires I use the code for WYSIWYG printing.  Otherwise my margins are also lost in the print.
It's Microsoft solution - to make OCX (or anything other) and then issue numerous SPs or PRB articles. Why don't try vbaccelerator richtextcontrol wich based on new RichEd20.dll with many new futures.
Cheers