Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I print the code comments in color on a printer 2

Status
Not open for further replies.

gwigton

Programmer
Jul 23, 2002
52
US
Ok, I am trying to set up my VB 6.0 so that when I am printing my code to a color printer, I can quickly see my comment lines by having them print in the same color that my screen is showing the comment in. Is there any way to accomplish this?

Thanks,
gwigton
 

The easiest way I can think of is to create a RTF file and save and print it.
 
I have tried to save it both as a .rtf format and also copy and paste into a .doc, but the comments still show up in black text both on the screen and on the print-out. You would think there would be an easy solution to this issue, but I am still scratching my head.
 

[tt]'This is a comment in green (I am using TGML for this site)
If ThisWereAVariable = Black Then [/tt]

The first thing you would need to do is parse out your code file and load it into a RTB (RichTextBox). Then you would need to find or parse the text looking for specific symbols "'" or keywords (as above). Then once you have used the selstart and sellength properties to highlight the text you want to change color you set its color. Once this is done for the whole file you would save the file to disk then shell out word to print it.

I can also suggest that you search this site for "RTB" or "RichTextBox" you will find several solutions that will meet your needs.

I hope this helps you in your quest!

Good Luck
 
Well, seems to me that what you need is the very good PrettyCode.Print Add-In available here:


It is free, works like a charm, it is often updated. Have been using for a while and cannot do without it anymore.

Giorgio
 
Thanks gvidali!

PrintCode.Pretty worked great. This really makes reading printed code a lot easier.

Thanks Again!
 

For anybody who wants to build their own you can take the hints from my previous post disreguarding the saving the file and shelling out word and then use

[tt]RTB.SelStart = 0
RTB.SelLength = Len(RTB.TextRTF)
RTB.SelPrint Printer.hDC
[/tt]

This will print out the colors that you define for each character, word, line, etc. (and if you are using a B&W printer you will see shades of grey for some colors).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top