|
-
Jul 26th, 2007, 12:51 PM
#1
Thread Starter
Lively Member
Print a form in centre alignment
Hi All,
I am developing a new project to print details on a cheque leaf. I have a form noramally with the size of a normal cheque leaf.
The form is inclueded some text boxes to put date, name of the beneficiary, amount and amount in words.
Now I want to print this form on a cheque leaft. I have the idea to print the form that I get from : http://www.vb-helper.com/howto_print...textboxes.html
But the problem, this print is left aligned. I want to print the data on a cheque leaf which is placed on the center of the tray of a Laser printer.
So any body has idea to align center to printer form.
With regards,
Nasreen
-
Jul 26th, 2007, 01:39 PM
#2
Re: Print a form in centre alignment
Code:
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Const VK_MENU As Byte = &H12
Private Const VK_SNAPSHOT As Byte = &H2C
Private Const KEYEVENTF_KEYUP = &H2
Private Sub Command1_Click()
Dim lWidth As Long
Dim lHeight As Long
Clipboard.Clear
Call keybd_event(VK_MENU, 0, 0, 0)
Call keybd_event(VK_SNAPSHOT, 0, 0, 0)
DoEvents
Call keybd_event(VK_SNAPSHOT, 0, KEYEVENTF_KEYUP, 0)
Call keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0)
Printer.Print
If Width > Printer.ScaleWidth Then
lWidth = Printer.ScaleWidth
lHeight = (Printer.ScaleWidth / Width) * Height
Else
lWidth = Width
lHeight = Height
End If
Printer.PaintPicture Clipboard.GetData, (Printer.ScaleWidth - Width) / 2, 0, lWidth, lHeight
Printer.EndDoc
End Sub
-
Jul 26th, 2007, 09:28 PM
#3
Re: Print a form in centre alignment
Take a look at this thread particularly post #7.
-
Jul 27th, 2007, 05:17 AM
#4
Thread Starter
Lively Member
Re: Print a form in centre alignment
Hi MartinLiss,
Thanks for your help and code.
But in my case this alignment is not enough.
Firstly your code prints the full picutre of the form including buttons, labels textboxes etc and From itself. But I want to print the data I type in the text boxes only.
Secondly please assume that, my project is to print data on a cheque leaf.
I tested your code both in Portrait and Landscape paper orientations. I want to print the data in Landscape paper orientation. In this orientation, your code prints in Left-Centre of a A4 paper (Landscape Mode). I want to print Top-Centre of a A4 paper.
The best example for my project in another way is, How I can print address in a Letter Cover from VB Form ?.
I hope you have got the idea that expect.
With regards,
Nasreen
-
May 14th, 2009, 12:35 PM
#5
Thread Starter
Lively Member
Re: Print a form in centre alignment
Hi all,
I am dveloping a small project to print Adresses on a Envelop using Laser Jet printers.
Has anybody an idea how I can print a text content in a Form at the desired place of the envelop, (Normally to address at right-centre and from address at left bottom)
With regards,
Nasreen
-
May 14th, 2009, 01:21 PM
#6
Re: Print a form in centre alignment
It might work better to use another bordless form and have your textbox data copied to labels on the other form and print the other form
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|