HELP! RichTextBox Printing

Ok guys,

I know there is someone out there that will be able to help me.


I am trying to print a multiline Rich Text Box that may or may not be multiple pages long. I am using the CommonDialog control to implement this. I have actually tried several different things:

1. Use the CommonDialog.hDC to call RichTextBox.SelPrint(CommonDialog.hDC)

The only problem I have with doing this is that it either never stops spooling to the printer, or nothing ever gets sent to the printer.


2. I tried using the Printer object. AFTER using the CommonDialog control ie:

Printer.Print ""

RichTextBox.SelPrint(Printer.hDC)

Printer.EndDoc


The problem that arrises here is that I am only able to print exactly 46 lines no matter how many more lines the RichTextBox may actually have.


3. I tried just sending the text to the printer:

Printer.Print ""

Printer.Print RichTextBox.text

Printer.EndDoc


Problem: Although it prints everything, I have special formatting that I've done in the RichTextBox that does get printed.


Please! I'm sure someone has an AH HA for me. I'm using VB 5.0 and I've tried all the example code in the help files. Maybe this version has a

problem with the Common Print Dialog??


If you don't mind sending your reply to my email I'd really appreciate it

its william@intersurf.com

Thanks in Advance

William




Comments

  • Okay,

    I've managed to answer my own question this time, and I'm posting the answer in case anyone else out there is intersted.


    I found an article on the microsoft website that says there is an error with the SelPrint method used to print the RTB contents. It

    does not complete the entire contents.

    For anyone interested in a way to get around this check out the artical:

    http://support.microsoft.com/support/kb/articles/Q173/3/62.asp




    : Ok guys,

    : I know there is someone out there that will be able to help me.


    : I am trying to print a multiline Rich Text Box that may or may not be multiple pages long. I am using the CommonDialog control to implement this. I have actually tried several different things:

    : 1. Use the CommonDialog.hDC to call RichTextBox.SelPrint(CommonDialog.hDC)

    : The only problem I have with doing this is that it either never stops spooling to the printer, or nothing ever gets sent to the printer.


    : 2. I tried using the Printer object. AFTER using the CommonDialog control ie:

    : Printer.Print ""

    : RichTextBox.SelPrint(Printer.hDC)

    : Printer.EndDoc


    : The problem that arrises here is that I am only able to print exactly 46 lines no matter how many more lines the RichTextBox may actually have.


    : 3. I tried just sending the text to the printer:

    : Printer.Print ""

    : Printer.Print RichTextBox.text

    : Printer.EndDoc


    : Problem: Although it prints everything, I have special formatting that I've done in the RichTextBox that does get printed.


    : Please! I'm sure someone has an AH HA for me. I'm using VB 5.0 and I've tried all the example code in the help files. Maybe this version has a

    : problem with the Common Print Dialog??


    : If you don't mind sending your reply to my email I'd really appreciate it

    : its william@intersurf.com

    : Thanks in Advance

    : William





Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories