Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Printing in VB6
I have a few questions about printing in VB 6.

1) How do I determine how many lines of a font will fit on a page?
Obviously, there will be less lines of 24 font on a page than 12 font. It
would also depend on the font type and letter. An i is not as wide as a w.
Are there any methods for calculating this or is it just trial and error?

2) How can I add a picutre to the page to print? I have a few bitmaps and
gif's that I would like to add.

3) Is there a way to preview what I am about to print? I can easily waste a
lot of papper.

4) Can I set the font of one line to be bold and 16 and the next line to be
12 and regular font? Before I was setting the font with Printer.Fontbold =
true. Then I changed it to Printer.Fontbold = false. The whole document was
not bold - I wanted the first part to be bold. Can sections of the page have
different fonts in VB6? Or was I doing something wrong?

Thanks for the help.

Report this thread to moderator Post Follow-up to this message
Old Post
Jonathan
10-27-04 08:55 PM


Re: Printing in VB6
Jonathan wrote:
> I have a few questions about printing in VB 6.
>
> 1) How do I determine how many lines of a font will fit on a page?
> Obviously, there will be less lines of 24 font on a page than 12 font. It
> would also depend on the font type and letter. An i is not as wide as a w.
> Are there any methods for calculating this or is it just trial and error?

To measure a single line, you can use the printer's TextHeight method.

> 2) How can I add a picutre to the page to print? I have a few bitmaps and
> gif's that I would like to add.

No experience... but see the 'HOWTO' article below.

> 3) Is there a way to preview what I am about to print? I can easily waste 
a
> lot of papper.

There are a whole bunch of Print Preview components on
planetsourcecode.com ..

> 4) Can I set the font of one line to be bold and 16 and the next line to b
e
> 12 and regular font? Before I was setting the font with Printer.Fontbold =
> true. Then I changed it to Printer.Fontbold = false. The whole document wa
s
> not bold - I wanted the first part to be bold. Can sections of the page ha
ve
> different fonts in VB6? Or was I doing something wrong?

We use some of this code for printing. Basically, write the text to a
RichTextBox (multi font support built in) and then dump that box to the
printer.

HOWTO: Set Up the RichTextBox Control for WYSIWYG Printing
http://support.microsoft.com/defaul...kb;en-us;146022

> Thanks for the help.

--
Ken Halter - MS-MVP-VB - http://www.vbsight.com
Please keep all discussions in the groups..

Report this thread to moderator Post Follow-up to this message
Old Post
Ken Halter
10-27-04 08:55 PM


Re: Printing in VB6
"Jonathan" <Jonathan@discussions.microsoft.com> wrote
> I have a few questions about printing in VB 6.
>
> 1) How do I determine how many lines of a font will fit on a page?
> Obviously, there will be less lines of 24 font on a page than 12 font. It
> would also depend on the font type and letter. An i is not as wide as a w.
> Are there any methods for calculating this or is it just trial and error?

Set up the device with the correct font, and use its TextWidth and TextHeigh
t
properties to measure various strings.  While width can vary in a non-propor
tional
font, the height usually does not, so getting the total lines should be a si
mple
calculation, dividing the ScaleHeight of the device, by the TextHeight of a 
line.


> 2) How can I add a picutre to the page to print? I have a few bitmaps and
> gif's that I would like to add.

The printer supports the PaintPicture method.



> 3) Is there a way to preview what I am about to print? I can easily waste 
a
> lot of papper.

How about directing your printing to a picturebox first?


>
> 4) Can I set the font of one line to be bold and 16 and the next line to b
e
> 12 and regular font? Before I was setting the font with Printer.Fontbold =
> true. Then I changed it to Printer.Fontbold = false. The whole document wa
s
> not bold - I wanted the first part to be bold. Can sections of the page ha
ve
> different fonts in VB6? Or was I doing something wrong?

The Print command should reflect whatever the current settings are.
Although its an iterative process:  Print/change/print/change/print ... etc.
.

LFS



Report this thread to moderator Post Follow-up to this message
Old Post
Larry Serflaten
10-27-04 08:55 PM


Re: Printing in VB6
I "fooled around" a lot with creating a "print-preview" and finally
just gave up and print to a PDFand look at the result.  Lots of free
PDF drivers available (PDF995)




On Wed, 27 Oct 2004 11:53:26 -0500, "Larry Serflaten"
<serflaten@usinternet.com> wrote:

>
>"Jonathan" <Jonathan@discussions.microsoft.com> wrote 
>
>Set up the device with the correct font, and use its TextWidth and TextHeig
ht
>properties to measure various strings.  While width can vary in a non-propo
rtional
>font, the height usually does not, so getting the total lines should be a s
imple
>calculation, dividing the ScaleHeight of the device, by the TextHeight of a
 line.
>
> 
>
>The printer supports the PaintPicture method.
>
>
> 
>
>How about directing your printing to a picturebox first?
>
> 
>
>The Print command should reflect whatever the current settings are.
>Although its an iterative process:  Print/change/print/change/print ... etc
..
>
>LFS
>



Report this thread to moderator Post Follow-up to this message
Old Post
Lee Peedin
10-27-04 08:55 PM


Re: Printing in VB6
On Wed, 27 Oct 2004 13:53:28 -0400, Lee Peedin
<lee@DONOTSPAMMEsafedatausa.com> wrote:

>I "fooled around" a lot with creating a "print-preview" and finally
>just gave up and print to a PDFand look at the result.  Lots of free
>PDF drivers available (PDF995)

If you can write code to print to the Printer, then that code needs
very little modification to print to a Picturebox


Report this thread to moderator Post Follow-up to this message
Old Post
J French
10-29-04 01:55 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Visual Basic archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:52 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.