home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / tool / various / barvbx / createbc.frm < prev    next >
Text File  |  1995-02-27  |  16KB  |  543 lines

  1. VERSION 2.00
  2. Begin Form CreateBC 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "Create a Barcode!"
  5.    ClientHeight    =   4500
  6.    ClientLeft      =   1395
  7.    ClientTop       =   2145
  8.    ClientWidth     =   8670
  9.    Height          =   5025
  10.    Icon            =   CREATEBC.FRX:0000
  11.    Left            =   1335
  12.    LinkTopic       =   "CreateBC"
  13.    ScaleHeight     =   4500
  14.    ScaleWidth      =   8670
  15.    Top             =   1680
  16.    Width           =   8790
  17.    Begin ComboBox theScaleMode 
  18.       Height          =   288
  19.       Left            =   6720
  20.       Style           =   2  'Dropdown List
  21.       TabIndex        =   8
  22.       Top             =   840
  23.       Width           =   1788
  24.    End
  25.    Begin ComboBox AutoSize 
  26.       Height          =   288
  27.       Left            =   6720
  28.       Style           =   2  'Dropdown List
  29.       TabIndex        =   7
  30.       Top             =   444
  31.       Width           =   1284
  32.    End
  33.    Begin ComboBox Rotation 
  34.       Height          =   288
  35.       Left            =   1644
  36.       Style           =   2  'Dropdown List
  37.       TabIndex        =   6
  38.       Top             =   2040
  39.       Width           =   1848
  40.    End
  41.    Begin ComboBox Ratio 
  42.       Height          =   288
  43.       Left            =   1644
  44.       Style           =   2  'Dropdown List
  45.       TabIndex        =   5
  46.       Top             =   1644
  47.       Width           =   1008
  48.    End
  49.    Begin ComboBox BarCodeType 
  50.       Height          =   288
  51.       Left            =   1644
  52.       Style           =   2  'Dropdown List
  53.       TabIndex        =   4
  54.       Top             =   1248
  55.       Width           =   3360
  56.    End
  57.    Begin ComboBox CaptionPosition 
  58.       Height          =   288
  59.       Left            =   1644
  60.       Style           =   2  'Dropdown List
  61.       TabIndex        =   3
  62.       Top             =   852
  63.       Width           =   2472
  64.    End
  65.    Begin CommandButton ErrorBtn 
  66.       Caption         =   "Last &Error"
  67.       Height          =   432
  68.       Left            =   5268
  69.       TabIndex        =   15
  70.       Top             =   2484
  71.       Width           =   1404
  72.    End
  73.    Begin TextBox NarrWidth 
  74.       Height          =   288
  75.       Left            =   6720
  76.       TabIndex        =   11
  77.       Top             =   2028
  78.       Width           =   852
  79.    End
  80.    Begin TextBox Text 
  81.       Height          =   288
  82.       Left            =   1644
  83.       TabIndex        =   0
  84.       Top             =   60
  85.       Width           =   2712
  86.    End
  87.    Begin TextBox CaptionText 
  88.       Height          =   288
  89.       Left            =   1644
  90.       TabIndex        =   2
  91.       Top             =   456
  92.       Width           =   2712
  93.    End
  94.    Begin TextBox TotalHeight 
  95.       Height          =   288
  96.       Left            =   6720
  97.       TabIndex        =   9
  98.       Top             =   1236
  99.       Width           =   840
  100.    End
  101.    Begin CommandButton FontBtn 
  102.       Caption         =   "&Font..."
  103.       Height          =   432
  104.       Left            =   336
  105.       TabIndex        =   12
  106.       Top             =   2484
  107.       Width           =   1404
  108.    End
  109.    Begin CheckBox AutoCaption 
  110.       BackColor       =   &H00C0C0C0&
  111.       Caption         =   "Auto Caption"
  112.       Height          =   288
  113.       Left            =   4500
  114.       TabIndex        =   1
  115.       Top             =   84
  116.       Width           =   1512
  117.    End
  118.    Begin TextBox BarHeight 
  119.       Height          =   288
  120.       Left            =   6720
  121.       TabIndex        =   10
  122.       Top             =   1632
  123.       Width           =   840
  124.    End
  125.    Begin CommandButton ClipboardBtn 
  126.       Caption         =   "Clip&board"
  127.       Height          =   432
  128.       Left            =   3624
  129.       TabIndex        =   14
  130.       Top             =   2484
  131.       Width           =   1404
  132.    End
  133.    Begin CommonDialog CMDialog1 
  134.       CancelError     =   -1  'True
  135.       Left            =   8196
  136.       PrinterDefault  =   0   'False
  137.       Top             =   1860
  138.    End
  139.    Begin CommandButton CancelBtn 
  140.       Cancel          =   -1  'True
  141.       Caption         =   "&Cancel"
  142.       Height          =   432
  143.       Left            =   6912
  144.       TabIndex        =   16
  145.       Top             =   2484
  146.       Width           =   1404
  147.    End
  148.    Begin BarCode BarCode1 
  149.       AlignH          =   0  'Left
  150.       AlignV          =   0  'Top
  151.       AutoSize        =   3  'Both
  152.       BackColor       =   &H00FFFFFF&
  153.       BarCodeType     =   0  'Code 3 of 9
  154.       BorderStyle     =   0  'None
  155.       Caption         =   ""
  156.       CaptionPosition =   0  'Bottom Left
  157.       Checksum        =   0
  158.       FontBold        =   -1  'True
  159.       FontName        =   "Arial"
  160.       FontSize        =   10.5
  161.       ForeColor       =   &H00000000&
  162.       Height          =   1260
  163.       IntercharacterGap=   0
  164.       Left            =   204
  165.       Ratio           =   0  '3:1
  166.       Rotation        =   0  'Normal
  167.       ScaleBarHeight  =   1260
  168.       ScaleHeight     =   1260
  169.       ScaleLeft       =   0
  170.       ScaleMode       =   1  'Twip
  171.       ScaleNarrowBarWidth=   30
  172.       ScaleOffsetH    =   0
  173.       ScaleOffsetV    =   0
  174.       ScaleTop        =   0
  175.       ScaleWidth      =   8250
  176.       Text            =   ""
  177.       Top             =   3072
  178.       Width           =   8256
  179.    End
  180.    Begin CommandButton PrintBtn 
  181.       Caption         =   "&Print..."
  182.       Height          =   432
  183.       Left            =   1980
  184.       TabIndex        =   13
  185.       Top             =   2484
  186.       Width           =   1404
  187.    End
  188.    Begin Label Label1 
  189.       Alignment       =   1  'Right Justify
  190.       BackColor       =   &H00C0C0C0&
  191.       Caption         =   "Bar Code Type:"
  192.       Height          =   312
  193.       Left            =   60
  194.       TabIndex        =   17
  195.       Top             =   1272
  196.       Width           =   1512
  197.    End
  198.    Begin Label Label2 
  199.       Alignment       =   1  'Right Justify
  200.       BackColor       =   &H00C0C0C0&
  201.       Caption         =   "Ratio:"
  202.       Height          =   312
  203.       Left            =   60
  204.       TabIndex        =   27
  205.       Top             =   1668
  206.       Width           =   1512
  207.    End
  208.    Begin Label Label3 
  209.       Alignment       =   1  'Right Justify
  210.       BackColor       =   &H00C0C0C0&
  211.       Caption         =   "Narrow Bar Width:"
  212.       Height          =   312
  213.       Left            =   5064
  214.       TabIndex        =   26
  215.       Top             =   2064
  216.       Width           =   1596
  217.    End
  218.    Begin Label Label6 
  219.       Alignment       =   1  'Right Justify
  220.       BackColor       =   &H00C0C0C0&
  221.       Caption         =   "Text Value:"
  222.       Height          =   312
  223.       Left            =   60
  224.       TabIndex        =   25
  225.       Top             =   84
  226.       Width           =   1512
  227.    End
  228.    Begin Label Label7 
  229.       Alignment       =   1  'Right Justify
  230.       BackColor       =   &H00C0C0C0&
  231.       Caption         =   "Caption:"
  232.       Height          =   312
  233.       Left            =   60
  234.       TabIndex        =   24
  235.       Top             =   480
  236.       Width           =   1512
  237.    End
  238.    Begin Label Label8 
  239.       Alignment       =   1  'Right Justify
  240.       BackColor       =   &H00C0C0C0&
  241.       Caption         =   "Caption Position:"
  242.       Height          =   312
  243.       Left            =   60
  244.       TabIndex        =   23
  245.       Top             =   876
  246.       Width           =   1512
  247.    End
  248.    Begin Label Label9 
  249.       Alignment       =   1  'Right Justify
  250.       BackColor       =   &H00C0C0C0&
  251.       Caption         =   "Height:"
  252.       Height          =   312
  253.       Left            =   5064
  254.       TabIndex        =   22
  255.       Top             =   1272
  256.       Width           =   1596
  257.    End
  258.    Begin Label Label10 
  259.       Alignment       =   1  'Right Justify
  260.       BackColor       =   &H00C0C0C0&
  261.       Caption         =   "Rotation:"
  262.       Height          =   312
  263.       Left            =   60
  264.       TabIndex        =   21
  265.       Top             =   2064
  266.       Width           =   1512
  267.    End
  268.    Begin Label Label11 
  269.       Alignment       =   1  'Right Justify
  270.       BackColor       =   &H00C0C0C0&
  271.       Caption         =   "Barcode Height:"
  272.       Height          =   312
  273.       Left            =   5064
  274.       TabIndex        =   20
  275.       Top             =   1668
  276.       Width           =   1596
  277.    End
  278.    Begin Label Label4 
  279.       Alignment       =   1  'Right Justify
  280.       BackColor       =   &H00C0C0C0&
  281.       Caption         =   "Scale Mode:"
  282.       Height          =   312
  283.       Left            =   5064
  284.       TabIndex        =   19
  285.       Top             =   876
  286.       Width           =   1596
  287.    End
  288.    Begin Label Label5 
  289.       Alignment       =   1  'Right Justify
  290.       BackColor       =   &H00C0C0C0&
  291.       Caption         =   "AutoSize:"
  292.       Height          =   312
  293.       Left            =   5064
  294.       TabIndex        =   18
  295.       Top             =   480
  296.       Width           =   1596
  297.    End
  298. End
  299. Option Explicit
  300. Dim ErrCode%
  301. Dim Ok%
  302. Const MsgBoxType% = 64
  303. Const MsgBoxTitle$ = "Create A Barcode!"
  304.  
  305. Sub AutoSize_LostFocus ()
  306.   BarCode1.AutoSize = AutoSize.ListIndex
  307.   BarCode1.ScaleBarHeight = Val(BarHeight.Text)
  308. End Sub
  309.  
  310. Sub BarCodeType_LostFocus ()
  311.   BarCode1.BarCodeType = BarCodeType.ListIndex
  312. End Sub
  313.  
  314. Sub BarHeight_LostFocus ()
  315.   If Val(BarHeight.Text) > 0 Then
  316.     BarCode1.ScaleBarHeight = Val(BarHeight.Text)
  317.   Else
  318.     Beep
  319.     MsgBox "Barcode Height must be greater than zero!", 16, MsgBoxTitle
  320.     BarHeight.SetFocus
  321.     BarHeight.Text = Val(BarCode1.ScaleBarHeight)
  322.   End If
  323. End Sub
  324.  
  325. Sub CancelBtn_Click ()
  326.   Unload Me
  327. End Sub
  328.  
  329. Sub CaptionPosition_LostFocus ()
  330.   BarCode1.CaptionPosition = CaptionPosition.ListIndex
  331. End Sub
  332.  
  333. Sub CaptionText_Change ()
  334.   BarCode1.Caption = CaptionText.Text
  335. End Sub
  336.  
  337. Sub ClipboardBtn_Click ()
  338.   BarCode1.Action = 2
  339. End Sub
  340.  
  341. Sub ErrorBtn_Click ()
  342.   ErrCode = BarCodeGetLastErrorCode()
  343.   MsgBox Str$(ErrCode) & "-" & BarCodeGetLastErrorString(), MsgBoxType, MsgBoxTitle
  344. End Sub
  345.  
  346. Sub FontBtn_Click ()
  347.   Dim Canceled%
  348.  
  349.   Canceled = False
  350.  
  351.   On Error GoTo FontDlgErr
  352.  
  353.   CMDialog1.Flags = 1
  354.   CMDialog1.Action = 4
  355.  
  356.   If Canceled = False Then
  357.     BarCode1.FontName = CMDialog1.FontName
  358.     BarCode1.FontSize = CMDialog1.FontSize
  359.     BarCode1.FontBold = CMDialog1.FontBold
  360.   End If
  361.  
  362.   Exit Sub
  363.  
  364. FontDlgErr:
  365.   If Err = 32755 Then
  366.     Canceled = True
  367.   End If
  368.   Resume Next
  369. End Sub
  370.  
  371. Sub Form_Load ()
  372.   CenterWindow Me
  373.  
  374.   CaptionPosition.AddItem ("0 - Bottom Left")
  375.   CaptionPosition.AddItem ("1 - Bottom Center")
  376.   CaptionPosition.AddItem ("2 - Bottom Right")
  377.   CaptionPosition.AddItem ("3 - Top Left")
  378.   CaptionPosition.AddItem ("4 - Top Center")
  379.   CaptionPosition.AddItem ("5 - Top Right")
  380.  
  381.   BarCodeType.AddItem ("0 - Code 3 of 9")
  382.   BarCodeType.AddItem ("1 - Extended Code 3 of 9")
  383.   BarCodeType.AddItem ("2 - Interleaved 2 of 5")
  384.   BarCodeType.AddItem ("3 - Code 93")
  385.   BarCodeType.AddItem ("4 - Extended Code 93")
  386.   BarCodeType.AddItem ("5 - UPCA")
  387.   BarCodeType.AddItem ("6 - UPCE 10 digit")
  388.   BarCodeType.AddItem ("7 - UPCE0 6 digit")
  389.   BarCodeType.AddItem ("8 - UPCE1 6 digit")
  390.   BarCodeType.AddItem ("9 - EAN 13")
  391.   BarCodeType.AddItem ("10 - EAN 8")
  392.   BarCodeType.AddItem ("11 - Code 128 Auto")
  393.   BarCodeType.AddItem ("12 - Code 128 A")
  394.   BarCodeType.AddItem ("13 - Code 128 B")
  395.   BarCodeType.AddItem ("14 - Code 128 C")
  396.   BarCodeType.AddItem ("15 - Codabar")
  397.   BarCodeType.AddItem ("16 - MSI Plessy")
  398.   BarCodeType.AddItem ("17 - UCC-128")
  399.   BarCodeType.AddItem ("18 - POSTNET (Zip+4 Postal Code)")
  400.   
  401.   Ratio.AddItem ("0 - 3:1")
  402.   Ratio.AddItem ("1 - 2.5:1")
  403.   Ratio.AddItem ("2 - 2:1")
  404.  
  405.   Rotation.AddItem ("0 - Normal")
  406.   Rotation.AddItem ("1 - Right")
  407.   Rotation.AddItem ("2 - Upside Down")
  408.   Rotation.AddItem ("3 - Left")
  409.  
  410.   AutoSize.AddItem ("0 - None")
  411.   AutoSize.AddItem ("1 - Height")
  412.   AutoSize.AddItem ("2 - Width")
  413.   AutoSize.AddItem ("3 - Both")
  414.  
  415.   theScaleMode.AddItem ("0 - User")
  416.   theScaleMode.AddItem ("1 - Twip")
  417.   theScaleMode.AddItem ("2 - Point")
  418.   theScaleMode.AddItem ("3 - Pixel")
  419.   theScaleMode.AddItem ("4 - Character")
  420.   theScaleMode.AddItem ("5 - Inch")
  421.   theScaleMode.AddItem ("6 - Millimeter")
  422.   theScaleMode.AddItem ("7 - Centimeter")
  423.  
  424.   AutoCaption.Value = 1
  425.   CaptionText.Text = BarCode1.Caption
  426.   BarCodeType.ListIndex = BarCode1.BarCodeType
  427.   Ratio.ListIndex = BarCode1.Ratio
  428.   NarrWidth.Text = LTrim(Str(BarCode1.ScaleNarrowBarWidth))
  429.   CaptionPosition.ListIndex = BarCode1.CaptionPosition
  430.   Rotation.ListIndex = BarCode1.Rotation
  431.   If Rotation.ListIndex = 1 Or Rotation.ListIndex = 3 Then
  432.     TotalHeight.Text = BarCode1.Width
  433.   Else
  434.     TotalHeight.Text = BarCode1.Height
  435.   End If
  436.   BarHeight.Text = Val(BarCode1.ScaleBarHeight)
  437.   AutoSize.ListIndex = BarCode1.AutoSize
  438.   theScaleMode.ListIndex = BarCode1.ScaleMode
  439.   CMDialog1.FontName = BarCode1.FontName
  440.   CMDialog1.FontSize = BarCode1.FontSize
  441.   CMDialog1.FontBold = BarCode1.FontBold
  442. End Sub
  443.  
  444. Sub NarrWidth_LostFocus ()
  445.   If Val(NarrWidth.Text) > 0 Then
  446.     BarCode1.ScaleNarrowBarWidth = Val(NarrWidth.Text)
  447.   Else
  448.     Beep
  449.     MsgBox "Narrow Bar Width must be greater than zero!", 16, MsgBoxTitle
  450.     NarrWidth.SetFocus
  451.     NarrWidth.Text = LTrim(Str(BarCode1.ScaleNarrowBarWidth))
  452.   End If
  453. End Sub
  454.  
  455. Sub PrintBtn_Click ()
  456.   Dim DOCINFO As DOCINFO
  457.   Dim StopPrint As Integer
  458.  
  459.   StopPrint = False
  460.   On Error GoTo PrintErr:
  461.                    
  462.   CMDialog1.Flags = PD_RETURNDC Or PD_PRINTSETUP
  463.   CMDialog1.Action = 5
  464.     
  465.   If StopPrint = False Then
  466.     Screen.MousePointer = 11
  467.  
  468.     DOCINFO.cbSize = 0
  469.     DOCINFO.DocName = 0
  470.     DOCINFO.Output = 0
  471.  
  472.     Ok = StartDoc(CMDialog1.hDC, DOCINFO)
  473.     Ok = StartPage(CMDialog1.hDC)
  474.  
  475.     BarCode1.PrinterHDC = CMDialog1.hDC
  476.     If BarCodeGetLastErrorCode() <> False Then
  477.       MsgBox BarCodeGetLastErrorString()
  478.     End If
  479.  
  480.     Ok = EndPage(CMDialog1.hDC)
  481.     Ok = EndDocAPI(CMDialog1.hDC)
  482.     Ok = DeleteDC(CMDialog1.hDC)
  483.     Screen.MousePointer = 0
  484.   End If
  485.  
  486.   On Error GoTo 0
  487. Exit Sub
  488.  
  489. PrintErr:
  490.   StopPrint = True
  491.   Resume Next
  492. End Sub
  493.  
  494. Sub Ratio_LostFocus ()
  495.   BarCode1.Ratio = Ratio.ListIndex
  496. End Sub
  497.  
  498. Sub Rotation_LostFocus ()
  499.   BarCode1.Rotation = Rotation.ListIndex
  500.   If Rotation.ListIndex = 1 Or Rotation.ListIndex = 3 Then
  501.     TotalHeight.Text = BarCode1.Width
  502.   Else
  503.     TotalHeight.Text = BarCode1.Height
  504.   End If
  505.   BarHeight.Text = Val(BarCode1.ScaleBarHeight)
  506. End Sub
  507.  
  508. Sub Text_Change ()
  509.   BarCode1.Text = Text.Text
  510.   If AutoCaption.Value = 1 Then
  511.     CaptionText.Text = Text.Text
  512.     If BarCode1.BarCodeType >= 5 And BarCode1.BarCodeType <= 10 Then
  513.       CaptionText.Text = CaptionText.Text & BarCode1.ChecksumString
  514.     End If
  515.   End If
  516. End Sub
  517.  
  518. Sub theScaleMode_LostFocus ()
  519.   BarCode1.ScaleMode = theScaleMode.ListIndex
  520.   NarrWidth.Text = LTrim(Str(BarCode1.ScaleNarrowBarWidth))
  521.   BarHeight.Text = Val(BarCode1.ScaleBarHeight)
  522. End Sub
  523.  
  524. Sub TotalHeight_LostFocus ()
  525.   If Val(TotalHeight.Text) > 0 Then
  526.     If Rotation.ListIndex = 1 Or Rotation.ListIndex = 3 Then
  527.       BarCode1.Width = Val(TotalHeight.Text)
  528.     Else
  529.       BarCode1.Height = Val(TotalHeight.Text)
  530.     End If
  531.   Else
  532.     Beep
  533.     MsgBox "Height must be greater than zero!", 16, MsgBoxTitle
  534.     TotalHeight.SetFocus
  535.     If Rotation.ListIndex = 1 Or Rotation.ListIndex = 3 Then
  536.       TotalHeight.Text = BarCode1.Width
  537.     Else
  538.       TotalHeight.Text = BarCode1.Height
  539.     End If
  540.   End If
  541. End Sub
  542.  
  543.