Re: VB Printer Dialog Problem (VB6)
- From: "Mike Williams" <Mike@xxxxxxxxxxxxxxxxx>
- Date: Sat, 1 Jul 2006 17:30:23 +0100
<andy.vandierendonck@xxxxxxxxxx> wrote in message news:1151766701.576251.58240@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
It's a lot to post if I want to show my print routine. I use own sub
routine's and functions that I've placed in a public bas module
I don't really want to see your entire print routine. In fact I'd much sooner see "a written explanation" than code. I don't like code :-)
What I would really like to know is exactly what it is you are printing? None of the code you have posted shows that. There isn't a single Print statement in your code (except for the initial Print statement to open the printer object). Can you explain in simple terms where you are getting the stuff to print? Is it all "built into" the program at design time, or is it all provided by the user at run time? Or is is perhaps a combination of both? If some or all of it is provided by the user at runtime, then how are you "collecting it" from the user? Is he entering stuff into a text box? Or perhaps into a RichTextBox? Also, are you printing just text? Or is there is something else as well (graphics or whatever)? And how are you breaking long paragraphs of text into individual lines of text to send to the printer? Are you using simple Printer.Print statements to print each line of text individually? Or are you perhaps using the DrawText API to print blocks of text into a specified rectangle on the page? Or are you perhaps breaking paragraphs of text into individual lines suitable for printing using your own code? There are so many possibilities and I find it very difficult to help you unless you give me answers to some or preferably all of the questions I have asked.
First let the my print routine run on an userform, because
almost every properties in the printer object are also available
in the userform properties
Nope. I'm afraid it doesn't work like that. Forms and printers have very different resolutions (typically 96 pixels per inch in the case of a Form and 600 pixels per inch in the case of a printer). Font sizes can only be in "whole pixel values", so when you ask for (say) an 11 point font on a specific device the operating system will examine the "pixels per inch" of that device and will give you the nearest font size it can, to the nearest whole pixel value. Typically, if you request an 11 point True Type font on a Form you will actually get 11.25 points, and on a printer you might get something like 11.04 points. And that is just a small part of it. There are lots of other reasons why you simply cannot treat the printer and the screen (or anything on the screen) equally. If you want to write code to split blocks of text into individual lines of a length suitable for printing then you need to do so using the TextWidth property of the target device (the printer). Don't get too worried though. This kind of stuff can definitely be done, but I can't really suggest the mest way to do it until I know exactly what it is you are printing and where you are getting the data from.
But I just was wondering if it was possible to run
print commands without the printer receive it, such
as block the printer.
Depends what you are doing. If you are using a RichTextBox then it is very easy to do that. If not then you can write code to examine sections (perhaps paragraphs) of text to establish how to best split it into individual lines to send them to the printer without actually doing so (check out the Printer.TextWidth function). Alternatively, you can use the DrawText API to format and print a block of text within any specified rectangle on the page, and if you just want to know the size of the printed block without actually printing it you can do so using the DT_CALCRECT flag. That is only useful for standard text though, and not text that might include different size fonts and bold and italic and stuff. Perhaps the easiest way (especially if you are just printing text) is to place all the text for the entire print job into a RichTextBox. That will of course allow you to have different fonts and font styles. You can then instruct the RichTextBox to print the text to the printer using whatever left, right, top and bottom page margins you desire, and you can include separate "headers and footers" as desired on each page. You can also do exactly the same thing, but instruct the RichTextBox to just "pretend to be sending it to the printer", so that you can tell exactly how many pages are involved before you actually perform the print job. Then after you have done that you can call exactly the same routine again, but this time actually sending it to the printer. This of course allows you to have footers such as "Page 2 of 5" and stuff like that. But as I've said I can't really help you until I know exactly what you are doing.
Post again. Don't worry about posting lots of code. In fact I'd sooner not read through lots of code. Just explain, in ordinary words and in great detail, exactly what it is you are doing. The more you tell us the better.
Mike
.
- Follow-Ups:
- Re: VB Printer Dialog Problem (VB6)
- From: andy . vandierendonck
- Re: VB Printer Dialog Problem (VB6)
- References:
- Re: VB Printer Dialog Problem (VB6)
- From: andy . vandierendonck
- Re: VB Printer Dialog Problem (VB6)
- Prev by Date: Re: VB Printer Dialog Problem (VB6)
- Next by Date: Re: qodbc driver
- Previous by thread: Re: VB Printer Dialog Problem (VB6)
- Next by thread: Re: VB Printer Dialog Problem (VB6)
- Index(es):
Relevant Pages
|