Hi,
Does anyone know how print an entire form in Visual Basic 6? I need to be able to resize the form so it prints on one page.
13 1746
Hi,
Try form1.printform. But before executing this, change the form color to white. So that it will not waste ink... ^^
Regards,
Jeff
Yes, it really comes down to one of two choices - PrintForm, or "roll your own". Though I do recall from some years back that creating your own equivalent of PrintForm is not that hard. The problem with PrintForm, of course, is that (if I remember correctly) it prints at screen resolution, and loses lots of detail. By running through the controls on the form and printing them yourself, I think you can get around that.
(Or maybe you can buy some sort of printing software that will handle it, but that seems rather a waste.)
Hi,
I tried the PrintForm but it cuts off half of my form. You suggested for me to create my own equivalent to PrintForm, do you have any ideas how to go about that? I tried looking for examples online but couldn't really find anything that would fit my needs.
Yes, it really comes down to one of two choices - PrintForm, or "roll your own". Though I do recall from some years back that creating your own equivalent of PrintForm is not that hard. The problem with PrintForm, of course, is that (if I remember correctly) it prints at screen resolution, and loses lots of detail. By running through the controls on the form and printing them yourself, I think you can get around that.
(Or maybe you can buy some sort of printing software that will handle it, but that seems rather a waste.)
To be more specific about my problem I will paste some sample code that I am using: - Private Sub Command1_Click()
-
-
Form1.PrintForm
-
-
End Sub
-
-
Private Sub Form_Load()
-
-
MSFlexGrid1.Width = 5870
-
MSFlexGrid1.Top = 840
-
MSFlexGrid1.Left = 4800
-
MSFlexGrid1.Height = 11655
-
-
MSFlexGrid1.Col = 2
-
MSFlexGrid1.Row = 23
-
MSFlexGrid1.CellBackColor = &HFFFFC0
-
'initial settings when form is loaded
-
Label1.FontSize = 23
-
Label1.Caption = "Data"
-
Label1.FontName = "Times New Roman"
-
Label1.BackColor = &H8000000F
-
'Label2.Alignment = 0
-
Label1.Width = MSFlexGrid1.Width
-
Label1.Height = 600
-
Label1.Top = MSFlexGrid1.Top - 100 - Label1.Height
-
Label1.ForeColor = &HFF&
-
-
Label2.Caption = "TEST"
-
Label2.FontSize = 20
-
Label2.FontName = "Times New Roman"
-
Label2.Alignment = 0
-
Label2.Width = 4250
-
Label2.Height = 450
-
Label2.Top = MSFlexGrid1.Top + MSFlexGrid1.Height
-
Label2.ForeColor = &HFF&
-
Label2.BackColor = &H8000000F
-
-
For i = 0 To 23
-
MSFlexGrid1.RowHeight(i) = 2 * MSFlexGrid1.RowHeight(i)
-
Next i
-
-
For i = 0 To 3
-
MSFlexGrid1.ColWidth(i) = 1.5 * MSFlexGrid1.ColWidth(i)
-
Next i
-
-
MSFlexGrid1.TextMatrix(0, 1) = "Size range"
-
MSFlexGrid1.TextMatrix(0, 2) = "m"
-
MSFlexGrid1.TextMatrix(0, 3) = "a"
-
MSFlexGrid1.TextMatrix(1, 0) = "d"
-
MSFlexGrid1.TextMatrix(1, 1) = "k"
-
MSFlexGrid1.TextMatrix(1, 2) = "s"
-
MSFlexGrid1.TextMatrix(1, 3) = "t"
-
MSFlexGrid1.TextMatrix(23, 1) = "Sum"
-
-
End Sub
-
-
Private Sub Form_Resize()
-
'make sure everything is centered when form is resized
-
-
Label1.Left = (Form1.Width / 2) - (Label1.Width / 2)
-
MSFlexGrid1.Left = (Form1.Width / 2) - (MSFlexGrid1.Width / 2)
-
Label2.Left = MSFlexGrid1.Left
-
-
End Sub
I have one MSFlexGrid that has 24 rows and 4 columns and I have 2 labels and one Print button. I want to print it exacly as shown on the screen once the program is run.
Yes, it really comes down to one of two choices - PrintForm, or "roll your own". Though I do recall from some years back that creating your own equivalent of PrintForm is not that hard. The problem with PrintForm, of course, is that (if I remember correctly) it prints at screen resolution, and loses lots of detail. By running through the controls on the form and printing them yourself, I think you can get around that.
(Or maybe you can buy some sort of printing software that will handle it, but that seems rather a waste.)
I did see a sample to print all the controls on a form, probably more than ten years ago now. At lunch time (maybe 4 hours from now) I'll see whether I can find (or create) something.
Sorry, nothing yet. Stay tuned...
I've found a print preview example for VB which provides some helpful info, but not the actual printform equivalent. I know I had one somewhere...
I've found a print preview example for VB which provides some helpful info, but not the actual printform equivalent. I know I had one somewhere...
Have you found anything? I've been looking and can't find too much.
Have you found anything? I've been looking and can't find too much.
Not yet - sorry. Might have to build one. I was just thinking of a loop through the controls on the form, printing each of them to the printer. The difficulaties, I suppose, would lie in how to reproduce the look of things like textboxes whose text is longer than the box.
Keep looking though, I'm sure there's already something out there - I know I saw it, early in my VB days (probably more than 10 years ago).
Not yet - sorry. Might have to build one. I was just thinking of a loop through the controls on the form, printing each of them to the printer. The difficulaties, I suppose, would lie in how to reproduce the look of things like textboxes whose text is longer than the box.
Keep looking though, I'm sure there's already something out there - I know I saw it, early in my VB days (probably more than 10 years ago).
I decided to try and use the printer object. I have a text box that has a blue background and the text inside is right justified. With the printer object i've only found a way to print the text inside the text box but not the textbox as a whole. Do you have any idea how to do this?
I decided to try and use the printer object. I have a text box that has a blue background and the text inside is right justified. With the printer object i've only found a way to print the text inside the text box but not the textbox as a whole. Do you have any idea how to do this?
(Sorry, haven't had a chance to get back to this.)
I suppose you might just have to draw a box, with the appropriate border, and set the fill colour to match the background of the textbox. Probably using a generic "print this textbox" routine. One thing I recall is that back when I was playing around with all this print preview stuff, colour printing wasn't something that had to be considered.
By the way, if you search M$'s website for something like "add print preview to basic application" they have complete code there to implement print preview. They have versions for... um, I think VB3 and VB5. The latter should also work in VB6.
This won't directly solve your form printing problem, but it's very useful to have, and if you are going to build a form print solution, the preview capability will make it much quicker (and cheaper!) to test as you go. One thing I have always found about printing is that it takes a lot of trial and error.
(Sorry, haven't had a chance to get back to this.)
I suppose you might just have to draw a box, with the appropriate border, and set the fill colour to match the background of the textbox. Probably using a generic "print this textbox" routine. One thing I recall is that back when I was playing around with all this print preview stuff, colour printing wasn't something that had to be considered.
By the way, if you search M$'s website for something like "add print preview to basic application" they have complete code there to implement print preview. They have versions for... um, I think VB3 and VB5. The latter should also work in VB6.
This won't directly solve your form printing problem, but it's very useful to have, and if you are going to build a form print solution, the preview capability will make it much quicker (and cheaper!) to test as you go. One thing I have always found about printing is that it takes a lot of trial and error.
Yeah i agree with you there, ALOT OF TRIAL AND ERROR. I did happen to find something on this website :
http://support.microsoft.com/?kbid=161299
It really helps with what I am doing because it can capture the entire client area and fit it to one page when printing. It does come out a little blurry though, do you have any idea why this is? It seems that all the different printing techniques I have tried so far all seem to come out blurry.
... It does come out a little blurry though, do you have any idea why this is? It seems that all the different printing techniques I have tried so far all seem to come out blurry.
I believe this is a pretty common problem, related to the relatively low resolution of the screen. Even a pretty basic printer these days will probably produce 300 dots per inch. A typical screen, on the other hand, shows something on the order of 72 dpi (possibly higher nowadays). So obviously in capturing the screen, you aren't going to get the same sort of resolution you're used to seeing printed.
That's why "drawing" things on the printer generally produces much better results than dumping an image direct from the screen.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jody Gelowitz |
last post by:
I am having a problem with printing selected pages. Actually, the problem
isn't with printing selected pages as it is more to do with having blank
pages print for those pages that have not been...
|
by: Programatix |
last post by:
Hi,
I am working on the PrintDocument, PrintDialog, PageSetupDialog and
PrintPreviewControl components of Visual Studio .NET 2003. My developement
machine is running Windows XP.
There are...
|
by: Jody Gelowitz |
last post by:
I am trying to find the definition of "Safe Printing" and cannot find out
exactly what this entitles. The reason is that I am trying to print
contents from a single textbox to no avail using the...
|
by: Suzanka |
last post by:
Hello,
I have an application written in C# on visual studio .NET. It is a web
aplication.
The application consists of many different forms, that users
occassionaly want to print out for filing....
|
by: Arif |
last post by:
I C# code prints very slow as compared to a third party barcode printing
software. That software prints approximately 10 labels in 2 seconds while my
C# code prints 10 labels in 5 to 6 seconds. And...
|
by: Siv |
last post by:
Hi,
I am getting into printing with VB.NET 2005 and want to implement the usual
capability that a user can select a selection of pages. I have a report
that is generated by my application that if...
|
by: Neo Geshel |
last post by:
Greetings.
BACKGROUND:
My sites are pure XHTML 1.1 with CSS 2.1 for markup. My pages are
delivered as application/xhtml+xml for all non-MS web clients, and as
text/xml for all MS web...
|
by: nikhilgargi |
last post by:
Requirement:
I need to provide printing capability in a C# desktop application that I am developing
The documents that need to be printed can be in Rich Text Format (RTF) or HTML. Custom...
|
by: Brett |
last post by:
I have an ASP.NET page that displays work orders in a GridView. In that
GridView is a checkbox column. When the user clicks a "Print" button, I
create a report, using the .NET Framework printing...
|
by: it0ny |
last post by:
Hi guys,
thanks I am fairly new to this forum so I hope I chose the right place to post this question.
I try to make my program printout a deposit's report. I created a class to store the...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |