home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / VISUAL_B / CODIGO_1 / BAR_VBX / FORM1.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1993-12-22  |  7.3 KB  |  234 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "BarCode/VBX Sample"
  4.    ClientHeight    =   3336
  5.    ClientLeft      =   900
  6.    ClientTop       =   1920
  7.    ClientWidth     =   5856
  8.    Height          =   3756
  9.    Left            =   852
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   3336
  12.    ScaleWidth      =   5856
  13.    Top             =   1548
  14.    Width           =   5952
  15.    Begin BarCode BarCode2 
  16.       BarCodeType     =   0  'Code 3 of 9
  17.       Checksum        =   0
  18.       Height          =   672
  19.       Left            =   4500
  20.       NarrowBarWidth  =   2
  21.       Ratio           =   0  '3:1
  22.       Rotation        =   0  'Normal
  23.       Text            =   ""
  24.       Top             =   600
  25.       Visible         =   0   'False
  26.       Width           =   1212
  27.    End
  28.    Begin CommandButton Command3 
  29.       Caption         =   "P&rint Printer"
  30.       Height          =   432
  31.       Left            =   3720
  32.       TabIndex        =   6
  33.       Top             =   2760
  34.       Width           =   1992
  35.    End
  36.    Begin CommandButton PrintFormBtn 
  37.       Caption         =   "Print &Form"
  38.       Height          =   432
  39.       Left            =   1860
  40.       TabIndex        =   5
  41.       Top             =   2760
  42.       Width           =   1752
  43.    End
  44.    Begin CommandButton Command2 
  45.       Caption         =   "&Bound Sample..."
  46.       Height          =   432
  47.       Left            =   60
  48.       TabIndex        =   4
  49.       Top             =   2160
  50.       Width           =   1692
  51.    End
  52.    Begin CommonDialog CMDialog1 
  53.       CancelError     =   -1  'True
  54.       Left            =   5280
  55.       PrinterDefault  =   0   'False
  56.       Top             =   60
  57.    End
  58.    Begin CommandButton Command1 
  59.       Cancel          =   -1  'True
  60.       Caption         =   "&Cancel"
  61.       Height          =   432
  62.       Left            =   1860
  63.       TabIndex        =   2
  64.       Top             =   2160
  65.       Width           =   1752
  66.    End
  67.    Begin BarCode BarCode1 
  68.       BarCodeType     =   0  'Code 3 of 9
  69.       Checksum        =   0
  70.       Height          =   672
  71.       Left            =   180
  72.       NarrowBarWidth  =   2
  73.       Ratio           =   0  '3:1
  74.       Rotation        =   0  'Normal
  75.       Text            =   ""
  76.       Top             =   600
  77.       Width           =   3456
  78.    End
  79.    Begin CommandButton Print 
  80.       Caption         =   "&Print w/Selection"
  81.       Height          =   432
  82.       Left            =   60
  83.       TabIndex        =   1
  84.       Top             =   2760
  85.       Width           =   1692
  86.    End
  87.    Begin TextBox Text1 
  88.       FontBold        =   0   'False
  89.       FontItalic      =   0   'False
  90.       FontName        =   "MS Sans Serif"
  91.       FontSize        =   9.6
  92.       FontStrikethru  =   0   'False
  93.       FontUnderline   =   0   'False
  94.       Height          =   360
  95.       Left            =   120
  96.       TabIndex        =   0
  97.       Text            =   "Text1"
  98.       Top             =   180
  99.       Width           =   3072
  100.    End
  101.    Begin Label Label1 
  102.       Caption         =   "Double Click on BarCode to set Properties."
  103.       Height          =   312
  104.       Left            =   60
  105.       TabIndex        =   3
  106.       Top             =   1620
  107.       Width           =   4332
  108.    End
  109. Sub BarCode1_DblClick ()
  110.     Form2.Show 1
  111. End Sub
  112. Sub Command1_Click ()
  113.     End
  114. End Sub
  115. Sub Command2_Click ()
  116.     Form3.Show 1
  117. End Sub
  118. Sub Command3_Click ()
  119.     BarCode1.PrinterTop = 50
  120.     BarCode1.PrinterLeft = 0
  121.     BarCode1.PrinterHeight = 100
  122.     BarCode1.PrinterBarWidth = BarCode1.NarrowBarWidth * 2
  123.     BarCode1.PrinterHDC = Printer.hDC
  124.     If BarCodeGetLastErrorCode() <> False Then
  125.     MsgBox BarCodeGetLastErrorString()
  126.     End If
  127.     Printer.CurrentX = 0
  128.     Printer.CurrentY = 0
  129.     Printer.Print "Part Number";
  130.     Printer.CurrentX = 5000
  131.     Printer.Print "Serial Number";
  132.     BarCode1.PrinterLeft = 835
  133.     BarCode1.PrinterHDC = Printer.hDC
  134.     If BarCodeGetLastErrorCode() <> False Then
  135.     MsgBox BarCodeGetLastErrorString()
  136.     End If
  137.     Printer.NewPage
  138.     Printer.EndDoc
  139. End Sub
  140. Sub Form_Load ()
  141.     Text1.Text = "123456"
  142. End Sub
  143. Sub Print_Click ()
  144.     Dim DOCINFO As DOCINFO
  145.     Dim StopPrint As Integer
  146.     Dim OutStr As String
  147.     Dim hOldFont As Integer
  148.     Dim theScaleMode As Integer
  149.     StopPrint = False
  150.     On Error GoTo PrintErr:
  151.                    
  152.     CMDialog1.Flags = PD_RETURNDC Or PD_PRINTSETUP
  153.     CMDialog1.Action = 5
  154.     If StopPrint = False Then
  155.     Screen.MousePointer = 11
  156.     theScaleMode = 6 ' Millimeters
  157.     CreateObjects
  158.     DOCINFO.cbSize = 0
  159.     DOCINFO.DocName = 0
  160.     DOCINFO.Output = 0
  161.     Ok = StartDoc(CMDialog1.hDC, DOCINFO)
  162.     Ok = StartPage(CMDialog1.hDC)
  163.     hOldFont = SelectObject(CMDialog1.hDC, hTextFont)
  164.     PrintText CMDialog1.hDC, "Part Number (P)", 0, 0, hTextFont, theScaleMode
  165.     PrintText CMDialog1.hDC, "123-ABC", 0, 4, hDataFont, theScaleMode
  166.     BarCode2.BarCodeType = 0
  167.     BarCode2.Text = "P" & "123-ABC" & Chr(0)
  168.     BarCode2.PrinterTop = 13
  169.     BarCode2.PrinterLeft = 0
  170.     BarCode2.PrinterHeight = 12
  171.     BarCode2.PrinterBarWidth = 4
  172.     BarCode2.PrinterScaleMode = theScaleMode
  173.     BarCode2.PrinterHDC = CMDialog1.hDC
  174.     If BarCodeGetLastErrorCode() <> False Then
  175.         MsgBox BarCodeGetLastErrorString()
  176.     End If
  177.     PrintText CMDialog1.hDC, "Serial Number (S)", 85, 0, hTextFont, theScaleMode
  178.     PrintText CMDialog1.hDC, "987654", 85, 4, hDataFont, theScaleMode
  179.     BarCode2.BarCodeType = 0
  180.     BarCode2.Text = "S" & "987654" & Chr(0)
  181.     BarCode2.PrinterTop = 13
  182.     BarCode2.PrinterLeft = 85
  183.     BarCode2.PrinterHeight = 12
  184.     BarCode2.PrinterBarWidth = 4
  185.     BarCode2.PrinterHDC = CMDialog1.hDC
  186.     If BarCodeGetLastErrorCode() <> False Then
  187.         MsgBox BarCodeGetLastErrorString()
  188.     End If
  189.     PrintText CMDialog1.hDC, "P.O. Number (N)", 0, 30, hTextFont, theScaleMode
  190.     PrintText CMDialog1.hDC, "546789", 0, 34, hDataFont, theScaleMode
  191.     BarCode2.BarCodeType = 0
  192.     BarCode2.Text = "N" & "546789" & Chr(0)
  193.     BarCode2.PrinterTop = 42
  194.     BarCode2.PrinterLeft = 0
  195.     BarCode2.PrinterHeight = 12
  196.     BarCode2.PrinterBarWidth = 4
  197.     BarCode2.PrinterHDC = CMDialog1.hDC
  198.     If BarCodeGetLastErrorCode() <> False Then
  199.         MsgBox BarCodeGetLastErrorString()
  200.     End If
  201.     PrintText CMDialog1.hDC, "ABC Corporation", 85, 42, hCompanyFont, theScaleMode
  202.     PrintText CMDialog1.hDC, "123 Street Address", 85, 46, hCompanyFont, theScaleMode
  203.     PrintText CMDialog1.hDC, "Anywhere, USA", 85, 50, hCompanyFont, theScaleMode
  204.     Ok = SelectObject(CMDialog1.hDC, hPen)
  205.     MoveToScale CMDialog1.hDC, 80, 0, theScaleMode
  206.     LineToScale CMDialog1.hDC, 80, 55, theScaleMode
  207.     MoveToScale CMDialog1.hDC, 0, 28, theScaleMode
  208.     LineToScale CMDialog1.hDC, 155, 28, theScaleMode
  209.     Ok = EndPage(CMDialog1.hDC)
  210.     Ok = EndDocAPI(CMDialog1.hDC)
  211.     Ok = SelectObject(CMDialog1.hDC, hOldFont)
  212.     DeleteObjects
  213.     Ok = DeleteDC(CMDialog1.hDC)
  214.     Screen.MousePointer = 0
  215.     End If
  216.     On Error GoTo 0
  217. Exit Sub
  218. PrintErr:
  219.     StopPrint = True
  220.     Resume Next
  221. End Sub
  222. Sub PrintFormBtn_Click ()
  223.     Form4.PartNumber.Text = "123456"
  224.     Form4.PartBarCode.Text = "P" & Form4.PartNumber.Text
  225.     Form4.SerialNumber.Text = "230549"
  226.     Form4.SerialBarCode.Text = "S" & Form4.SerialNumber.Text
  227.     Form4.PONumber.Text = "345634-DF"
  228.     Form4.POBarCode.Text = "N" & Form4.PONumber.Text
  229.     Form4.PrintForm
  230. End Sub
  231. Sub Text1_Change ()
  232.     BarCode1.Text = Text1.Text
  233. End Sub
  234.