home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 5 Developer's Kit / vb5 dev kit.iso / dev / csview / fezprint.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-04-05  |  30.2 KB  |  893 lines

  1. VERSION 2.00
  2. Begin Form fEZPrint 
  3.    BackColor       =   &H00FFFFFF&
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "VSPrinter: a smarter Replacement for the Printer Object"
  6.    ClientHeight    =   6375
  7.    ClientLeft      =   240
  8.    ClientTop       =   465
  9.    ClientWidth     =   8985
  10.    Height          =   6780
  11.    Left            =   180
  12.    LinkTopic       =   "Form1"
  13.    MaxButton       =   0   'False
  14.    MinButton       =   0   'False
  15.    ScaleHeight     =   6375
  16.    ScaleWidth      =   8985
  17.    Top             =   120
  18.    Width           =   9105
  19.    Begin vsViewPort vsViewPort2 
  20.       BackColor       =   &H00808080&
  21.       ConvInfo        =   FEZPRINT.FRX:0000
  22.       Height          =   2910
  23.       LargeChangeVert =   900
  24.       Left            =   540
  25.       Top             =   1890
  26.       VirtualHeight   =   6900
  27.       VirtualWidth    =   0
  28.       Width           =   2985
  29.       Begin CommandButton Command1 
  30.          BackColor       =   &H00808080&
  31.          Caption         =   "Measure Text"
  32.          FontBold        =   0   'False
  33.          FontItalic      =   0   'False
  34.          FontName        =   "MS Sans Serif"
  35.          FontSize        =   8.25
  36.          FontStrikethru  =   0   'False
  37.          FontUnderline   =   0   'False
  38.          Height          =   375
  39.          Index           =   12
  40.          Left            =   1395
  41.          TabIndex        =   17
  42.          Top             =   2370
  43.          Width           =   1200
  44.       End
  45.       Begin CommandButton Command1 
  46.          BackColor       =   &H00808080&
  47.          Caption         =   "Fancy Table"
  48.          FontBold        =   0   'False
  49.          FontItalic      =   0   'False
  50.          FontName        =   "MS Sans Serif"
  51.          FontSize        =   8.25
  52.          FontStrikethru  =   0   'False
  53.          FontUnderline   =   0   'False
  54.          Height          =   375
  55.          Index           =   11
  56.          Left            =   1410
  57.          TabIndex        =   16
  58.          Top             =   570
  59.          Width           =   1200
  60.       End
  61.       Begin CommandButton Command1 
  62.          BackColor       =   &H00808080&
  63.          Caption         =   "Line by Line"
  64.          FontBold        =   0   'False
  65.          FontItalic      =   0   'False
  66.          FontName        =   "MS Sans Serif"
  67.          FontSize        =   8.25
  68.          FontStrikethru  =   0   'False
  69.          FontUnderline   =   0   'False
  70.          Height          =   375
  71.          Index           =   0
  72.          Left            =   90
  73.          TabIndex        =   3
  74.          Top             =   75
  75.          Width           =   1200
  76.       End
  77.       Begin CommandButton Command1 
  78.          BackColor       =   &H00808080&
  79.          Caption         =   "Paragraph"
  80.          FontBold        =   0   'False
  81.          FontItalic      =   0   'False
  82.          FontName        =   "MS Sans Serif"
  83.          FontSize        =   8.25
  84.          FontStrikethru  =   0   'False
  85.          FontUnderline   =   0   'False
  86.          Height          =   375
  87.          Index           =   1
  88.          Left            =   1410
  89.          TabIndex        =   4
  90.          Top             =   60
  91.          Width           =   1200
  92.       End
  93.       Begin CommandButton Command1 
  94.          BackColor       =   &H00808080&
  95.          Caption         =   "Tables"
  96.          FontBold        =   0   'False
  97.          FontItalic      =   0   'False
  98.          FontName        =   "MS Sans Serif"
  99.          FontSize        =   8.25
  100.          FontStrikethru  =   0   'False
  101.          FontUnderline   =   0   'False
  102.          Height          =   375
  103.          Index           =   2
  104.          Left            =   90
  105.          TabIndex        =   5
  106.          Top             =   570
  107.          Width           =   1200
  108.       End
  109.       Begin CommandButton Command1 
  110.          BackColor       =   &H00808080&
  111.          Caption         =   "Multi-Column"
  112.          FontBold        =   0   'False
  113.          FontItalic      =   0   'False
  114.          FontName        =   "MS Sans Serif"
  115.          FontSize        =   8.25
  116.          FontStrikethru  =   0   'False
  117.          FontUnderline   =   0   'False
  118.          Height          =   375
  119.          Index           =   3
  120.          Left            =   90
  121.          TabIndex        =   6
  122.          Top             =   1020
  123.          Width           =   1200
  124.       End
  125.       Begin CommandButton Command1 
  126.          BackColor       =   &H00808080&
  127.          Caption         =   "Draw"
  128.          FontBold        =   0   'False
  129.          FontItalic      =   0   'False
  130.          FontName        =   "MS Sans Serif"
  131.          FontSize        =   8.25
  132.          FontStrikethru  =   0   'False
  133.          FontUnderline   =   0   'False
  134.          Height          =   375
  135.          Index           =   4
  136.          Left            =   90
  137.          TabIndex        =   10
  138.          Top             =   1905
  139.          Width           =   1200
  140.       End
  141.       Begin CommandButton Command1 
  142.          BackColor       =   &H00808080&
  143.          Caption         =   "&AlignText"
  144.          FontBold        =   0   'False
  145.          FontItalic      =   0   'False
  146.          FontName        =   "MS Sans Serif"
  147.          FontSize        =   8.25
  148.          FontStrikethru  =   0   'False
  149.          FontUnderline   =   0   'False
  150.          Height          =   375
  151.          Index           =   5
  152.          Left            =   1395
  153.          TabIndex        =   7
  154.          Top             =   1005
  155.          Width           =   1200
  156.       End
  157.       Begin CommandButton Command1 
  158.          BackColor       =   &H00808080&
  159.          Caption         =   "&Indent"
  160.          FontBold        =   0   'False
  161.          FontItalic      =   0   'False
  162.          FontName        =   "MS Sans Serif"
  163.          FontSize        =   8.25
  164.          FontStrikethru  =   0   'False
  165.          FontUnderline   =   0   'False
  166.          Height          =   375
  167.          Index           =   6
  168.          Left            =   90
  169.          TabIndex        =   8
  170.          Top             =   1470
  171.          Width           =   1200
  172.       End
  173.       Begin CommandButton Command1 
  174.          BackColor       =   &H00808080&
  175.          Caption         =   "&Mail Merge"
  176.          FontBold        =   0   'False
  177.          FontItalic      =   0   'False
  178.          FontName        =   "MS Sans Serif"
  179.          FontSize        =   8.25
  180.          FontStrikethru  =   0   'False
  181.          FontUnderline   =   0   'False
  182.          Height          =   375
  183.          Index           =   7
  184.          Left            =   1395
  185.          TabIndex        =   9
  186.          Top             =   1455
  187.          Width           =   1200
  188.       End
  189.       Begin CommandButton Command1 
  190.          BackColor       =   &H00808080&
  191.          Caption         =   "&Graphics"
  192.          FontBold        =   0   'False
  193.          FontItalic      =   0   'False
  194.          FontName        =   "MS Sans Serif"
  195.          FontSize        =   8.25
  196.          FontStrikethru  =   0   'False
  197.          FontUnderline   =   0   'False
  198.          Height          =   375
  199.          Index           =   8
  200.          Left            =   1395
  201.          TabIndex        =   11
  202.          Top             =   1905
  203.          Width           =   1200
  204.       End
  205.       Begin CommandButton Command1 
  206.          BackColor       =   &H00808080&
  207.          Caption         =   "Angle"
  208.          FontBold        =   0   'False
  209.          FontItalic      =   0   'False
  210.          FontName        =   "MS Sans Serif"
  211.          FontSize        =   8.25
  212.          FontStrikethru  =   0   'False
  213.          FontUnderline   =   0   'False
  214.          Height          =   375
  215.          Index           =   10
  216.          Left            =   105
  217.          TabIndex        =   12
  218.          Top             =   2370
  219.          Width           =   1200
  220.       End
  221.    End
  222.    Begin CommandButton Command1 
  223.       BackColor       =   &H00C0C0C0&
  224.       Caption         =   "&Order Form"
  225.       Default         =   -1  'True
  226.       FontBold        =   0   'False
  227.       FontItalic      =   0   'False
  228.       FontName        =   "MS Sans Serif"
  229.       FontSize        =   8.25
  230.       FontStrikethru  =   0   'False
  231.       FontUnderline   =   0   'False
  232.       Height          =   510
  233.       Index           =   9
  234.       Left            =   540
  235.       TabIndex        =   13
  236.       Top             =   5025
  237.       Width           =   2985
  238.    End
  239.    Begin ComboBox cmbOrientation 
  240.       Enabled         =   0   'False
  241.       FontBold        =   0   'False
  242.       FontItalic      =   0   'False
  243.       FontName        =   "MS Sans Serif"
  244.       FontSize        =   8.25
  245.       FontStrikethru  =   0   'False
  246.       FontUnderline   =   0   'False
  247.       Height          =   315
  248.       Left            =   2385
  249.       Style           =   2  'Dropdown List
  250.       TabIndex        =   0
  251.       Top             =   990
  252.       Width           =   1065
  253.    End
  254.    Begin CommandButton cmdPrint 
  255.       BackColor       =   &H00C0C0C0&
  256.       Caption         =   "&Print"
  257.       Enabled         =   0   'False
  258.       FontBold        =   0   'False
  259.       FontItalic      =   0   'False
  260.       FontName        =   "MS Sans Serif"
  261.       FontSize        =   8.25
  262.       FontStrikethru  =   0   'False
  263.       FontUnderline   =   0   'False
  264.       Height          =   300
  265.       Left            =   7680
  266.       TabIndex        =   2
  267.       Top             =   75
  268.       Width           =   1095
  269.    End
  270.    Begin vsViewPort vsViewPort1 
  271.       BackColor       =   &H00808080&
  272.       ConvInfo        =   FEZPRINT.FRX:000B
  273.       Height          =   5835
  274.       Left            =   4350
  275.       Top             =   435
  276.       VirtualHeight   =   0
  277.       VirtualWidth    =   0
  278.       Width           =   4440
  279.       Begin vsPrinter vsPrinter 
  280.          BackColor       =   &H00FFFFFF&
  281.          BrushColor      =   &H0080FFFF&
  282.          ConvInfo        =   FEZPRINT.FRX:0016
  283.          FontName        =   "Arial"
  284.          FontSize        =   40
  285.          Footer          =   "||Page %d"
  286.          HdrColor        =   &H00800000&
  287.          HdrFontBold     =   -1  'True
  288.          HdrFontItalic   =   -1  'True
  289.          HdrFontName     =   "Arial"
  290.          HdrFontSize     =   24
  291.          Header          =   "|VideoSoft VSView"
  292.          Height          =   1335
  293.          Left            =   195
  294.          PenWidth        =   2
  295.          TableSep        =   "|;"
  296.          Top             =   195
  297.          Width           =   1065
  298.       End
  299.    End
  300.    Begin ComboBox cmbZoom 
  301.       Enabled         =   0   'False
  302.       FontBold        =   0   'False
  303.       FontItalic      =   0   'False
  304.       FontName        =   "MS Sans Serif"
  305.       FontSize        =   8.25
  306.       FontStrikethru  =   0   'False
  307.       FontUnderline   =   0   'False
  308.       Height          =   315
  309.       Left            =   2400
  310.       Style           =   2  'Dropdown List
  311.       TabIndex        =   1
  312.       Top             =   1395
  313.       Width           =   1050
  314.    End
  315.    Begin Image Image4 
  316.       Height          =   720
  317.       Left            =   300
  318.       Picture         =   FEZPRINT.FRX:0021
  319.       Top             =   135
  320.       Width           =   3480
  321.    End
  322.    Begin Image Image3 
  323.       Height          =   510
  324.       Left            =   5715
  325.       Picture         =   FEZPRINT.FRX:2FDB
  326.       Stretch         =   -1  'True
  327.       Top             =   -15
  328.       Visible         =   0   'False
  329.       Width           =   750
  330.    End
  331.    Begin Image Image2 
  332.       Height          =   330
  333.       Left            =   5070
  334.       Picture         =   FEZPRINT.FRX:C335
  335.       Stretch         =   -1  'True
  336.       Top             =   90
  337.       Visible         =   0   'False
  338.       Width           =   540
  339.    End
  340.    Begin Label Label1 
  341.       Alignment       =   2  'Center
  342.       AutoSize        =   -1  'True
  343.       BackStyle       =   0  'Transparent
  344.       Caption         =   "Orient."
  345.       FontBold        =   0   'False
  346.       FontItalic      =   0   'False
  347.       FontName        =   "MS Sans Serif"
  348.       FontSize        =   8.25
  349.       FontStrikethru  =   0   'False
  350.       FontUnderline   =   0   'False
  351.       ForeColor       =   &H00000000&
  352.       Height          =   195
  353.       Index           =   2
  354.       Left            =   1680
  355.       TabIndex        =   15
  356.       Top             =   1020
  357.       Width           =   495
  358.    End
  359.    Begin Label Label1 
  360.       Alignment       =   2  'Center
  361.       AutoSize        =   -1  'True
  362.       BackStyle       =   0  'Transparent
  363.       Caption         =   "Zoom"
  364.       FontBold        =   0   'False
  365.       FontItalic      =   0   'False
  366.       FontName        =   "MS Sans Serif"
  367.       FontSize        =   8.25
  368.       FontStrikethru  =   0   'False
  369.       FontUnderline   =   0   'False
  370.       ForeColor       =   &H00000000&
  371.       Height          =   195
  372.       Index           =   1
  373.       Left            =   1710
  374.       TabIndex        =   14
  375.       Top             =   1410
  376.       Width           =   435
  377.    End
  378.    Begin Image Image1 
  379.       Height          =   420
  380.       Left            =   885
  381.       Picture         =   FEZPRINT.FRX:CED7
  382.       Top             =   1020
  383.       Width           =   420
  384.    End
  385. Option Explicit
  386. Dim MyPage%         'Keep the output view to be printed
  387. Dim OldOrientation  'Don't mess with my printer settings
  388. Sub cmbOrientation_Click ()
  389.   mousepointer = 11
  390.   vsPrinter.Orientation = cmbOrientation.ListIndex
  391.   cmbZoom_click
  392.   If MyPage >= 0 Then Command1_Click MyPage
  393.   mousepointer = 0
  394. End Sub
  395. Sub cmbZoom_click ()
  396.   vsPrinter.Visible = False
  397.   mousepointer = 11
  398.   'Change the screen size to zoom value
  399.   vsPrinter.Width = vsPrinter.PageWidth * Val(cmbZoom) / 100
  400.   vsPrinter.Height = vsPrinter.PageHeight * Val(cmbZoom) / 100
  401.   'Make scrollable ViewPort
  402.   vsViewPort1.VirtualWidth = vsPrinter.Width + 100
  403.   vsViewPort1.VirtualHeight = vsPrinter.Height + 200
  404.   ' center printer if it fit on the screen
  405.   If vsPrinter.Width < vsViewPort1.Width Then vsPrinter.Left = (vsViewPort1.Width - vsPrinter.Width) / 2
  406.   If vsPrinter.Height < vsViewPort1.Height Then vsPrinter.Top = (vsViewPort1.Height - vsPrinter.Height) / 2
  407.   mousepointer = 0
  408.   vsPrinter.Visible = True
  409. End Sub
  410. Sub cmdPrint_Click ()
  411.   ' get ready to print
  412.   cmdPrint.Enabled = False
  413.   mousepointer = 11
  414.   ' print to the printer
  415.   vsPrinter.Preview = False
  416.   Command1_Click MyPage
  417.   vsPrinter.Preview = True
  418.   ' all done
  419.   cmdPrint.Enabled = True
  420.   mousepointer = 0
  421. End Sub
  422. Sub Command1_Click (Index%)
  423.       
  424.   ' remember page for use with Print command
  425.   MyPage = Index%
  426.   ' we have a print job, so let's enable these guys
  427.   cmbZoom.Enabled = True
  428.   cmdPrint.Enabled = True
  429.   cmbOrientation.Enabled = True
  430.   ' start the print preview job
  431.   vsPrinter.Action = 3 ' StartDoc
  432.   If vsPrinter.Error Then Beep: Exit Sub
  433.   mousepointer = 11
  434.   ' set default style
  435.   vsPrinter.FontName = "Arial"
  436.   vsPrinter.FontSize = 40
  437.   vsPrinter.FontBold = False
  438.   vsPrinter.FontItalic = False
  439.   vsPrinter.TextAlign = 0  'Left
  440.   vsPrinter.TableBorder = 7
  441.   vsPrinter.PageBorder = 3
  442.   vsPrinter.PenStyle = 0
  443.   vsPrinter.BrushStyle = 0
  444.   vsPrinter.PenWidth = 2
  445.   vsPrinter.PenColor = 0
  446.   vsPrinter.BrushColor = 0
  447.   vsPrinter.TextColor = 0
  448.   vsPrinter.Columns = 1
  449.   ' choose what to print based on button index
  450.   Select Case Index
  451.     Case 0: DoLine
  452.     Case 1: DoParagraph
  453.     Case 2: DoTable
  454.     Case 3: DoColumns
  455.     Case 4: DoDrawing
  456.     Case 5: DoAlign
  457.     Case 6: DoIndent
  458.     Case 7: DoMailMerge "Joe Smith", "Chief Financial Officer"
  459.             DoMailMerge "Mary Kerney", "President"
  460.     Case 8: DoGraphics
  461.     Case 9: DoOrder
  462.     Case 10: DoAngle
  463.     Case 11: DoFancyTable
  464.   End Select
  465.   ' all done
  466.   vsPrinter.Action = 6 'End Document
  467.   mousepointer = 0
  468. End Sub
  469. Sub DoAlign ()
  470.       
  471.       ' show page title
  472.       vsPrinter.SpaceAfter = 500
  473.       vsPrinter.TextColor = QBColor(1)
  474.       vsPrinter.TextAlign = 1  'Center
  475.       vsPrinter.FontUnderline = True
  476.       vsPrinter.Paragraph = ""
  477.       vsPrinter.Paragraph = "VSPrinter automatically aligns proportional fonts"
  478.       vsPrinter.FontUnderline = False
  479.       
  480.       ' show off
  481.       vsPrinter.FontSize = 20
  482.       vsPrinter.TextColor = QBColor(0)
  483.       vsPrinter.CurrentY = vsPrinter.PageHeight / 2
  484.       vsPrinter.CurrentX = vsPrinter.MarginLeft
  485.       vsPrinter.TextAlign = 2  'Rigth
  486.       vsPrinter.Paragraph = "Text is right aligned"
  487.       vsPrinter.TextAlign = 1  'Center
  488.       vsPrinter.Paragraph = "Text is centered"
  489.       vsPrinter.TextAlign = 0  'Left
  490.       vsPrinter.Paragraph = "Text is left aligned"
  491.       vsPrinter.SpaceAfter = 0
  492. End Sub
  493. Sub DoAngle ()
  494.       Dim i%, j%
  495.       ' show page title
  496.       vsPrinter.TextAngle = 450
  497.       vsPrinter = ""
  498.       vsPrinter = ""
  499.       vsPrinter = ""
  500.       vsPrinter = ""
  501.       vsPrinter = "Rotate text"
  502.       vsPrinter = "to any angle"
  503.       
  504.       ' rotate Text
  505.       j = 1
  506.       For i = 450 To 3600 Step 900
  507.         vsPrinter.TextColor = QBColor(j)
  508.         vsPrinter.CurrentX = vsPrinter.PageWidth * .5
  509.         vsPrinter.CurrentY = vsPrinter.PageHeight * .5
  510.         vsPrinter.TextAngle = i
  511.         vsPrinter.Text = "VSView"
  512.         j = j + 1
  513.       Next
  514.       ' restore defaults
  515.       vsPrinter.TextAngle = 0
  516.       vsPrinter.TextColor = 0
  517. End Sub
  518. Sub DoColumns ()
  519.       Dim s$, i%
  520.       ' set multi-column mode
  521.       vsPrinter.Columns = 2
  522.       
  523.       ' create a string to print
  524.       s = "VSPrinter can also print in multiple columns. "
  525.       s = s + "You have control over column breaks, and you can save "
  526.       s = s + "a whole lot of paper by using multiple columns."
  527.       
  528.       ' print text in two colors just for fun
  529.       vsPrinter.TextColor = QBColor(1)
  530.       vsPrinter = s
  531.       vsPrinter = ""
  532.       vsPrinter.TextColor = QBColor(0)
  533.       vsPrinter = s
  534. End Sub
  535. Sub DoDrawing ()
  536.       Dim s$, x%, y%
  537.       ' go to center of the page
  538.       vsPrinter.CurrentX = vsPrinter.PageWidth / 2
  539.       vsPrinter.CurrentY = vsPrinter.PageHeight / 2
  540.       ' start with some text
  541.       vsPrinter.TextAlign = 1
  542.       vsPrinter.TextColor = &H800000       'Blue
  543.       vsPrinter = "Add graphics to your reports!"
  544.       vsPrinter.TextColor = &H0&           'Black
  545.       vsPrinter = "With VSPrinter, it's easy!"
  546.       vsPrinter.TextAlign = 0              ' Left
  547.       ' draw graphics with primitives
  548.       vsPrinter.X1 = vsPrinter.PageWidth / 4 * .25
  549.       vsPrinter.Y1 = vsPrinter.PageHeight / 4 * .25
  550.       vsPrinter.X2 = vsPrinter.PageWidth / 4 * 1.25
  551.       vsPrinter.Y2 = vsPrinter.PageHeight / 4 * 1.25
  552.       vsPrinter.BrushColor = &HFF&         'Red
  553.       vsPrinter.BrushStyle = 6             'Cross
  554.       vsPrinter.Draw = 3                   'Circle
  555.       vsPrinter.X1 = vsPrinter.PageWidth * .7
  556.       vsPrinter.Y1 = vsPrinter.PageHeight * .7
  557.       vsPrinter.X2 = vsPrinter.PageWidth * .9
  558.       vsPrinter.Y2 = vsPrinter.PageHeight * .9
  559.       vsPrinter.BrushColor = &H800080      'Purple
  560.       vsPrinter.BrushStyle = 7             'Cross Diagonal
  561.       vsPrinter.Draw = 2                   'Rect.
  562.       ' polylines are good for charts, graphs, maps etc...
  563.       s = ""
  564.       For x = vsPrinter.MarginLeft To vsPrinter.PageWidth - vsPrinter.MarginRight Step 20
  565.         y = 3000 + Cos(x * 3.1416 / 180) * (x - vsPrinter.PageWidth / 2) / 10
  566.         s = s + Str(x) + Str(y)
  567.       Next
  568.       vsPrinter.PenWidth = 30
  569.       vsPrinter.PolyLine = s
  570.       vsPrinter.PenWidth = 0
  571. End Sub
  572. Sub DoFancyTable ()
  573.     Dim f$, s$, tw, savx
  574.     Dim sp%
  575.     ' initialize
  576.     f = "2000|1800|^1440|^2200;"
  577.     tw = 2000 + 1800 + 1440 + 2200
  578.     s = "Country|Capital|GNP|Comments"
  579.     ' print page title
  580.     vsPrinter.TextAlign = 1    'Center
  581.     vsPrinter.FontSize = 40
  582.     vsPrinter = ""
  583.     vsPrinter = "Shading Tables"
  584.     vsPrinter.FontSize = 18
  585.     vsPrinter = ""
  586.     vsPrinter = ""
  587.     ' save row start position
  588.     Select Case vsPrinter.TextAlign
  589.       Case 0: vsPrinter.X1 = vsPrinter.CurrentX
  590.       Case 1: vsPrinter.X1 = (vsPrinter.PageWidth - tw) / 2
  591.       Case 2: vsPrinter.X1 = vsPrinter.PageWidth - tw - vsPrinter.MarginRight
  592.     End Select
  593.     savx = vsPrinter.X1
  594.     vsPrinter.Y1 = vsPrinter.CurrentY
  595.     ' print header just to measure row
  596.     vsPrinter.FontBold = True
  597.     vsPrinter.Table = f + s
  598.     ' save row end position
  599.     vsPrinter.X2 = vsPrinter.X1 + tw
  600.     vsPrinter.Y2 = vsPrinter.CurrentY
  601.     ' use saved positions to draw light shading
  602.     vsPrinter.BrushStyle = 0
  603.     vsPrinter.BrushColor = RGB(255, 255, 0)
  604.     vsPrinter.PenColor = vsPrinter.BrushColor
  605.     vsPrinter.Draw = 2 ' rectangle
  606.     vsPrinter.PenColor = 0
  607.       
  608.       
  609.     ' the shading erased the row, so let's go again
  610.     vsPrinter.CurrentX = savx
  611.     vsPrinter.CurrentY = vsPrinter.Y1
  612.     vsPrinter.Table = f + s
  613.       
  614.     ' disable header coloring
  615.     vsPrinter.TextColor = 0
  616.     sp = MyPage
  617.     MyPage = -1
  618.     ' do the table body
  619.     vsPrinter.FontBold = False
  620.     s = f + "Argentina|Buenos Aires|50|Tango land;"
  621.     s = s + "Brazil|Brasilia|150|Lambada, anyone?;"
  622.     s = s + "Chile|Santiago|25|This has nothing to do with beans!;"
  623.     vsPrinter.Table = s
  624.     '  let's try some pictures on the table
  625.     vsPrinter.FontSize = 40
  626.     vsPrinter = ""
  627.     vsPrinter = "Pictures on Tables"
  628.     vsPrinter.FontSize = 14
  629.     vsPrinter = ""
  630.     vsPrinter = ""
  631.     ' initialize
  632.     f = "2000|>720|7000;"
  633.     tw = 2000 + 720 + 7000
  634.     s = "Control||Comments;"
  635.     vsPrinter.TextAlign = 0    'Left
  636.     vsPrinter.X1 = vsPrinter.CurrentX
  637.     vsPrinter.Y1 = vsPrinter.CurrentY
  638.     ' print header just to measure row
  639.     vsPrinter.FontBold = True
  640.     vsPrinter.Table = f + s
  641.     ' save row end position
  642.     vsPrinter.X2 = vsPrinter.X1 + tw
  643.     vsPrinter.Y2 = vsPrinter.CurrentY
  644.     ' just for kicks, put a picture in cell 2
  645.     vsPrinter.X1 = vsPrinter.X1 + 2000
  646.     vsPrinter.X2 = vsPrinter.X1 + 720
  647.     vsPrinter.Picture = image1
  648.     s = "Grid|No|Limited functionality;"
  649.     s = s + "vsPrinter|Yes|Very powerful"
  650.     vsPrinter.Table = f + s
  651.     ' restore defaults
  652.     MyPage = sp
  653. End Sub
  654. Sub DoGraphics ()
  655.     Dim s$, fmt$
  656.     ' print page title
  657.     vsPrinter = ""
  658.     vsPrinter.CurrentX = 2500
  659.     vsPrinter.TextColor = QBColor(1)
  660.     vsPrinter = "Metafiles and Bitmaps"
  661.     vsPrinter.TextColor = QBColor(0)
  662.     vsPrinter.FontSize = 28
  663.     vsPrinter = ""
  664.     s = "You can now print and preview reports that "
  665.     s = s + "include bitmaps and metafiles.  "
  666.     s = s + "Automate desktop publishing with vsView!!!!"
  667.     vsPrinter = s
  668.     vsPrinter = ""
  669.     ' print pictures, stretch and align anywhere on the page
  670.     vsPrinter.X1 = 1000
  671.     vsPrinter.Y1 = 1000
  672.     vsPrinter.X2 = 2400
  673.     vsPrinter.Y2 = 2400
  674.     vsPrinter.Picture = image3.Picture
  675.     vsPrinter.X1 = vsPrinter.CurrentX
  676.     vsPrinter.Y1 = vsPrinter.CurrentY
  677.     vsPrinter.X2 = vsPrinter.PageWidth - vsPrinter.MarginRight
  678.     vsPrinter.Y2 = vsPrinter.PageHeight - vsPrinter.MarginBottom
  679.     vsPrinter.Picture = image3.Picture
  680.       
  681. End Sub
  682. Sub DoIndent ()
  683.     ' indent left, right, or center
  684.     vsPrinter.IndentFirst = 1000
  685.     vsPrinter = "You can automatically indent the FIRST LINE of a paragraph."
  686.     vsPrinter = ""
  687.     vsPrinter.IndentFirst = 0
  688.     vsPrinter.IndentLeft = 1000
  689.     vsPrinter = "You can automatically indent from the LEFT margin of the page."
  690.     vsPrinter = ""
  691.     vsPrinter.IndentLeft = 0
  692.     vsPrinter.IndentRight = 1000
  693.     vsPrinter = "You can automatically indent from the RIGHT margin of the page."
  694.     vsPrinter = ""
  695.     vsPrinter.IndentLeft = 1000
  696.     vsPrinter.IndentFirst = 1500
  697.     vsPrinter = "Or combine all types of indentation."
  698.     ' restore defaults
  699.     vsPrinter.IndentLeft = 0
  700.     vsPrinter.IndentFirst = 0
  701.     vsPrinter.IndentRight = 0
  702. End Sub
  703. Sub DoLine ()
  704.       
  705.       ' start a line or paragraph with one font
  706.       vsPrinter.TextColor = 0
  707.       vsPrinter = ""
  708.       vsPrinter.Text = "With VSPrinter you can print "
  709.       ' continue with a different font
  710.       vsPrinter.FontBold = True
  711.       vsPrinter.TextColor = RGB(255, 0, 255)
  712.       vsPrinter.Text = "Line by Line"
  713.       
  714.       ' and finish with the original font!
  715.       vsPrinter.TextColor = 0
  716.       vsPrinter.FontBold = False
  717.       vsPrinter.Text = " just like you would in VB."
  718.       vsPrinter.Text = " Text wraps automatically, so your life becomes easier."
  719. End Sub
  720. Sub DoMailMerge (FullName$, Position$)
  721.     ' get ready to print with "corporate" font
  722.     vsPrinter.FontBold = False
  723.     vsPrinter.FontSize = 24
  724.     vsPrinter.TextColor = 0
  725.     ' you could print a letterhead here...
  726.     ' date and salutation...
  727.     vsPrinter = Format$(Now, "mmmm d, yyyy")
  728.     vsPrinter = ""
  729.     vsPrinter = ""
  730.     vsPrinter.Text = "This letter is to inform that "
  731.     ' print person name and new position
  732.     vsPrinter.TextColor = RGB(255, 0, 0)
  733.     vsPrinter.Text = FullName
  734.     vsPrinter.TextColor = 0
  735.     vsPrinter.Text = " has been promoted to "
  736.     vsPrinter.TextColor = RGB(255, 0, 0)
  737.     vsPrinter.Text = Position
  738.     vsPrinter.TextColor = 0
  739.     vsPrinter.Text = " of this company."
  740.     ' skip an inch instead of breaking pages (with Action property)
  741.     vsPrinter.CurrentY = vsPrinter.CurrentY + 1440
  742.     vsPrinter.CurrentX = vsPrinter.MarginLeft
  743. End Sub
  744. Sub DoOrder ()
  745.     Dim fmt$, s$, INCHES%
  746.     ' initialize
  747.     INCHES = 1440
  748.     vsPrinter.FontSize = 30
  749.     vsPrinter.FontBold = True
  750.     ' place money picture
  751.     vsPrinter.X1 = vsPrinter.PageWidth - (2.5 * INCHES)
  752.     vsPrinter.Y1 = .75 * INCHES
  753.     vsPrinter.X2 = vsPrinter.X1 + (2 * INCHES)
  754.     vsPrinter.Y2 = vsPrinter.Y1 + (1.25 * INCHES)
  755.     vsPrinter.Picture = image2.Picture
  756.     ' print title
  757.     vsPrinter.CurrentY = .75 * INCHES
  758.     vsPrinter = "ORDER FORM"
  759.     vsPrinter.PenWidth = 2
  760.     vsPrinter.FontSize = 10
  761.     vsPrinter.FontBold = False
  762.     vsPrinter = "Please rush my order to the following address:"
  763.     vsPrinter = ""
  764.     ' print table to hold customer name and address
  765.     fmt = "2500|>4500;" ' column widths in Twips (1440 = 1 inch)
  766.     s = fmt
  767.     s = s + "Name|;"
  768.     s = s + "Company|;"
  769.     s = s + "Address|;"
  770.     s = s + "|;"
  771.     s = s + "|;"
  772.     s = s + "|;"
  773.     s = s + "Phone|;"
  774.     s = s + "Fax|;"
  775.     s = s + "Credit Card #|;"
  776.     s = s + "Expiration Date|;"
  777.     s = s + "Comments|;"
  778.     s = s + "|;"
  779.     s = s + "|;"
  780.     vsPrinter.TableBorder = 5 ' columns
  781.     vsPrinter.Table = s
  782.     ' some fine print...
  783.     vsPrinter = ""
  784.     vsPrinter = ""
  785.     vsPrinter = "Fax your credit card order to 510-843-0174 or mail your check or money order to: VideoSoft, 2625 Alcatraz Avenue, Suite 271, Berkeley, California 94705.  Sorry no CODs."
  786.     vsPrinter = ""
  787.     ' another table for quantities and amounts (let's center this one)
  788.     vsPrinter.TextAlign = 1   ' center
  789.     vsPrinter.TableBorder = 7 ' all
  790.     fmt = "^2000|^4000|^2000|^2000;"
  791.     s = fmt
  792.     s = s + "QUANTITY|COPIES OF|PRICE|TOTAL;"
  793.     vsPrinter.Table = s
  794.     ' print body in 4 columns but with different column alignment
  795.     fmt = "^2000|4000|>2000|>2000;"
  796.     s = fmt
  797.     s = s + "VBX Controls|||;"
  798.     s = s + "|VideoSoft VSVBX|$45.00|;"
  799.     s = s + "|VideoSoft VSView|$99.00|;"
  800.     s = s + "|VideoSoft VSFlex|$99.00|;"
  801.     s = s + "OLE Controls|||;"
  802.     s = s + "|VideoSoft VSView/OCX|$149.00|;"
  803.     s = s + "|VideoSoft VS-OCX|$99.00|;"
  804.     s = s + "|VideoSoft VSFlex/OCX|$149.00|;"
  805.     vsPrinter.Table = s
  806.     ' now append another table with only 2 columns
  807.     fmt = ">8000|>2000;"
  808.     s = fmt
  809.     s = s + "California state residents add 8.5% sales tax|;"
  810.     s = s + "Shipping and Handling Domestic|US$7.00;"
  811.     s = s + "Shipping and Handling International|US$10.00;"
  812.     s = s + "TOTAL|;"
  813.     vsPrinter.Table = s
  814. End Sub
  815. Sub DoParagraph ()
  816.     Dim s$
  817.     ' print paragraphs by assigning a string to the printer
  818.     s = "You can print whole paragraphs at once! This is very easy. "
  819.     vsPrinter.Paragraph = s + s
  820.     vsPrinter.Paragraph = ""
  821.     vsPrinter.Paragraph = "VSPrinter takes care of indentation, wrapping, spacing, etc."
  822. End Sub
  823. Sub DoTable ()
  824.     Dim s$, fmt$
  825.     ' print page title
  826.     vsPrinter = "Print by Table"
  827.     vsPrinter.FontSize = 18
  828.     vsPrinter = ""
  829.     s = "You can now print reports that include paragraphs "
  830.     s = s + "and tables.  With VSView, printing a grid it is very easy."
  831.     vsPrinter = s
  832.     vsPrinter = ""
  833.     ' create table format
  834.     fmt = "2500|>1600|^1600|>2100|>2200;"                   '^Center > Right
  835.     ' create table string
  836.     s = fmt + "Product|Code|Region|Units Sold|Revenue;"     'Set header
  837.     s = s + "Spam in a Can|00012|North|372|$23,542;"
  838.     s = s + "Flipper Tuna|00231|North|832|$44,432;"
  839.     s = s + "Jiffy Lubed Butter|00978|North|452|$53,535"
  840.     ' print the table in three flavors
  841.     vsPrinter.PenWidth = 1
  842.     vsPrinter.TextAlign = 1
  843.     vsPrinter.FontSize = 18
  844.     vsPrinter.TableBorder = 7
  845.     vsPrinter.Table = s         ' flavor 1
  846.     vsPrinter = ""
  847.     vsPrinter.FontSize = 14
  848.     vsPrinter.TableBorder = 8
  849.     vsPrinter.Table = s         ' flavor 2
  850.     vsPrinter = ""
  851.     vsPrinter = ""
  852.     vsPrinter.TableBorder = 9
  853.     vsPrinter.Table = s         ' flavor 3
  854.     ' and resume printing regular text
  855.     vsPrinter = "Same table, different alignment and borders."
  856. End Sub
  857. Sub Form_Load ()
  858.   ' save orientation to clean up later
  859.   OldOrientation = vsPrinter.Orientation
  860.   ' initialize
  861.   MyPage = -1    ' no current page
  862.   vsPrinter.Preview = True
  863.   vsPrinter.PreviewPage = 1
  864.   ' preset zoom levels (you can choose your own)
  865.   cmbZoom.AddItem "35"
  866.   'cmbZoom.AddItem "50"
  867.   cmbZoom.AddItem "75"
  868.   cmbZoom.AddItem "100"
  869.   cmbZoom.AddItem "150"
  870.   cmbZoom.AddItem "200"
  871.   cmbZoom.ListIndex = 0
  872.   ' orientation (you cannot choose your own)
  873.   cmbOrientation.AddItem "Portrait"
  874.   cmbOrientation.AddItem "Landscape"
  875.   cmbOrientation.ListIndex = 0
  876.   ' ready, set default page to 0
  877.   MyPage = 0
  878. End Sub
  879. Sub Form_Unload (Cancel As Integer)
  880.   ' restore printer orientation
  881.   vsPrinter.Orientation = OldOrientation
  882. End Sub
  883. Sub vsPrinter_NewTableCell (row As Integer, Column As Integer, Cell As String)
  884.   ' only when printing Table Example
  885.   If MyPage <> 2 Then Exit Sub
  886.   ' change color of hte headers (row 1)
  887.   If row = 1 Then
  888.     vsPrinter.TextColor = QBColor(Column)
  889.   Else
  890.     vsPrinter.TextColor = 1
  891.   End If
  892. End Sub
  893.