Home > Archive > Visual Basic Syntax > February 2005 > 3 questions
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| sentinel 2005-01-23, 9:05 pm |
| Hello
I am trying to print some variables on the default printer.
The app is multi user and my problem is that when i print from one
computer then the document looks just fine, but when i print from
another comp, the document is on two pages because margins are different...
Q1: How do i read the margins from a vb app and set new ones and after
printing set the original margins?
for printing i use 'printer' and printer.print "some text" & some variables
for positioning i use .currentX and .currnetY ... Can i set a scale
model so whatever the margins are the document looks the same?
Q2: the document must contain one image in the header. How do i print an
image? will picture object pict1 integrate in the document? will
pict1.print be imideatly or when the code reaches printer.enddoc ?
Q3: the users that run the program are running an exe file from
server... if i wanted to compile an update all users must stop
working.... is there a way to do this dynamicly? the exe is starter and
it checks for an dll on the server and runs the file with the latest date?
thanks for help
| |
| Russ Holsclaw 2005-01-23, 9:05 pm |
| "sentinel" <support@elma.hr> wrote in message
news:cpjmf2$cr5$1@garrison.globalnet.hr...
> Hello
>
> I am trying to print some variables on the default printer.
> The app is multi user and my problem is that when i print from one
> computer then the document looks just fine, but when i print from another
> comp, the document is on two pages because margins are different...
>
> Q1: How do i read the margins from a vb app and set new ones and after
> printing set the original margins?
>
> for printing i use 'printer' and printer.print "some text" & some
> variables
>
> for positioning i use .currentX and .currnetY ... Can i set a scale
> model so whatever the margins are the document looks the same?
The problem you're experiencing is that every printer has a "printable
area" of the page that is slightly smaller than the paper size. The width
of this area is Printer.Scalewidth and the height is Printer.Scaleheight.
The units are Twips by default (1/1440 of an inch).
The paper size in Twips is: Printer.Width and Printer.Height
This isn't quite all the information you need, because VB doesn't directly
provide a way to determine what the offset is between the edges of the
paper and the edges of the "printable area". The following functions,
placed into a general module, flesh out this information for the printer
object you're using. The PrinterOffsetX function returns the horizontal
offset, in Twips, between the paper edge and the printing area, and
PrinterOffsetY gives you the vertical offset. Subtract these figures from
the left and top margin values, in Twips, to compensate for this offset.
Right and Top margins can also be calculated, too, but I'll leave the
mathematics as an exercise for the student. :-)
'========================begin module==================================
=
' Contains following functions:
' PrinterOffsetX(o as printer), PrinterOffsetY(o as printer)
' These functions return "single" values representing the number
' of twips the printing area is relative to the left and top
' edges of the page.
Private Declare Function GetDeviceCaps Lib "gdi32" _
(ByVal hDC As Long, ByVal nIndex As Long) As Long
Const PHYSICALHEIGHT = 111
Const PHYSICALOFFSETX = 112
Const PHYSICALOFFSETY = 113
Const PHYSICALWIDTH = 110
'
Public Function PrinterOffsetX(PrObject As Printer) As Single
PrinterOffsetX = GetDeviceCaps(PrObject.hDC, PHYSICALOFFSETX) *
PrObject.TwipsPerPixelX
End Function
Public Function PrinterOffsetY(PrObject As Printer) As Single
PrinterOffsetY = GetDeviceCaps(PrObject.hDC, PHYSICALOFFSETY) *
PrObject.TwipsPerPixelY
End Function
'======================end of module==================
> Q2: the document must contain one image in the header. How do i print an
> image? will picture object pict1 integrate in the document? will
> pict1.print be imideatly or when the code reaches printer.enddoc ?
Look up the PaintPicture method of the Printer object.
> Q3: the users that run the program are running an exe file from server...
> if i wanted to compile an update all users must stop working.... is there
> a way to do this dynamicly? the exe is starter and it checks for an dll
> on the server and runs the file with the latest date?
This is not a good idea, for the reasons you've already found, not to
mention the fact that the VB runtime
must still be installed on each user's machine. I suppose you could
distribute the program so it can be
started from a Bat file that first refreshes the EXE file from the network
server. Check the Dos/Windows command called "Replace". This includes an
option to replace only files that are older than the version you are
copying.
| |
| sentinel 2005-01-23, 9:05 pm |
| Russ Holsclaw wrote:
>
> '========================begin module==================================
=
> ' Contains following functions:
> ' PrinterOffsetX(o as printer), PrinterOffsetY(o as printer)
> ' These functions return "single" values representing the number
> ' of twips the printing area is relative to the left and top
> ' edges of the page.
>
> Private Declare Function GetDeviceCaps Lib "gdi32" _
> (ByVal hDC As Long, ByVal nIndex As Long) As Long
> Const PHYSICALHEIGHT = 111
> Const PHYSICALOFFSETX = 112
> Const PHYSICALOFFSETY = 113
> Const PHYSICALWIDTH = 110
> '
>
> Public Function PrinterOffsetX(PrObject As Printer) As Single
> PrinterOffsetX = GetDeviceCaps(PrObject.hDC, PHYSICALOFFSETX) *
> PrObject.TwipsPerPixelX
> End Function
>
> Public Function PrinterOffsetY(PrObject As Printer) As Single
> PrinterOffsetY = GetDeviceCaps(PrObject.hDC, PHYSICALOFFSETY) *
> PrObject.TwipsPerPixelY
> End Function
> '======================end of module==================
>
Thanks
>
>
> Look up the PaintPicture method of the Printer object.
>
i figured this out as soon as i posted the message....
Printer.PaintPicture LoadPicture("header.jpg"), x, y, width, height
>
>
> This is not a good idea, for the reasons you've already found, not to
> mention the fact that the VB runtime
> must still be installed on each user's machine. I suppose you could
> distribute the program so it can be
> started from a Bat file that first refreshes the EXE file from the
> network server. Check the Dos/Windows command called "Replace". This
> includes an option to replace only files that are older than the version
> you are copying.
i guess for now i will upgrade the program before the users start
working for now...
thanks for the quick responce
| |
| Tommy Two Heads 2005-02-04, 9:06 am |
|
"sentinel" wrote:
> Hello
>
> I am trying to print some variables on the default printer.
> The app is multi user and my problem is that when i print from one
> computer then the document looks just fine, but when i print from
> another comp, the document is on two pages because margins are different...
>
> Q1: How do i read the margins from a vb app and set new ones and after
> printing set the original margins?
>
> for printing i use 'printer' and printer.print "some text" & some variables
>
> for positioning i use .currentX and .currnetY ... Can i set a scale
> model so whatever the margins are the document looks the same?
>
>
>
> Q2: the document must contain one image in the header. How do i print an
> image? will picture object pict1 integrate in the document? will
> pict1.print be imideatly or when the code reaches printer.enddoc ?
>
>
> Q3: the users that run the program are running an exe file from
> server... if i wanted to compile an update all users must stop
> working.... is there a way to do this dynamicly? the exe is starter and
> it checks for an dll on the server and runs the file with the latest date?
>
>
> thanks for help
>
|
|
|
|
|