Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
How to print a form which has larger than sceen si...
Author:
R.J.Balaji
E-mail:
Click to e-mail author
Submitted:
9/27/2001
Version:
VB6
Compatibility:
VB6
Category:
Windows API
Views:
15357
How to print a form which has larger than sceen size.The Printform method doesn't print the unvisible part of the form in screen.So the following code expalins how to print the form using paint picture method.place to picture boxes and place two labelsand a command button inside the picture box1.Make the form larger than screens size.add the following code to the form and run it.it will print both top and bottom labels.
Declarations:
Private Const twipFactor = 1440 Private Const WM_PAINT = &HF Private Const WM_PRINT = &H317 Private Const PRF_CLIENT = &H4& Private Const PRF_CHILDREN = &H10& Private Const PRF_OWENED = &H20& Dim swide As Single, stall As Single Dim rv As Long Private Declare Function SendMessage Lib _ "user32" Alias "SendMessageA" (ByVal hwnd As Long, _ ByVal wMsg As Long, ByVal wParam As Long, _ lParam As Long) As Long
Code:
Private Sub form_load() Me.Visible = True Me.ScaleMode = vbTwips 'default swide = 8.5 stall = 11 Me.Width = twipFactor * swide Me.Height = twipFactor * stall With Picture1 Top = 0 Left = 0 MsgBox twipFactor MsgBox swide MsgBox stall Width = twipFactor * swide Height = twipFactor * stall End With With Picture2 Top = 0 Left = 0 Width = twipFactor * swide Height = twipFactor * stall End With With Label1 Left = Me.Width / 2 Top = 0 End With With Label2 Top = (twipFactor * stall) - .Height * 2 Left = Me.Width / 2 End With End Sub Private Sub command1_click() Me.Visible = True DoEvents Picture1.SetFocus Picture2.AutoRedraw = True rv = SendMessage(Picture1.hwnd, WM_PAINT, Picture2.hDC, 0) rv = SendMessage(Picture1.hwnd, WM_PRINT, Picture2.hDC, PRF_CHILDREN + PRF_CLIENT + PRF_OWNED) Picture2.Picture = Picture2.Image Picture2.AutoRedraw = False Printer.Print "" Printer.PaintPicture Picture2.Picture, 0, 0 Printer.EndDoc End Sub
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement