Author |
Message |
Ivan Demkovitc #1 / 8
|
 Need Ideas - Printing
Hi NG! In my App I print pictures on a printer. Also I implemented Preview screen where user can preview 1st page. This form contain 1 Picture Box. Basically I do same PaintPicture on this picture box. Now I want to add functionality where user will be able to zoom preview. I have no Idea how to do this unless Paint all thing together. It takes quite time to do this. And doing it like this will work really slow... Also How would I make my picure scroll up/down left/right ? Thanks
|
Fri, 10 Sep 2004 22:43:35 GMT |
|
 |
Mike William #2 / 8
|
 Need Ideas - Printing
Quote: > In my App I print pictures on a printer. Also I implemented Preview screen > Now I want to add functionality where user will be able to zoom preview. > I have no Idea how to do this unless Paint all thing together. > It takes quite time to do this. And doing it like this will work really
slow I'm not sure what you mean when you say that painting the entire picture into a Picture Box will take longer than painting it at a reduced size. In fact, the opposite is true! Also, I'm not entirely sure what you mean when you say you want to give the user a "zoom" facility. A lot depends on the original size of the picture. Most pictures taken by digital cameras, for example, are very much larger (pixel area) than the display, and you have to "reduce" them to show them on the screen so that the entire picture is visible. In such cases, an effective "zoom" can be given simply by drawing the picture into an Autoredraw Picture Box at its original size. This will (in the case of most digital camera pictures) produce a picture that is very much larger than the screen. You can then place this Picture Box inside another (smaller) Picture Box (so that the small picture box is the "container" for the large one) and allow the user to move around the picture with a cople of scroll bars. Some more detail of what it is you actually require would be nice. Mike
|
Sat, 11 Sep 2004 02:20:34 GMT |
|
 |
Ivan Demkovitc #3 / 8
|
 Need Ideas - Printing
Mike, see inline Quote: > I'm not sure what you mean when you say that painting the entire picture > into a Picture Box will take longer than painting it at a reduced size. In > fact, the opposite is true!
This is a barcode Label printing application. Each barcode generated as a separate Picture file. When I print it, I generate barcode using 3rd party control and save it as Picture file(using control) When I print labels I PaintPicture loading it from File. File is temporary, it is replaced with newly generated. It could be multiple barcodes per page. For certain symbologies it takes time just to generate Picture file. Also, I use Paint Method on Picture box when load Picture file (same way like I do with printer.) If I resize Picture box picture steel same (does not scale) . Even more, I found that when you Paint picture on Picture box you can not save it or get it as Picture property. Even AutoRedraw property set to true when i resize Picture Box picture does not resizes. Only cls and repainitng make it work. And thats why it takes time to generate it again. Quote: > Also, I'm not entirely sure what you mean when you say you want to give the > user a "zoom" facility. A lot depends on the original size of the picture.
Because user want make sure that barcode he/she needs will be printed they may want look at it closer. Quote: > Most pictures taken by digital cameras, for example, are very much larger > (pixel area) than the display, and you have to "reduce" them to show them on > the screen so that the entire picture is visible. In such cases, an > effective "zoom" can be given simply by drawing the picture into an > Autoredraw Picture Box at its original size. This will (in the case of most > digital camera pictures) produce a picture that is very much larger than the > screen. You can then place this Picture Box inside another (smaller) Picture > Box (so that the small picture box is the "container" for the large one) and > allow the user to move around the picture with a cople of scroll bars. > Some more detail of what it is you actually require would be nice.
Hope it will give you some insight. Main point here that I have multiple picture files for 1 Page.
|
Sat, 11 Sep 2004 02:51:30 GMT |
|
 |
Mike William #4 / 8
|
 Need Ideas - Printing
Right. I think I see what you are doing now. It would appear that these pictures (the individual barcodes) are quite small, and you want to let the user view them at a larger size if he wishes (something larger than their "real" size. The PaintPicture method is easily capable of doing this. For example, if your barcode is loaded into Picture1 picture box and you want to draw it into Picture2 picture box at a larger size then you can use: Picture2.PaintPicture Picture1.Picture, 0, 0, _ Picture2.ScaleWidth, Picture2.ScaleHeight This will draw the barcode into Picture2 picture box at whatever size Picture2 picture box happens to be. You can, of course, draw it at any other size you require, simply by setting the last two parameters of the above line of code accordingly. If Picture2 Autoredraw property is True at the time you use the above code then the drawing will become a "persistent bitmap" in the Image property (*not* the Picture property) of Picture 2, and you can access it if you require. Alternatively, you could use: Picture2.ScaleMode = vbInches Picture2.AutoRedraw = True Picture2.PaintPicture LoadPicture("c:\mypic"), 0.5, 0.5, 2, 1.5 . . . . . or Printer.ScaleMode = vbInches Printer.PaintPicture LoadPicture("c:\mypic.jpg"), 0.5, 0.5, 2, 1.5 Printer.EndDoc Both of which will print the picture at location (0.5, 0,5) and at a size of (2 x 1.5) logical inches. The only differences between the Picture Box output and the Printer output are: 1. The "logical inches" used by the Picture Box are not quite the same as "real" inches, and the actual size of a "logical" inch depends on many things, including the Windows font size setting (the number of Twips per Pixel), the resolution of the display and the physical size of the display. 2. The "logical" inches used by the printer are exactly the same size as "real" inches, and so the size of the printed output will be exactly what you have asked for. 3. The positioning of the printer output (top left corner of the printed picture) will not be exactly what you have asked for (despite it using "real" inches) and, moreover, it is likely to be at a slightly different position on different printers. Windows "knows" about these differences, though, and it is possible to write code to take care of this problem for you, so that both the position and the size of the prinnted output is exactly what you want. So, you can print a single bar code (or a number of separate bar codes) to either the printer or to a Picture Box and you can position and size them whereever you want. Does this help you at all? Mike
Quote: > Mike, > see inline > > I'm not sure what you mean when you say that painting the entire picture > > into a Picture Box will take longer than painting it at a reduced size. In > > fact, the opposite is true! > This is a barcode Label printing application. > Each barcode generated as a separate Picture file. When I print it, I > generate > barcode using 3rd party control and save it as Picture file(using control) > When I print labels I PaintPicture loading it from File. File is temporary, > it is replaced with newly > generated. It could be multiple barcodes per page. For certain symbologies > it takes time just to generate > Picture file. > Also, I use Paint Method on Picture box when load Picture file (same way > like I do with printer.) > If I resize Picture box picture steel same (does not scale) . Even more, I > found that when you > Paint picture on Picture box you can not save it or get it as Picture > property. > Even AutoRedraw property set to true when i resize Picture Box picture does > not resizes. > Only cls and repainitng make it work. > And thats why it takes time to generate it again. > > Also, I'm not entirely sure what you mean when you say you want to give > the > > user a "zoom" facility. A lot depends on the original size of the picture. > Because user want make sure that barcode he/she needs will be printed they > may want look > at it closer. > > Most pictures taken by digital cameras, for example, are very much larger > > (pixel area) than the display, and you have to "reduce" them to show them > on > > the screen so that the entire picture is visible. In such cases, an > > effective "zoom" can be given simply by drawing the picture into an > > Autoredraw Picture Box at its original size. This will (in the case of > most > > digital camera pictures) produce a picture that is very much larger than > the > > screen. You can then place this Picture Box inside another (smaller) > Picture > > Box (so that the small picture box is the "container" for the large one) > and > > allow the user to move around the picture with a cople of scroll bars. > > Some more detail of what it is you actually require would be nice. > Hope it will give you some insight. > Main point here that I have multiple picture files for 1 Page.
|
Sat, 11 Sep 2004 03:34:12 GMT |
|
 |
Ivan Demkovitc #5 / 8
|
 Need Ideas - Printing
Mike, Lets go into more detail... I have a DLL which print or show preview. There is 2 Methods: PrintLabels and PreviewLabels... This is completely identical methods. In first case I establish Printer object and use it for PaintPicture In second case I establish same Printer object, get all properties (like non-printable areas, page size, etc..) - What you was trying to explain... Show Form with only 1 Picture Box. Resize Form and Picture Box so H/W ratio is correct and same as Printer. Get Picture Box as a reference and do same thing as with Print Methos. PaintPicture and so on. Barcode Pictures by itself generated with 300 dpi (could be user-defined) And like you say this picture could be displayed on whole screen with perfect quality. But I show all Page and barcodes hardly readable. My problem is to make it possible to zoom on Preview so user can see specific barcodes closer. And I want to make it with minimum amount of work and acceptable speed. Simply resizing Form with Picure box is not doing job. Any ideas ?
Quote: > Right. I think I see what you are doing now. It would appear that these > pictures (the individual barcodes) are quite small, and you want to let the > user view them at a larger size if he wishes (something larger than their > "real" size. The PaintPicture method is easily capable of doing this. For > example, if your barcode is loaded into Picture1 picture box and you want to > draw it into Picture2 picture box at a larger size then you can use: > Picture2.PaintPicture Picture1.Picture, 0, 0, _ > Picture2.ScaleWidth, Picture2.ScaleHeight > This will draw the barcode into Picture2 picture box at whatever size > Picture2 picture box happens to be. You can, of course, draw it at any other > size you require, simply by setting the last two parameters of the above > line of code accordingly. > If Picture2 Autoredraw property is True at the time you use the above code > then the drawing will become a "persistent bitmap" in the Image property > (*not* the Picture property) of Picture 2, and you can access it if you > require. > Alternatively, you could use: > Picture2.ScaleMode = vbInches > Picture2.AutoRedraw = True > Picture2.PaintPicture LoadPicture("c:\mypic"), 0.5, 0.5, 2, 1.5 > . . . . . or > Printer.ScaleMode = vbInches > Printer.PaintPicture LoadPicture("c:\mypic.jpg"), 0.5, 0.5, 2, 1.5 > Printer.EndDoc > Both of which will print the picture at location (0.5, 0,5) and at a size of > (2 x 1.5) logical inches. The only differences between the Picture Box > output and the Printer output are: > 1. The "logical inches" used by the Picture Box are not quite the same as > "real" inches, and the actual size of a "logical" inch depends on many > things, including the Windows font size setting (the number of Twips per > Pixel), the resolution of the display and the physical size of the display. > 2. The "logical" inches used by the printer are exactly the same size as > "real" inches, and so the size of the printed output will be exactly what > you have asked for. > 3. The positioning of the printer output (top left corner of the printed > picture) will not be exactly what you have asked for (despite it using > "real" inches) and, moreover, it is likely to be at a slightly different > position on different printers. Windows "knows" about these differences, > though, and it is possible to write code to take care of this problem for > you, so that both the position and the size of the prinnted output is > exactly what you want. > So, you can print a single bar code (or a number of separate bar codes) to > either the printer or to a Picture Box and you can position and size them > whereever you want. > Does this help you at all? > Mike
> > Mike, > > see inline > > > I'm not sure what you mean when you say that painting the entire picture > > > into a Picture Box will take longer than painting it at a reduced size. > In > > > fact, the opposite is true! > > This is a barcode Label printing application. > > Each barcode generated as a separate Picture file. When I print it, I > > generate > > barcode using 3rd party control and save it as Picture file(using control) > > When I print labels I PaintPicture loading it from File. File is > temporary, > > it is replaced with newly > > generated. It could be multiple barcodes per page. For certain symbologies > > it takes time just to generate > > Picture file. > > Also, I use Paint Method on Picture box when load Picture file (same way > > like I do with printer.) > > If I resize Picture box picture steel same (does not scale) . Even more, I > > found that when you > > Paint picture on Picture box you can not save it or get it as Picture > > property. > > Even AutoRedraw property set to true when i resize Picture Box picture > does > > not resizes. > > Only cls and repainitng make it work. > > And thats why it takes time to generate it again. > > > Also, I'm not entirely sure what you mean when you say you want to give > > the > > > user a "zoom" facility. A lot depends on the original size of the > picture. > > Because user want make sure that barcode he/she needs will be printed they > > may want look > > at it closer. > > > Most pictures taken by digital cameras, for example, are very much > larger > > > (pixel area) than the display, and you have to "reduce" them to show > them > > on > > > the screen so that the entire picture is visible. In such cases, an > > > effective "zoom" can be given simply by drawing the picture into an > > > Autoredraw Picture Box at its original size. This will (in the case of > > most > > > digital camera pictures) produce a picture that is very much larger than > > the > > > screen. You can then place this Picture Box inside another (smaller) > > Picture > > > Box (so that the small picture box is the "container" for the large one) > > and > > > allow the user to move around the picture with a cople of scroll bars. > > > Some more detail of what it is you actually require would be nice. > > Hope it will give you some insight. > > Main point here that I have multiple picture files for 1 Page.
|
Sat, 11 Sep 2004 04:20:39 GMT |
|
 |
Mike William #6 / 8
|
 Need Ideas - Printing
I'm still not sure what you mean, Ivan. Post the code that you are using (or at least the part of it concerning printing). Maybe that will give me a better idea. For example, how do you get the DLL to print the page full of bar codes to the printer. And how do you get it to print the same thing to a Picture Box. Details (and code) please. Mike
Quote: > Mike, > Lets go into more detail... > I have a DLL which print or show preview. > There is 2 Methods: PrintLabels and PreviewLabels... > This is completely identical methods. > In first case I establish Printer object and use it for PaintPicture > In second case I establish same Printer object, get all properties (like > non-printable areas, page size, etc..) - What you was trying to explain... > Show Form with only 1 Picture Box. Resize Form and Picture Box so H/W ratio > is correct and same as Printer. > Get Picture Box as a reference and do same thing as with Print Methos. > PaintPicture and so on. > Barcode Pictures by itself generated with 300 dpi (could be user-defined) > And like you say this picture could be displayed on whole screen with > perfect quality. > But I show all Page and barcodes hardly readable. > My problem is to make it possible to zoom on Preview so user can see > specific barcodes closer. > And I want to make it with minimum amount of work and acceptable speed. > Simply resizing Form with Picure box is not doing job. > Any ideas ?
> > Right. I think I see what you are doing now. It would appear that these > > pictures (the individual barcodes) are quite small, and you want to let > the > > user view them at a larger size if he wishes (something larger than their > > "real" size. The PaintPicture method is easily capable of doing this. For > > example, if your barcode is loaded into Picture1 picture box and you want > to > > draw it into Picture2 picture box at a larger size then you can use: > > Picture2.PaintPicture Picture1.Picture, 0, 0, _ > > Picture2.ScaleWidth, Picture2.ScaleHeight > > This will draw the barcode into Picture2 picture box at whatever size > > Picture2 picture box happens to be. You can, of course, draw it at any > other > > size you require, simply by setting the last two parameters of the above > > line of code accordingly. > > If Picture2 Autoredraw property is True at the time you use the above code > > then the drawing will become a "persistent bitmap" in the Image property > > (*not* the Picture property) of Picture 2, and you can access it if you > > require. > > Alternatively, you could use: > > Picture2.ScaleMode = vbInches > > Picture2.AutoRedraw = True > > Picture2.PaintPicture LoadPicture("c:\mypic"), 0.5, 0.5, 2, 1.5 > > . . . . . or > > Printer.ScaleMode = vbInches > > Printer.PaintPicture LoadPicture("c:\mypic.jpg"), 0.5, 0.5, 2, 1.5 > > Printer.EndDoc > > Both of which will print the picture at location (0.5, 0,5) and at a size > of > > (2 x 1.5) logical inches. The only differences between the Picture Box > > output and the Printer output are: > > 1. The "logical inches" used by the Picture Box are not quite the same as > > "real" inches, and the actual size of a "logical" inch depends on many > > things, including the Windows font size setting (the number of Twips per > > Pixel), the resolution of the display and the physical size of the > display. > > 2. The "logical" inches used by the printer are exactly the same size as > > "real" inches, and so the size of the printed output will be exactly what > > you have asked for. > > 3. The positioning of the printer output (top left corner of the printed > > picture) will not be exactly what you have asked for (despite it using > > "real" inches) and, moreover, it is likely to be at a slightly different > > position on different printers. Windows "knows" about these differences, > > though, and it is possible to write code to take care of this problem for > > you, so that both the position and the size of the prinnted output is > > exactly what you want. > > So, you can print a single bar code (or a number of separate bar codes) to > > either the printer or to a Picture Box and you can position and size them > > whereever you want. > > Does this help you at all? > > Mike
> > > Mike, > > > see inline > > > > I'm not sure what you mean when you say that painting the entire > picture > > > > into a Picture Box will take longer than painting it at a reduced > size. > > In > > > > fact, the opposite is true! > > > This is a barcode Label printing application. > > > Each barcode generated as a separate Picture file. When I print it, I > > > generate > > > barcode using 3rd party control and save it as Picture file(using > control) > > > When I print labels I PaintPicture loading it from File. File is > > temporary, > > > it is replaced with newly > > > generated. It could be multiple barcodes per page. For certain > symbologies > > > it takes time just to generate > > > Picture file. > > > Also, I use Paint Method on Picture box when load Picture file (same way > > > like I do with printer.) > > > If I resize Picture box picture steel same (does not scale) . Even more, > I > > > found that when you > > > Paint picture on Picture box you can not save it or get it as Picture > > > property. > > > Even AutoRedraw property set to true when i resize Picture Box picture > > does > > > not resizes. > > > Only cls and repainitng make it work. > > > And thats why it takes time to generate it again. > > > > Also, I'm not entirely sure what you mean when you say you want to > give > > > the > > > > user a "zoom" facility. A lot depends on the original size of the > > picture. > > > Because user want make sure that barcode he/she needs will be printed > they > > > may want look > > > at it closer. > > > > Most pictures taken by digital cameras, for example, are very much > > larger > > > > (pixel area) than the display, and you have to "reduce" them to show > > them > > > on > > > > the screen so that the entire picture is visible. In such cases, an > > > > effective "zoom" can be given simply by drawing the picture into an > > > > Autoredraw Picture Box at its original size. This will (in the case of > > > most > > > > digital camera pictures) produce a picture that is very much larger > than > > > the > > > > screen. You can then place this Picture Box inside another (smaller) > > > Picture > > > > Box (so that the small picture box is the "container" for the large > one) > > > and > > > > allow the user to move around the picture with a cople of scroll bars. > > > > Some more detail of what it is you actually require would be nice. > > > Hope it will give you some insight. > > > Main point here that I have multiple picture files for 1 Page.
|
Sat, 11 Sep 2004 05:31:38 GMT |
|
 |
Ivan Demkovitc #7 / 8
|
 Need Ideas - Printing
Here we go.. frmPreview Code: (contain picPrev Picture Box) Option Explicit Public HbyWRatio As Single Public Sub ResizeForm() If HbyWRatio = 0 Then Exit Sub With picPrev '.Top = 100 '.Left = 0 .Height = Me.Height - 390 .Width = Int(.Height / HbyWRatio) Me.Width = .Width + 110 .Refresh End With End Sub Private Sub Form_Resize() ResizeForm End Sub cls Code: (I put 2 procedures here) Public Sub PreviewLabels(rData As ADODB.Recordset, Optional XStart As Integer = 1, Optional YStart As Integer = 1, _ Optional vOption1 As Variant, Optional vOption2 As Variant, _ Optional vOption3 As Variant, Optional vOption4 As Variant, Optional vOption5 As Variant) Dim i As Integer Dim PgCnt As Integer 'count pages Dim RowCnt As Integer 'count rows Dim ColCnt As Integer 'count columns Dim X As Long Dim Y As Long Dim Xsize As Long Dim Ysize As Long Dim Pct As Picture Dim TestStr As String 'test recordset On Error Resume Next For i = 1 To BarCodes_Count TestStr = rData.Collect((i * 2 - 1) - 1) & rData.Collect((i * 2) - 1) If Err.Number <> 0 Then Err.Clear On Error GoTo 0 RaiseCustomError enumInvalidRecordset, emsgInvalidRecordset End If Next i On Error GoTo PreviewLabels_Error 'Load frmPreview frmPreview.Show frmPreview.HbyWRatio = (PrPageY + PrPageTopMargin + PrPageBottomMargin) _ / (PrPageX + PrPageLeftMargin + PrPageRightMargin) frmPreview.ResizeForm Set picPreview = frmPreview.picPrev With picPreview .ScaleMode = vbTwips .BackColor = vbWhite .ScaleHeight = PrPageY '+ PrPageTopMargin + PrPageBottomMargin .ScaleWidth = PrPageX '+ PrPageLeftMargin + PrPageRightMargin End With 'Paint RED lines for NON-PRINTABLE areas 'top Non-Printable area picPreview.Line (0, PrPageTopMargin)-(PrPageX, PrPageTopMargin), vbRed 'left Non-prinable area picPreview.Line (PrPageLeftMargin, 0)-(PrPageLeftMargin, PrPageY), vbRed 'Right Non-Printable area picPreview.Line (PrPageX - PrPageRightMargin, 0)-(PrPageX - PrPageRightMargin, PrPageY), vbRed 'Bottom Non-prinable area picPreview.Line (0, PrPageY - PrPageBottomMargin)-(PrPageX, PrPageY - PrPageBottomMargin), vbRed 'Paint Blue Lines for Labels Coordinates grid. 'horizontal lines For i = 1 To LabelsY picPreview.Line (0, Y_Coord(i))-(PrPageX, Y_Coord(i)), vbBlue picPreview.Line (0, Y_Coord(i) + StickerYSize)-(PrPageX, Y_Coord(i) + StickerYSize), vbBlue Next i 'vertical lines For i = 1 To LabelsX picPreview.Line (X_Coord(i), 0)-(X_Coord(i), PrPageY), vbBlue picPreview.Line (X_Coord(i) + StickerXSize, 0)-(X_Coord(i) + StickerXSize, PrPageY), vbBlue Next i PgCnt = 1 RowCnt = YStart ColCnt = XStart With rData .MoveFirst Do Until .EOF 'paint bar codes on one sticker For i = 1 To BarCodes_Count Set Pct = GenBarCode(.Collect((i * 2 - 1) - 1), .Collect((i * 2) - 1), i) 'now I need to paint this picture on Printer X = X_Coord(ColCnt) + LeftCoord(i) '+ PrPageLeftMargin Y = Y_Coord(RowCnt) + TopCoord(i) '+ PrPageTopMargin Set oBarCode = BarCodes.Item(LabelProfile(i)) If Not Pct Is Nothing Then 'Calculate size of picture based on rotation degrees 'If horizontal position for barcode If oBarCode.Rotation = bcClockwise_180 Or oBarCode.Rotation = bcZeroDegrees Then Xsize = (Pct.Width / Pct.Height) * PrintHeight(i) Ysize = 1 * PrintHeight(i) Else 'If Vertical position Ysize = (Pct.Height / Pct.Width) * PrintHeight(i) Xsize = 1 * PrintHeight(i) End If Set oBarCode = Nothing picPreview.PaintPicture Pct, X, Y, Xsize, Ysize Else 'Draw 3 lines to show position of barcode If oBarCode.Rotation = bcClockwise_180 Or oBarCode.Rotation = bcZeroDegrees Then picPreview.Line (X, Y)-(X, Y + PrintHeight(i)), vbRed 'top horizontal line picPreview.Line (X, Y)-(X + lLineSize, Y), vbRed 'bottom horizontal line picPreview.Line (X, Y + PrintHeight(i))-(X + lLineSize, Y + PrintHeight(i)), vbRed 'need to draw arrow :-) picPreview.Line (X + lLineSize, Y)-(X + lLineSize - lArrSize, Y + lArrSize / 2), vbRed picPreview.Line (X + lLineSize, Y + PrintHeight(i))-(X + lLineSize - lArrSize, Y + PrintHeight(i) - lArrSize / 2), vbRed Else picPreview.Line (X, Y)-(X + PrintHeight(i), Y), vbRed 'left vertical line picPreview.Line (X, Y)-(X, Y + lLineSize), vbRed 'right vertical line picPreview.Line (X + PrintHeight(i), Y)-(X + PrintHeight(i), Y + lLineSize), vbRed 'need to draw arrow :-) picPreview.Line (X, Y + lLineSize)-(X + lArrSize / 2, Y + lLineSize - lArrSize), vbRed picPreview.Line (X + PrintHeight(i), Y + lLineSize)-(X + PrintHeight(i) - lArrSize / 2, Y + lLineSize - lArrSize), vbRed End If End If Next i 'now we need display this picture in proper cell in FarPoint 'now we need increase row/col and change page if necessary If ColCnt = LabelsX Then 'if last label on right ColCnt = 1 RowCnt = RowCnt + 1 If RowCnt > LabelsY Then 'need change page ColCnt = 1 RowCnt = 1 PgCnt = PgCnt + 1 'End Of Page Exit Do End If Else ColCnt = ColCnt + 1 End If .MoveNext Loop End With Exit Sub PreviewLabels_Error: RaiseCustomError enumFatal, emsgFatal & "Number: " & Err.Number & " (" & Err.Description & ") in procedure PreviewLabels of Class Module clsPrintLabel" End Sub ---------------------------------------------------------------------------- -------- Public Sub PrintLabels(rData As ADODB.Recordset, Optional XStart As Integer = 1, Optional YStart As Integer = 1, _ Optional vOption1 As Variant, Optional vOption2 As Variant, _ Optional vOption3 As Variant, Optional vOption4 As Variant, Optional vOption5 As Variant) Dim i As Integer Dim PgCnt As Integer 'count pages Dim RowCnt As Integer 'count rows Dim ColCnt As Integer 'count columns Dim X As Long Dim Y As Long Dim Xsize As Long Dim Ysize As Long Dim TestStr As String Dim Pct As Picture On Error GoTo PrintLabels_Error 'test recordset rData.MoveFirst For i = 1 To BarCodes_Count TestStr = rData.Collect((i * 2 - 1) - 1) & rData.Collect((i * 2) - 1) If Err.Number <> 0 Then RaiseCustomError enumInvalidRecordset, emsgInvalidRecordset Next i PgCnt = 1 RowCnt = YStart ColCnt = XStart With rData '.MoveFirst Do Until .EOF 'paint bar codes on one sticker For i = 1 To BarCodes_Count Set Pct = GenBarCode(.Collect((i * 2 - 1) - 1), .Collect((i * 2) - 1), i) 'now I need to paint this picture on Printer X = X_Coord(ColCnt) + LeftCoord(i) - PrPageLeftMargin Y = Y_Coord(RowCnt) + TopCoord(i) - PrPageTopMargin If Not Pct Is Nothing Then 'Calculate size of picture based on rotation degrees Set oBarCode = BarCodes.Item(LabelProfile(i)) 'If horizontal position for barcode If oBarCode.Rotation = bcClockwise_180 Or oBarCode.Rotation = bcZeroDegrees Then Xsize = (Pct.Width / Pct.Height) * PrintHeight(i) Ysize = 1 * PrintHeight(i) Else 'If Vertical position Ysize = (Pct.Height / Pct.Width) * PrintHeight(i) Xsize = 1 * PrintHeight(i) End If Set oBarCode = Nothing Printer.PaintPicture Pct, X, Y, Xsize, Ysize End If Next i 'now we need increase row/col and change page if necessary If ColCnt = LabelsX Then 'if last label on right ColCnt = 1 RowCnt = RowCnt + 1 If RowCnt > LabelsY Then 'need change page ColCnt = 1 RowCnt = 1 PgCnt = PgCnt + 1 Printer.NewPage End If Else ColCnt = ColCnt + 1 End If .MoveNext Loop End With Printer.EndDoc Exit Sub PrintLabels_Error: RaiseCustomError enumFatal, emsgFatal & "Number: " & Err.Number & " (" & Err.Description & ") in procedure PrintLabels of Class Module clsPrintLabel" End Sub ---------------------------------------------------------------------------- ---- This is sub use 3rd party control to generate barcode and return picture object Private Function GenBarCode(Msg As String, Cmt As String, BarCodeNum As Integer) As Picture Dim LabelProfileID As String On Error GoTo GenBarCode_Error LabelProfileID = LabelProfile(BarCodeNum) Set oBarCode = BarCodes.Item(LabelProfileID) 'reset every time BadMsg = False oBarCode.Message = Msg 'if error event was fired flag updated If BadMsg Then Set GenBarCode = Nothing Set oBarCode = Nothing Exit Function End If If Len(Cmt) > 100 Then oBarCode.Comment = Trim$(Left$(Cmt, 100)) Else oBarCode.Comment = Trim$(Cmt) End If oBarCode.SaveBarCode TempPath Set GenBarCode = LoadPicture(TempPath) Set oBarCode = Nothing Exit Function GenBarCode_Error: RaiseCustomError enumFatal, emsgFatal & "Number: " & Err.Number & " (" & Err.Description & ") in procedure GenBarCode of Class Module clsPrintLabel" End Function
... read more »
|
Sat, 11 Sep 2004 06:23:04 GMT |
|
 |
Mike William #8 / 8
|
 Need Ideas - Printing
Wow! That's a lot of code for someone who has been drinking Bacardi and Coke all night! (I mean me, not you!). Mind you, it's my own fault! I did ask you to post it! I'll have a look in the morning, when I sober up (unless, of course, somebody else comes up with an answer before that). Mike p.s. That's the beauty of email. People don't know you're drunk unless you tell them! You can go over and over your message correcting typos and spelling mistakes and bad grammer for ages before you decide to post it :-) Ah! But did I slip up there. Should it be "grammar"? Yep! It should! http://www.dictionary.com/ comes to the rescue again :-) Pass the Bacardi!
Quote: > Here we go.. > snip <
|
Sat, 11 Sep 2004 07:00:55 GMT |
|
|
|