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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

priting more than one form on the same page 3

Status
Not open for further replies.

Peppy

Programmer
Sep 3, 2001
12
0
0
US
Hi, I was browsing the vb 6.0 forum for threads about
resizing forms. I need a form that is 12240 w x 15840 H and
the height and width will not take this size. The resize event will only work during run time. I was wondering if you have a solution. I thought about making two forms 6120 X 7920
but then I would need them to be print on one page and I do not know how to do that can anyone help? Appreciate the feedback. Thanks Peppy



 
MrMooCow, the measure is twips. I hope you get this. It was not clear to me how to respond to you?? Peppy
 
Hmmm,
In twips OR Pixels I can set it to the mentioned.Have you tried typing it in? It will only let u drag it to certain sizes. I typed ur exact values that u said would be accept and on my machine it was.

Sorry maybe I don't get your question.

Please I believe I can help you but I'm unclear. Brad,
Free mp3 player,games and more.
 
Dear MrMooCow, I see what ur saying...
Well yes setting two forms to equal 4.25 x 5.5 is not a problem, but how do I get them to print on the same page?
 
Dear MrMooCow, I see what ur saying...
Well yes setting two forms to equal 4.25 x 5.5 is not a problem, but how do I get them to print on the same page?
 
Okay, now I see your problem, I have a solution, give me a day or two to develop it. WHat you could to was capture each form as a picture, then on what paper sized form you could then load them into picture boxes. Thus one form would print out as two. I need a day or two to work on it, but I believe its possible. Brad,
Free mp3 player,games and more.
 
Okay this is kinda crazy, but heres how I got it to work.

I have one form with to PICTURE boxes, each is as big as my two other forms.

In a module there is this:


Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Public Const VK_SNAPSHOT As Byte = 44


Almost there!

Now on each form there is this


Clipboard.Clear
DoEvents
Call keybd_event(VK_SNAPSHOT, 0, 0, 0)
DoEvents
'Do something with the picture.
Form2.Picture1.PaintPicture Clipboard.GetData, 0, 0


That will paint a picture of the current form to the second one. WHich could be printed. The only thing is you have to have the form visible and have FOCUS. To do each of them you will have to run the code in red twice each time with the repective form on top so I think this would work but I'm not sure.

in a module as a function


Form1.show
<put the green code here>
form1.hide
form3.show
<put the green code here>
form3.hide

This might just work.

I hope this helps, It does work for me. I'm sorry that its not the &quot;best&quot; solution, probably not even the &quot;good&quot; solution.

Regards, if it doesn't work, you can also email me at bradsvb@yahoo.com
Brad,
Free mp3 player,games and more.
 
Or, something like this?

Private Sub cmdPrint_Click()
Printer.ScaleMode = vbTwips
Printer.Print ;
Printer.PaintPicture Form1.picF1, 100, 100, 7560, 6480
Printer.PaintPicture Form2.picF1, 100, 6580, 7560, 6480
Printer.EndDoc

End Sub

Tim

Remember the KISS principle:
Keep It Simple, Stupid!
 
I tried your code and got a type mismatch error
here is my code:

Public Sub cmdPrint_Click()

Printer.ScaleMode = vbTwips
Printer.Print;
Printer.PaintPicture frmCkCopy1.Picture1, 100, 100, 7560, 6480
Printer.PaintPicture frmCkCopy2.Picture2, 100, 6580,7560,6480
Printer.EndDoc


End Sub
Am I missing something? I understood this to mean it would print form one in a picture box and print form two in a picture box all on one sheet of paper, is that right? Thanks Peppy
 
Where is
Public Sub cmdPrint_Click() Located? If this is the click event of a command button on a form, then it can't be declared as Public.
I assume you have a form frmCkCopy1 with a picbox named Picture1 on it, and a form frmCkCopy2 with a picbox named Picture2 on it, and both picboxes have a picture.

Also, there needs to be a space
Printer.Print; should be Printer.Print ;

otherwise, looks fine to me
Tim

Tim

Remember the KISS principle:
Keep It Simple, Stupid!
 
Hi Tim, the assumption you made about my forms setup is what
I have. I did change Public sub, and printer.print ;...
I also tried making a brand new project with 3 forms, print from form1, insert your code into cmdPrint sub, which tells
form2.picture2, form3.picture3 to print....however I am still
getting Type mismatch error...I did notice in the properties
scalemode was set to 0-user and I changed them to twips. Any ideas??? Thanks Diane
 
Been outa town....
what line of code are u getting error on? Tim

Remember the KISS principle:
Keep It Simple, Stupid!
 
Hello Tim, Hope your were not flying??
The error &quot;Type Mismatch&quot; occurs on the following line:

Printer.PaintPicture frmCkCopy.Picture1, 100, 100, 7560, 6480

I brought this to my professor and he did not know either??
Thanks
 
well.........try this:
Printer.PaintPicture frmCkCopy.Picture1.Image, 100, 100, 7560, 6480
Tim

Remember the KISS principle:
Keep It Simple, Stupid!
 
Tim, that did work....hurrah. However this is printing
just picturebox and the image. I am trying to print forms with lables on it. I am sending information to this lables that I need to print in a specific layout. I did try putting these lables in the picture box but they are not printing. I am playing around with it, but so far nothing. It would be so simple if there was a way to just print the two forms on one page....any ideas?? Peppy
 
Peppy:
Methinks the gods that be at MS want us to use MS products for printing, so the Printer Object is rather limited. One might pray that in a future incarnation they might beef it up. It would be nice to just 'drop' an object on it (like a picbox or label or grid) and print. But, meanwhile, back at the ranch........

You could explore using Word or Excel. Or a reporting suite such as ActiveReports or CrystalReports(Ugh).

Or with Printer Object...:

With this line - Printer.PaintPicture frmCkCopy.Picture1.Image, 100, 100, 7560, 6480
- we are using a graphical method to 'draw' on the printer object. If I wanted a 'label' for Picture1(on the printer), I first find out how high a letter is, move to the loction on the Printer Object where I want it located, then print it.

Dim intCharHeight As Integer

With Printer
'set Printer font
.Font.Name = frmCkCopy.Font.Name
.Font.Bold = frmCkCopy.Font.Bold
.Font.Size = frmCkCopy.Font.Size
Printer.Print 'Note: You can't use With Printer with the .Print Method

'get height of a letter
intCharHeight = .TextHeight(&quot;W&quot;)

'postion for printing (=pic1.left & just above pic1)
.CurrentX = 100
.CurrentY = 100 - intCharHeight - 30 '30 for spacing
Printer.Print frmCkCopy.Label1.Caption
End With

Don't forget to use Printer.EndDoc to print. Tim

Remember the KISS principle:
Keep It Simple, Stupid!
 
:)
well I don't know how to give stars...but you deserve two...
You certainly have a good understanding of the printer
properties. I am going to take your feedback and work on this. I shall let you know the final resolve on this form problem...Take Care Peppy
 
hi peppy,

i could give u a solution.
goto scale mode property of the form and set it to inches.
i think u can now set the width and height of the form to much higher values.

the printing then is quite normal.jus say

form.printForm

I tried this and this works.

Rajendra
sairajendra@hotmail.com

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top