Hi,
I have recently added some code to my form in regards to resizing an image on Print. I have an image that does print correctly after its been resized, howver i'm needing to use it as a backgound image which will have variable text written in front of it. I am having trouble geting labels and text boxes to print, along with the inlarged image that is printing. The labels and text boxes need to appear infront of the image.
And where do I place the necessary code?
Please help!! Urgently needed!
My code currently looks like this: Private Sub cmdPrint_Click()
Printer.PaperSize = 3
'Print the image loaded in Picture1 (double size)
PrintImage Image1.Picture, , , 1#
End Sub
------------------------------
'Print the Picture contained in a PictureBox or a Form
Public Sub PrintImage(p As IPictureDisp, Optional ByVal x, Optional ByVal y, Optional ByVal resize)
If IsMissing(x) Then x = Printer.CurrentX
If IsMissing(y) Then y = Printer.CurrentY
If IsMissing(resize) Then resize = 1
Printer.PaintPicture p, x, y, p.Width * resize, p.Height * resize
End Sub 13 1792
I think you will need to print the various controls separately. It seems likely that the PrintPicture command would only send the contents of the .Picture (or maybe .Image) property, not other controls that are shown over the top of it.
Here's an idea - just as a quick workaround, could you duplicate the picturebox and associated labels etc. onto another form, then use thatform.PrintForm?
I think you will need to print the various controls separately. It seems likely that the PrintPicture command would only send the contents of the .Picture (or maybe .Image) property, not other controls that are shown over the top of it.
Here's an idea - just as a quick workaround, could you duplicate the picturebox and associated labels etc. onto another form, then use thatform.PrintForm?
The only issue with doing this is that it only prints what can be seen physically on the screen.. the image i'm using needs to be resized to print out exactly A4 in height and width.
Me.PrintForm command only prints what can be seen on the screen.
Any other options i can try??
Much Appreciated
The only issue with doing this is that it only prints what can be seen physically on the screen.. the image i'm using needs to be resized to print out exactly A4 in height and width.
Me.PrintForm command only prints what can be seen on the screen.
Any other options i can try??
Try these...
Try these...
I've looked at these 2 examples however they don't really solve my issue..
This is my exact problem:
I have an image which is nothing but a black rectangle (210mm x 297mm) in size. It is to be used as a background for what i'm trying to print.
I am printing it on A3 size paper. Infront of this black rectangle, i require to print the text from either text boxes or labels, situated infront of the black rectangle.
I can do this when the image isn't bigger than the screen. Ie. i can do it for A8, A6, and A5 sized images.
I have attached a copy of one of the smaller images, which i require the exact output to be printed in A4 size.
Thanks for your help again..
Sorry, although I do have some fairly extensive experience with printing forms and so on in VB6 (or earlier), it was probably something like 10 years ago. With luck, maybe someone else can help.
I'm just leaving work, but will try to do some research on this when I get home.
By the way, what did you mean exactly by "I can do this when the image isn't bigger than the screen"? How are you doing it now?
Sorry, although I do have some fairly extensive experience with printing forms and so on in VB6 (or earlier), it was probably something like 10 years ago. With luck, maybe someone else can help.
I'm just leaving work, but will try to do some research on this when I get home.
By the way, what did you mean exactly by "I can do this when the image isn't bigger than the screen"? How are you doing it now?
Private Sub cmdPrint_Click()
Printer.PaperSize = 3
Dim pcoControl As Control
Me.BackColor = vbWhite
Me.ForeColor = vbWhite
For Each pcoControl In Me.Controls
If TypeOf pcoControl Is TextBox Then
pcoControl.BackColor = vbBlack
pcoControl.BorderStyle = 0
ElseIf TypeOf pcoControl Is CommandButton Then
pcoControl.Visible = False
End If
Next pcoControl
Me.PrintForm
'** Then set all the properties back to their initial values by reversing the above
'** code.
End Sub
Ok, let me see whether I've got the situation straight. You have tried two methods so far: - Printer.PaintPicture
Prints the picture OK, but not the things you want overlaid. - Me.PrintForm
Works, but the size is limited.
Does this sound right?
One more questiuon - have you tried printing the text and other stuff (lines, boxes or whatever) onto the picture box, then sending the picture to the printer using your original method? If so, what was the result?
Note that for this to work, I expect you'd need to have AutoRedraw = True to create persistent graphics, otherwise it would just use the original picture.
One more questiuon - have you tried printing the text and other stuff (lines, boxes or whatever) onto the picture box, then sending the picture to the printer using your original method? If so, what was the result?
Note that for this to work, I expect you'd need to have AutoRedraw = True to create persistent graphics, otherwise it would just use the original picture.
In answer to your first question, yes this is correct! The answer to your second question, well the text to be displayed will changed according to an if statement, so simply pasting it on the picture will not help.
???
Do you know of any companies or individuals that can come on site to see if they can code what i require?
In answer to your first question, yes this is correct! The answer to your second question, well the text to be displayed will changed according to an if statement, so simply pasting it on the picture will not help.
What I meant was that you should be able to take your text and use the .Print method to place it onto the picture before sending it to the printer. This is where the AutoRedraw property becomes important, of course.
Do you know of any companies or individuals that can come on site to see if they can code what i require?
I don't even know what country you're in. :)
I've just started my lunch break, so I'll see whether I can come up with any further leads for you. But just checking out any tutorials on VB printing might help, as in theory this should be fairly straightforward. (Of course, should doesn't always help.)
I've been doing a bit of playing over lunch. This sample form I've been mucking about with allows me to type text into a textbox, click a button to paste it onto the picture box (clicking on the picture box selects the position for the text) then click another button to print that picture. (You can paste as mnay pieces of text as many times as you like, of course).
I realise this is pretty basic stuff (no pun intended). But by playing with properties of the picture box such as the font and so on, I don't see why this approach wouldn't allow your code to produce whatever you want.
If you'd like to use this form, just open a .FRM file in Notepad and paste this into it, completely replacing the contents.
At the very least, this should give us an idea of whether I'm completely off the track. - VERSION 5.00
-
Begin VB.Form Form1
-
Caption = "Form1"
-
ClientHeight = 5340
-
ClientLeft = 60
-
ClientTop = 345
-
ClientWidth = 6030
-
LinkTopic = "Form1"
-
ScaleHeight = 5340
-
ScaleWidth = 6030
-
StartUpPosition = 3 'Windows Default
-
Begin VB.CommandButton Command2
-
Caption = "Print"
-
Height = 435
-
Left = 660
-
TabIndex = 3
-
Top = 2400
-
Width = 1275
-
End
-
Begin VB.CommandButton Command1
-
Caption = "Paste text"
-
Height = 555
-
Left = 660
-
TabIndex = 2
-
Top = 1680
-
Width = 1215
-
End
-
Begin VB.TextBox Text1
-
Height = 315
-
Left = 480
-
TabIndex = 1
-
Text = "Text1"
-
Top = 3960
-
Width = 1875
-
End
-
Begin VB.PictureBox Picture1
-
AutoRedraw = -1 'True
-
BackColor = &H00000000&
-
BorderStyle = 0 'None
-
ClipControls = 0 'False
-
ForeColor = &H0000FFFF&
-
Height = 3195
-
Left = 3240
-
ScaleHeight = 3195
-
ScaleWidth = 2415
-
TabIndex = 0
-
Top = 840
-
Width = 2415
-
End
-
End
-
Attribute VB_Name = "Form1"
-
Attribute VB_GlobalNameSpace = False
-
Attribute VB_Creatable = False
-
Attribute VB_PredeclaredId = True
-
Attribute VB_Exposed = False
-
Private Sub Command1_Click()
-
With Picture1
-
Picture1.Print Text1
-
End With
-
End Sub
-
-
Private Sub Command2_Click()
-
Printer.PaintPicture Picture1.Image, 0, 0
-
Printer.EndDoc
-
End Sub
-
-
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
-
Picture1.CurrentX = X
-
Picture1.CurrentY = Y
-
End Sub
I've been doing a bit of playing over lunch. This sample form I've been mucking about with allows me to type text into a textbox, click a button to paste it onto the picture box (clicking on the picture box selects the position for the text) then click another button to print that picture. (You can paste as mnay pieces of text as many times as you like, of course).
I realise this is pretty basic stuff (no pun intended). But by playing with properties of the picture box such as the font and so on, I don't see why this approach wouldn't allow your code to produce whatever you want.
If you'd like to use this form, just open a .FRM file in Notepad and paste this into it, completely replacing the contents.
At the very least, this should give us an idea of whether I'm completely off the track. - VERSION 5.00
-
Begin VB.Form Form1
-
Caption = "Form1"
-
ClientHeight = 5340
-
ClientLeft = 60
-
ClientTop = 345
-
ClientWidth = 6030
-
LinkTopic = "Form1"
-
ScaleHeight = 5340
-
ScaleWidth = 6030
-
StartUpPosition = 3 'Windows Default
-
Begin VB.CommandButton Command2
-
Caption = "Print"
-
Height = 435
-
Left = 660
-
TabIndex = 3
-
Top = 2400
-
Width = 1275
-
End
-
Begin VB.CommandButton Command1
-
Caption = "Paste text"
-
Height = 555
-
Left = 660
-
TabIndex = 2
-
Top = 1680
-
Width = 1215
-
End
-
Begin VB.TextBox Text1
-
Height = 315
-
Left = 480
-
TabIndex = 1
-
Text = "Text1"
-
Top = 3960
-
Width = 1875
-
End
-
Begin VB.PictureBox Picture1
-
AutoRedraw = -1 'True
-
BackColor = &H00000000&
-
BorderStyle = 0 'None
-
ClipControls = 0 'False
-
ForeColor = &H0000FFFF&
-
Height = 3195
-
Left = 3240
-
ScaleHeight = 3195
-
ScaleWidth = 2415
-
TabIndex = 0
-
Top = 840
-
Width = 2415
-
End
-
End
-
Attribute VB_Name = "Form1"
-
Attribute VB_GlobalNameSpace = False
-
Attribute VB_Creatable = False
-
Attribute VB_PredeclaredId = True
-
Attribute VB_Exposed = False
-
Private Sub Command1_Click()
-
With Picture1
-
Picture1.Print Text1
-
End With
-
End Sub
-
-
Private Sub Command2_Click()
-
Printer.PaintPicture Picture1.Image, 0, 0
-
Printer.EndDoc
-
End Sub
-
-
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
-
Picture1.CurrentX = X
-
Picture1.CurrentY = Y
-
End Sub
Really appreciate the time and effort you are making on this for me..
Just wandering if it were possible for you to send me the Form Layout of the above code.. I'm not the most experienced programmer..
Also some of the text from the code when pasted into VB, becomes highlighted in bright red.. ie. not sure whether it will compile or not on run..
code in red is below:
Begin VB.Form Form1
Begin VB.CommandButton Command2
Begin VB.CommandButton Command1
Begin VB.TextBox Text1
Begin VB.PictureBox Picture1
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Everything else seems to look asthough it will compose
Try this. - Paste the text I posted into a text file, using Notepad or whatever
- Save it with the extension .Frm instead of .Txt
- Create a new project in VB6, with no forms or modules etc.
- Use "Add" (Ctrl-D I think) to add the "form" we just saved
- Set this form as the startup form
- Run
You see, the text I posted is what VB actually saves in the Frm file. I did it that way so there was no problem over attachments, and blocked uploads/downloads and so on.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Craig Malton |
last post by:
I have built a web application with ASP.NET and runs on a server running SQL.
Periodically, throughout the day, it stops functioning complaining of not
enough space on the disk - However, I have...
|
by: mike_basis |
last post by:
Hi All,
>From last 2 weeks I am despirately trying to get the installation steps
of R/3 4.7 on SQL server 2000 on Windows 2k or 2003 server. This is for
a distributed environment, I mean central...
|
by: Paolo |
last post by:
Hi,
I am trying to compact and repair my database, however every time I try it
comes up a message saying: Table: "TempMSysAccessObject already exists",
whenever I try to look for this table I...
|
by: johnmmcparland |
last post by:
I recently came across some code to help play .wav;
http://www.codeguru.com/Csharp/Csharp/cs_graphics/sound/article.php/c6143/
and while I got this to work in a stand-alone application, I have...
|
by: tgregg6 |
last post by:
I need help with my problem I am stuck and I don't know what to do!!! The problem is:
This program calculates the charges for DVD rentals where current releases cost $3.5 and all others cast $2.50....
|
by: ToAsTeEJaVa |
last post by:
I need to repeat a set of instructions but if the user enters a certain character or number e.g. 0; the program should stop...
what methods can I use for this?
I have tried to use a "for" method...
|
by: kommaraju |
last post by:
iam a starter to db2 & jdbc.i have a servlet program which connects to ibm db2
ussing jdbc.when i run this using apache tomcat 4.1.34 , it is showing a message that db2 driver cant be loaded & the...
|
by: jafarsibtain |
last post by:
hi..
I am creating a form where there are two combo Boxes (drop Down)
> Program_Combo_box
> Course_Code_Combo
in the Program Combo Box there are five items in the list >
1. BIT
2.BCA
3....
|
by: Brad Williams |
last post by:
Greetings,
How many transactions per second can access handel before SQL server is required?
How many computer can connect to a split database in access at once?
Thanks!!!!!
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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: 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: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |