VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "comdlg32.ocx"
Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "tabctl32.ocx"
Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0"; "richtx32.ocx"
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "mswinsck.ocx"
Begin VB.Form MainForm 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "filled in by program..."
   ClientHeight    =   7950
   ClientLeft      =   45
   ClientTop       =   375
   ClientWidth     =   12870
   BeginProperty Font 
      Name            =   "Arial"
      Size            =   14.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   Icon            =   "CreateHDBarcode.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   7950
   ScaleWidth      =   12870
   StartUpPosition =   2  'CenterScreen
   Begin TabDlg.SSTab SSTab 
      Height          =   7935
      Left            =   0
      TabIndex        =   42
      Top             =   0
      Width           =   12885
      _ExtentX        =   22728
      _ExtentY        =   13996
      _Version        =   393216
      Tabs            =   8
      TabsPerRow      =   8
      TabHeight       =   882
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Arial"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      TabCaption(0)   =   "Style"
      TabPicture(0)   =   "CreateHDBarcode.frx":030A
      Tab(0).ControlEnabled=   -1  'True
      Tab(0).Control(0)=   "UdpWinsock"
      Tab(0).Control(0).Enabled=   0   'False
      Tab(0).Control(1)=   "TcpWinsock"
      Tab(0).Control(1).Enabled=   0   'False
      Tab(0).Control(2)=   "Frame1"
      Tab(0).Control(2).Enabled=   0   'False
      Tab(0).Control(3)=   "Frame2"
      Tab(0).Control(3).Enabled=   0   'False
      Tab(0).Control(4)=   "UdpTimer"
      Tab(0).Control(4).Enabled=   0   'False
      Tab(0).Control(5)=   "TcpTimer"
      Tab(0).Control(5).Enabled=   0   'False
      Tab(0).ControlCount=   6
      TabCaption(1)   =   "Text/URL"
      TabPicture(1)   =   "CreateHDBarcode.frx":0326
      Tab(1).ControlEnabled=   0   'False
      Tab(1).Control(0)=   "Label5"
      Tab(1).Control(1)=   "DataText"
      Tab(1).ControlCount=   2
      TabCaption(2)   =   "Picture"
      TabPicture(2)   =   "CreateHDBarcode.frx":0342
      Tab(2).ControlEnabled=   0   'False
      Tab(2).Control(0)=   "Line1"
      Tab(2).Control(1)=   "Line2"
      Tab(2).Control(2)=   "Line3"
      Tab(2).Control(3)=   "BeforeSizeLabel"
      Tab(2).Control(4)=   "AfterSizeLabel"
      Tab(2).Control(5)=   "Label14"
      Tab(2).Control(6)=   "QualityLabel"
      Tab(2).Control(7)=   "BeforeJpegPicture"
      Tab(2).Control(8)=   "QualityScroll"
      Tab(2).Control(9)=   "AfterJpegPicture"
      Tab(2).Control(10)=   "ChooseJpegCommand"
      Tab(2).Control(11)=   "JpegFileText"
      Tab(2).ControlCount=   12
      TabCaption(3)   =   "Zip"
      TabPicture(3)   =   "CreateHDBarcode.frx":035E
      Tab(3).ControlEnabled=   0   'False
      Tab(3).Control(0)=   "Frame3"
      Tab(3).Control(1)=   "ZipFileText"
      Tab(3).Control(2)=   "ChooseZipCommand"
      Tab(3).ControlCount=   3
      TabCaption(4)   =   "Geometry"
      TabPicture(4)   =   "CreateHDBarcode.frx":037A
      Tab(4).ControlEnabled=   0   'False
      Tab(4).Control(0)=   "Frame4"
      Tab(4).Control(1)=   "Frame6"
      Tab(4).Control(2)=   "Frame7"
      Tab(4).ControlCount=   3
      TabCaption(5)   =   "Emboss"
      TabPicture(5)   =   "CreateHDBarcode.frx":0396
      Tab(5).ControlEnabled=   0   'False
      Tab(5).Control(0)=   "EmbossFileText"
      Tab(5).Control(1)=   "ChooseEmbossPicture"
      Tab(5).Control(2)=   "EmbossPicture"
      Tab(5).ControlCount=   3
      TabCaption(6)   =   "Security"
      TabPicture(6)   =   "CreateHDBarcode.frx":03B2
      Tab(6).ControlEnabled=   0   'False
      Tab(6).Control(0)=   "CompanyNameLabel"
      Tab(6).Control(1)=   "SecretPhraseLabel(0)"
      Tab(6).Control(2)=   "SecurityTroubleText"
      Tab(6).Control(3)=   "CodeGeneratorIPaddrLabel"
      Tab(6).Control(4)=   "IdentificationTagLabel"
      Tab(6).Control(5)=   "Label16"
      Tab(6).Control(6)=   "Label17"
      Tab(6).Control(7)=   "SecretPhraseLabel(1)"
      Tab(6).Control(8)=   "PublicOption"
      Tab(6).Control(9)=   "PrivateOption"
      Tab(6).Control(10)=   "CompanyNameText"
      Tab(6).Control(11)=   "SecretPhraseText(0)"
      Tab(6).Control(12)=   "CodeGeneratorIPAddrText"
      Tab(6).Control(13)=   "UniversalOption"
      Tab(6).Control(14)=   "UniqueOption"
      Tab(6).Control(15)=   "TemporaryCheck"
      Tab(6).Control(16)=   "IdentificationTagText"
      Tab(6).Control(17)=   "CascadedOption"
      Tab(6).Control(18)=   "SecretPhraseText(1)"
      Tab(6).Control(19)=   "UsageCheck(12)"
      Tab(6).Control(20)=   "UsageCheck(22)"
      Tab(6).Control(21)=   "UsageCheck(13)"
      Tab(6).Control(22)=   "UsageCheck(23)"
      Tab(6).Control(23)=   "UsageCheck(33)"
      Tab(6).Control(24)=   "UsageCheck(32)"
      Tab(6).Control(25)=   "UsageCheck(43)"
      Tab(6).Control(26)=   "UsageCheck(42)"
      Tab(6).Control(27)=   "UsageCheck(53)"
      Tab(6).Control(28)=   "UsageCheck(52)"
      Tab(6).ControlCount=   29
      TabCaption(7)   =   "View/Print"
      TabPicture(7)   =   "CreateHDBarcode.frx":03CE
      Tab(7).ControlEnabled=   0   'False
      Tab(7).Control(0)=   "ViewCommand"
      Tab(7).Control(1)=   "ViewPicture"
      Tab(7).Control(2)=   "Frame8"
      Tab(7).Control(3)=   "Frame5"
      Tab(7).Control(4)=   "PrintCommand"
      Tab(7).ControlCount=   5
      Begin VB.Timer TcpTimer 
         Enabled         =   0   'False
         Interval        =   1000
         Left            =   6840
         Top             =   6000
      End
      Begin VB.Timer UdpTimer 
         Interval        =   1000
         Left            =   7440
         Top             =   6000
      End
      Begin VB.CheckBox UsageCheck 
         Enabled         =   0   'False
         Height          =   375
         Index           =   52
         Left            =   -65160
         TabIndex        =   93
         Top             =   6758
         Width           =   615
      End
      Begin VB.CheckBox UsageCheck 
         Enabled         =   0   'False
         Height          =   375
         Index           =   53
         Left            =   -63840
         TabIndex        =   92
         Top             =   6758
         Width           =   615
      End
      Begin VB.CheckBox UsageCheck 
         Enabled         =   0   'False
         Height          =   375
         Index           =   42
         Left            =   -65160
         TabIndex        =   91
         Top             =   6158
         Width           =   615
      End
      Begin VB.CheckBox UsageCheck 
         Enabled         =   0   'False
         Height          =   375
         Index           =   43
         Left            =   -63840
         TabIndex        =   90
         Top             =   6158
         Width           =   615
      End
      Begin VB.CheckBox UsageCheck 
         Enabled         =   0   'False
         Height          =   375
         Index           =   32
         Left            =   -65160
         TabIndex        =   89
         Top             =   5558
         Width           =   615
      End
      Begin VB.CheckBox UsageCheck 
         Enabled         =   0   'False
         Height          =   375
         Index           =   33
         Left            =   -63840
         TabIndex        =   88
         Top             =   5558
         Width           =   615
      End
      Begin VB.CheckBox UsageCheck 
         Enabled         =   0   'False
         Height          =   375
         Index           =   23
         Left            =   -63840
         TabIndex        =   87
         Top             =   4920
         Width           =   615
      End
      Begin VB.CheckBox UsageCheck 
         Enabled         =   0   'False
         Height          =   375
         Index           =   13
         Left            =   -63840
         TabIndex        =   86
         Top             =   4320
         Width           =   615
      End
      Begin VB.CheckBox UsageCheck 
         Enabled         =   0   'False
         Height          =   375
         Index           =   22
         Left            =   -65160
         TabIndex        =   85
         Top             =   4920
         Width           =   615
      End
      Begin VB.CheckBox UsageCheck 
         Enabled         =   0   'False
         Height          =   375
         Index           =   12
         Left            =   -65160
         TabIndex        =   84
         Top             =   4320
         Width           =   615
      End
      Begin VB.TextBox SecretPhraseText 
         Height          =   450
         IMEMode         =   3  'DISABLE
         Index           =   1
         Left            =   -71400
         PasswordChar    =   "*"
         TabIndex        =   10
         Top             =   6720
         Width           =   5535
      End
      Begin VB.OptionButton CascadedOption 
         Caption         =   "Cascaded Authorization HD Barcode (for a previously authorized reader)"
         Height          =   375
         Left            =   -74280
         TabIndex        =   4
         Top             =   2760
         Width           =   10695
      End
      Begin VB.TextBox IdentificationTagText 
         Height          =   450
         IMEMode         =   3  'DISABLE
         Left            =   -71400
         TabIndex        =   8
         Top             =   5520
         Width           =   5535
      End
      Begin VB.CheckBox TemporaryCheck 
         Caption         =   "Temporary (requires rescan of authorization each time the reader app is run)"
         Height          =   375
         Left            =   -74280
         TabIndex        =   5
         Top             =   3240
         Width           =   10935
      End
      Begin VB.OptionButton UniqueOption 
         Caption         =   "Unique Authorization HD Barcode (for a specific reader)"
         Height          =   375
         Left            =   -74280
         TabIndex        =   3
         Top             =   2280
         Width           =   10695
      End
      Begin VB.OptionButton UniversalOption 
         Caption         =   "Universal Authorization HD Barcode (for any reader)"
         Height          =   375
         Left            =   -74280
         TabIndex        =   2
         Top             =   1800
         Width           =   10695
      End
      Begin VB.TextBox CodeGeneratorIPAddrText 
         Height          =   450
         IMEMode         =   3  'DISABLE
         Left            =   -71400
         Locked          =   -1  'True
         TabIndex        =   7
         Top             =   4920
         Width           =   5535
      End
      Begin VB.PictureBox EmbossPicture 
         Height          =   5295
         Left            =   -74520
         ScaleHeight     =   349
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   789
         TabIndex        =   77
         Top             =   2280
         Width           =   11895
      End
      Begin VB.CommandButton ChooseEmbossPicture 
         Caption         =   "Choose emboss picture"
         Height          =   735
         Left            =   -74520
         TabIndex        =   32
         Top             =   960
         Width           =   3615
      End
      Begin VB.TextBox EmbossFileText 
         Height          =   495
         Left            =   -70440
         TabIndex        =   33
         Top             =   1080
         Width           =   7815
      End
      Begin VB.CommandButton ChooseZipCommand 
         Caption         =   "Choose ZIP file"
         Height          =   735
         Left            =   -74520
         TabIndex        =   22
         Top             =   960
         Width           =   3615
      End
      Begin VB.TextBox ZipFileText 
         Height          =   495
         Left            =   -70440
         TabIndex        =   23
         Top             =   1080
         Width           =   7815
      End
      Begin VB.TextBox JpegFileText 
         Height          =   495
         Left            =   -70440
         TabIndex        =   20
         Top             =   1080
         Width           =   7815
      End
      Begin VB.CommandButton ChooseJpegCommand 
         Caption         =   "Choose JPEG file"
         Height          =   735
         Left            =   -74520
         TabIndex        =   19
         Top             =   960
         Width           =   3615
      End
      Begin VB.CommandButton PrintCommand 
         Caption         =   "Print"
         Height          =   495
         Left            =   -65520
         TabIndex        =   75
         Top             =   6960
         Width           =   2295
      End
      Begin VB.Frame Frame5 
         Caption         =   "Usage statistics (in bytes)"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   1815
         Left            =   -66240
         TabIndex        =   71
         Top             =   1680
         Width           =   3735
         Begin VB.TextBox TotalBytesText 
            Alignment       =   1  'Right Justify
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   9.75
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   300
            Left            =   2280
            Locked          =   -1  'True
            TabIndex        =   37
            Top             =   1320
            Width           =   1215
         End
         Begin VB.TextBox ErrorBytesText 
            Alignment       =   1  'Right Justify
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   9.75
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   300
            Left            =   2280
            Locked          =   -1  'True
            TabIndex        =   36
            Top             =   840
            Width           =   1215
         End
         Begin VB.TextBox UserBytesText 
            Alignment       =   1  'Right Justify
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   9.75
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   300
            Left            =   2280
            Locked          =   -1  'True
            TabIndex        =   35
            Top             =   300
            Width           =   1215
         End
         Begin VB.Label Label6 
            Alignment       =   1  'Right Justify
            Caption         =   "User data"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   9.75
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   360
            TabIndex        =   74
            Top             =   360
            Width           =   1695
         End
         Begin VB.Label Label7 
            Alignment       =   1  'Right Justify
            Caption         =   "Total"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   9.75
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   360
            TabIndex        =   73
            Top             =   1320
            Width           =   1695
         End
         Begin VB.Label Label8 
            Alignment       =   1  'Right Justify
            Caption         =   "Error correction"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   9.75
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   360
            TabIndex        =   72
            Top             =   840
            Width           =   1695
         End
      End
      Begin VB.Frame Frame8 
         Caption         =   "Printer information"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   2895
         Left            =   -66240
         TabIndex        =   67
         Top             =   3720
         Width           =   3735
         Begin VB.TextBox SymbolHeightText 
            Alignment       =   1  'Right Justify
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   9.75
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   300
            Left            =   2280
            Locked          =   -1  'True
            TabIndex        =   41
            Top             =   2160
            Width           =   1215
         End
         Begin VB.TextBox ResolutionText 
            Alignment       =   1  'Right Justify
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   9.75
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   300
            Left            =   2280
            TabIndex        =   39
            Top             =   1200
            Width           =   1215
         End
         Begin VB.TextBox SymbolWidthText 
            Alignment       =   1  'Right Justify
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   9.75
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   300
            Left            =   2280
            Locked          =   -1  'True
            TabIndex        =   40
            Top             =   1680
            Width           =   1215
         End
         Begin VB.CommandButton SelectPrinterCommand 
            Caption         =   "Select printer"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   9.75
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   495
            Left            =   720
            TabIndex        =   38
            Top             =   480
            Width           =   2295
         End
         Begin VB.Label Label11 
            Alignment       =   1  'Right Justify
            Caption         =   "Symbol height"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   9.75
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   120
            TabIndex        =   70
            Top             =   2160
            Width           =   1935
         End
         Begin VB.Label Label10 
            Alignment       =   1  'Right Justify
            Caption         =   "Printer DPI"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   9.75
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   360
            Left            =   240
            TabIndex        =   69
            Top             =   1215
            Width           =   1815
         End
         Begin VB.Label Label9 
            Alignment       =   1  'Right Justify
            Caption         =   "Symbol width"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   9.75
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   240
            TabIndex        =   68
            Top             =   1680
            Width           =   1815
         End
      End
      Begin VB.PictureBox ViewPicture 
         Height          =   6615
         Left            =   -74640
         ScaleHeight     =   437
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   533
         TabIndex        =   66
         Top             =   840
         Width           =   8055
      End
      Begin VB.CommandButton ViewCommand 
         Caption         =   "View"
         Height          =   495
         Left            =   -65520
         TabIndex        =   34
         Top             =   840
         Width           =   2295
      End
      Begin VB.Frame Frame7 
         Caption         =   "Group error correction"
         Height          =   2775
         Left            =   -74520
         TabIndex        =   64
         Top             =   3960
         Width           =   4575
         Begin VB.CheckBox AutomaticErrorCheck 
            Caption         =   "Automatic"
            Height          =   255
            Left            =   360
            TabIndex        =   27
            Top             =   600
            Value           =   1  'Checked
            Width           =   1815
         End
         Begin VB.HScrollBar ErrorCorrectionScroll 
            Height          =   375
            Left            =   360
            Max             =   15
            TabIndex        =   28
            Top             =   1200
            Width           =   1095
         End
         Begin VB.Label ErrorCorrectionLabel 
            Height          =   735
            Left            =   360
            TabIndex        =   65
            Top             =   1680
            Width           =   3855
         End
      End
      Begin VB.Frame Frame6 
         Caption         =   "Symbol size"
         Height          =   2655
         Left            =   -74520
         TabIndex        =   61
         Top             =   960
         Width           =   4575
         Begin VB.CheckBox AutomaticSizeCheck 
            Caption         =   "Automatic"
            Height          =   255
            Left            =   360
            TabIndex        =   24
            Top             =   600
            Value           =   1  'Checked
            Width           =   1815
         End
         Begin VB.HScrollBar BlockRowsScroll 
            Height          =   375
            Left            =   360
            Max             =   127
            TabIndex        =   25
            Top             =   1200
            Value           =   1
            Width           =   1095
         End
         Begin VB.HScrollBar BlockColsScroll 
            Height          =   375
            Left            =   360
            Max             =   127
            TabIndex        =   26
            Top             =   1920
            Value           =   1
            Width           =   1095
         End
         Begin VB.Label RowsLabel 
            Caption         =   "2 rows"
            Height          =   375
            Left            =   1680
            TabIndex        =   63
            Top             =   1200
            Width           =   1815
         End
         Begin VB.Label ColumnsLabel 
            Caption         =   "2 columns"
            Height          =   375
            Left            =   1680
            TabIndex        =   62
            Top             =   1920
            Width           =   1815
         End
      End
      Begin VB.Frame Frame4 
         Caption         =   "Pixel layout"
         Height          =   2655
         Left            =   -69480
         TabIndex        =   58
         Top             =   960
         Width           =   6855
         Begin VB.HScrollBar ThicknessScroll 
            Height          =   375
            Left            =   360
            Max             =   8
            Min             =   1
            TabIndex        =   30
            Top             =   1320
            Value           =   2
            Width           =   2415
         End
         Begin VB.HScrollBar GridSizeScroll 
            Height          =   375
            Left            =   360
            Max             =   128
            Min             =   3
            TabIndex        =   29
            Top             =   720
            Value           =   8
            Width           =   2415
         End
         Begin VB.CheckBox MirrorCheck 
            Caption         =   "Mirror image"
            Height          =   495
            Left            =   2760
            TabIndex        =   31
            Top             =   1920
            Width           =   2415
         End
         Begin VB.Label ThicknessLabel 
            Caption         =   "ThicknessLabel"
            Height          =   375
            Left            =   3000
            TabIndex        =   60
            Top             =   1320
            Width           =   3495
         End
         Begin VB.Label GridSizeLabel 
            Caption         =   "GridSizeLabel"
            Height          =   375
            Left            =   3000
            TabIndex        =   59
            Top             =   720
            Width           =   3495
         End
      End
      Begin VB.PictureBox AfterJpegPicture 
         Height          =   4335
         Left            =   -67560
         ScaleHeight     =   285
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   317
         TabIndex        =   53
         Top             =   2640
         Width           =   4815
      End
      Begin VB.HScrollBar QualityScroll 
         Height          =   375
         LargeChange     =   5
         Left            =   -69600
         Max             =   95
         Min             =   5
         TabIndex        =   21
         Top             =   5880
         Value           =   20
         Width           =   1815
      End
      Begin VB.PictureBox BeforeJpegPicture 
         Height          =   4335
         Left            =   -74640
         ScaleHeight     =   285
         ScaleMode       =   3  'Pixel
         ScaleWidth      =   317
         TabIndex        =   52
         Top             =   2640
         Width           =   4815
      End
      Begin VB.TextBox SecretPhraseText 
         Height          =   450
         IMEMode         =   3  'DISABLE
         Index           =   0
         Left            =   -71400
         PasswordChar    =   "*"
         TabIndex        =   9
         Top             =   6120
         Width           =   5535
      End
      Begin VB.TextBox CompanyNameText 
         Height          =   450
         Left            =   -71400
         Locked          =   -1  'True
         TabIndex        =   6
         Top             =   4320
         Width           =   5535
      End
      Begin VB.OptionButton PrivateOption 
         Caption         =   "Company Private HD Barcode (only authorized readers can scan and read the symbol)"
         Height          =   375
         Left            =   -74280
         TabIndex        =   1
         Top             =   1320
         Width           =   11535
      End
      Begin VB.OptionButton PublicOption 
         Caption         =   "Public HD Barcode (any reader can scan and read the symbol)"
         Height          =   375
         Left            =   -74280
         TabIndex        =   0
         Top             =   840
         Value           =   -1  'True
         Width           =   10695
      End
      Begin VB.Frame Frame2 
         Caption         =   "Choose the HD Barcode style:"
         Height          =   6855
         Left            =   360
         TabIndex        =   45
         Top             =   840
         Width           =   6135
         Begin VB.PictureBox StylePicture 
            Height          =   1695
            Index           =   0
            Left            =   360
            Picture         =   "CreateHDBarcode.frx":03EA
            ScaleHeight     =   1635
            ScaleWidth      =   1635
            TabIndex        =   48
            Top             =   600
            Width           =   1695
         End
         Begin VB.PictureBox StylePicture 
            Height          =   1695
            Index           =   2
            Left            =   360
            Picture         =   "CreateHDBarcode.frx":92D4
            ScaleHeight     =   1635
            ScaleWidth      =   1635
            TabIndex        =   47
            Top             =   4680
            Width           =   1695
         End
         Begin VB.PictureBox StylePicture 
            Height          =   1695
            Index           =   1
            Left            =   360
            Picture         =   "CreateHDBarcode.frx":C6C6
            ScaleHeight     =   1635
            ScaleWidth      =   1635
            TabIndex        =   46
            Top             =   2640
            Width           =   1695
         End
         Begin VB.OptionButton StyleOption 
            Caption         =   "Dots with embossed picture"
            Enabled         =   0   'False
            Height          =   1095
            Index           =   2
            Left            =   2280
            TabIndex        =   13
            Top             =   4920
            Width           =   2655
         End
         Begin VB.OptionButton StyleOption 
            Caption         =   "Dots"
            Height          =   375
            Index           =   1
            Left            =   2280
            TabIndex        =   12
            Top             =   3240
            Width           =   1095
         End
         Begin VB.OptionButton StyleOption 
            Caption         =   "Lines"
            Height          =   375
            Index           =   0
            Left            =   2160
            TabIndex        =   11
            Top             =   1320
            Width           =   1335
         End
      End
      Begin VB.Frame Frame1 
         Caption         =   "Choose what data will be included:"
         Height          =   4455
         Left            =   6840
         TabIndex        =   44
         Top             =   840
         Width           =   5655
         Begin VB.OptionButton DataOption 
            Caption         =   "Authorization HD Barcode"
            Height          =   375
            Index           =   5
            Left            =   360
            TabIndex        =   79
            Top             =   3600
            Width           =   5055
         End
         Begin VB.OptionButton DataOption 
            Caption         =   "Zipped file (HTML, BMP, etc.)"
            Height          =   375
            Index           =   4
            Left            =   360
            TabIndex        =   18
            Top             =   3000
            Width           =   4695
         End
         Begin VB.OptionButton DataOption 
            Caption         =   "Web address (URL)"
            Height          =   375
            Index           =   0
            Left            =   360
            TabIndex        =   14
            Top             =   600
            Width           =   3735
         End
         Begin VB.OptionButton DataOption 
            Caption         =   "JPEG picture only"
            Height          =   375
            Index           =   3
            Left            =   360
            TabIndex        =   17
            Top             =   2400
            Width           =   3735
         End
         Begin VB.OptionButton DataOption 
            Caption         =   "Text plus a JPEG picture"
            Height          =   375
            Index           =   2
            Left            =   360
            TabIndex        =   16
            Top             =   1800
            Width           =   3735
         End
         Begin VB.OptionButton DataOption 
            Caption         =   "Text"
            Height          =   375
            Index           =   1
            Left            =   360
            TabIndex        =   15
            Top             =   1200
            Width           =   3735
         End
      End
      Begin VB.Frame Frame3 
         BorderStyle     =   0  'None
         Height          =   2175
         Left            =   -74880
         TabIndex        =   43
         Top             =   600
         Width           =   12615
      End
      Begin RichTextLib.RichTextBox DataText 
         Height          =   5415
         Left            =   -74520
         TabIndex        =   80
         Top             =   2040
         Width           =   11895
         _ExtentX        =   20981
         _ExtentY        =   9551
         _Version        =   393217
         TextRTF         =   $"CreateHDBarcode.frx":FAB8
      End
      Begin MSWinsockLib.Winsock TcpWinsock 
         Left            =   6840
         Top             =   5400
         _ExtentX        =   741
         _ExtentY        =   741
         _Version        =   393216
      End
      Begin MSWinsockLib.Winsock UdpWinsock 
         Left            =   7440
         Top             =   5400
         _ExtentX        =   741
         _ExtentY        =   741
         _Version        =   393216
         Protocol        =   1
      End
      Begin VB.Label SecretPhraseLabel 
         Alignment       =   1  'Right Justify
         Caption         =   "SecretPhraseLabel(1):"
         Height          =   375
         Index           =   1
         Left            =   -74880
         TabIndex        =   94
         Top             =   6765
         Width           =   3255
      End
      Begin VB.Label Label17 
         Alignment       =   2  'Center
         Caption         =   "Embedded in barcode "
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   -64320
         TabIndex        =   83
         Top             =   3720
         Width           =   1215
      End
      Begin VB.Label Label16 
         Alignment       =   2  'Center
         Caption         =   "Used to encrypt "
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   -65640
         TabIndex        =   82
         Top             =   3720
         Width           =   1215
      End
      Begin VB.Label IdentificationTagLabel 
         Alignment       =   1  'Right Justify
         Caption         =   "Identification Tag:"
         Height          =   375
         Left            =   -74880
         TabIndex        =   81
         Top             =   5565
         Width           =   3255
      End
      Begin VB.Label CodeGeneratorIPaddrLabel 
         Alignment       =   1  'Right Justify
         Caption         =   "Code Generator IP addr:"
         Height          =   375
         Left            =   -74880
         TabIndex        =   78
         Top             =   4965
         Width           =   3255
      End
      Begin VB.Label SecurityTroubleText 
         Alignment       =   2  'Center
         Caption         =   "SecurityTroubleText"
         ForeColor       =   &H000000FF&
         Height          =   495
         Left            =   -74760
         TabIndex        =   76
         Top             =   7320
         Width           =   12375
      End
      Begin VB.Label QualityLabel 
         Alignment       =   2  'Center
         Height          =   375
         Left            =   -69600
         TabIndex        =   57
         Top             =   6480
         Width           =   1815
      End
      Begin VB.Label Label14 
         Alignment       =   2  'Center
         Caption         =   "Quality"
         Height          =   375
         Left            =   -69600
         TabIndex        =   56
         Top             =   5400
         Width           =   1815
      End
      Begin VB.Label AfterSizeLabel 
         Height          =   375
         Left            =   -67560
         TabIndex        =   55
         Top             =   7080
         Width           =   4815
      End
      Begin VB.Label BeforeSizeLabel 
         Height          =   375
         Left            =   -74640
         TabIndex        =   54
         Top             =   7080
         Width           =   4815
      End
      Begin VB.Line Line3 
         BorderWidth     =   5
         X1              =   -68400
         X2              =   -67920
         Y1              =   4920
         Y2              =   4560
      End
      Begin VB.Line Line2 
         BorderWidth     =   5
         X1              =   -68400
         X2              =   -67920
         Y1              =   4200
         Y2              =   4560
      End
      Begin VB.Line Line1 
         BorderWidth     =   5
         X1              =   -69480
         X2              =   -67920
         Y1              =   4560
         Y2              =   4560
      End
      Begin VB.Label Label5 
         Caption         =   "The following characters will be embedded in the data portion of the HD Barcode and will be displayed when the barcode is scanned."
         Height          =   735
         Left            =   -74520
         TabIndex        =   51
         Top             =   960
         Width           =   11895
      End
      Begin VB.Label SecretPhraseLabel 
         Alignment       =   1  'Right Justify
         Caption         =   "SecretPhraseLabel(0):"
         Height          =   375
         Index           =   0
         Left            =   -74880
         TabIndex        =   50
         Top             =   6165
         Width           =   3255
      End
      Begin VB.Label CompanyNameLabel 
         Alignment       =   1  'Right Justify
         Caption         =   "Company Name:"
         Height          =   375
         Left            =   -74880
         TabIndex        =   49
         Top             =   4365
         Width           =   3255
      End
   End
   Begin MSComDlg.CommonDialog Dialog 
      Left            =   12120
      Top             =   7200
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
End
Attribute VB_Name = "MainForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Const CodeGeneratorPort As Long = 8877

Private Enum StyleOptions
  FromLines = 0
  FromDots = 1
  Embossed = 2
End Enum

Private Enum DataOptions
  WebAddress = 0
  TextOnly = 1
  TextPlusPicture = 2
  PictureOnly = 3
  ZippedFile = 4
  AuthorizationHDBarcode = 5
End Enum

Private Enum TabNames
  StyleTab = 0
  TextTab = 1
  PictureTab = 2
  ZipTab = 3
  GeometryTab = 4
  EmbossTab = 5
  SecurityTab = 6
  ViewPrintTab = 7
End Enum

Private Authorized As Boolean
Private Incoming As String

Private SizeX As Long
Private SizeY As Long
Private oBmp As IPictureDisp

Private QualityTempFile As String
Private ViewPrintFile As String

Private Const SW_MAXIMIZE As Long = 3

Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Private Declare Function ShellExecute Lib "shell32" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long

Private Sub AfterJpegPicture_Paint()

If JpegFileText > "" Then
  UpdatePicture AfterJpegPicture, QualityTempFile
End If

End Sub

Private Sub BeforeJpegPicture_Paint()

BeforeJpegPicture.Cls
If JpegFileText > "" Then
  UpdatePicture BeforeJpegPicture, JpegFileText
End If

End Sub

Private Sub BlockColsScroll_Change()

If BlockColsScroll = 0 Then
  ColumnsLabel = "1 column"
Else
  ColumnsLabel = (BlockColsScroll * 2) & " columns"
End If
If SSTab.Tab = GeometryTab Then
  AutomaticSizeCheck = vbUnchecked
End If

End Sub

Private Sub BlockRowsScroll_Change()

If BlockRowsScroll = 0 Then
  RowsLabel = "1 row"
Else
  RowsLabel = (BlockRowsScroll * 2) & " rows"
End If
If SSTab.Tab = GeometryTab Then
  AutomaticSizeCheck = vbUnchecked
End If

End Sub

Private Sub CascadedOption_Click()

SecretPhraseText(1).Text = ""
RedoSecurityTab

End Sub

Private Sub CheckReaderSerialNumber()

Dim Ok As Boolean
Dim Scan As Long
Dim OneChar As String

Ok = True
For Scan = 1 To 15
  OneChar = Mid(SecretPhraseText(1).Text, Scan, 1)
  Select Case Scan
    Case 5, 10
      Ok = Ok And OneChar = "-"
    Case 15
      Ok = Ok And OneChar = ""
    Case Else
      Ok = Ok And OneChar >= "0" And OneChar <= "9"
  End Select
Next Scan

If Not Ok Then
  SecurityTroubleText = "Reader Serial Number must be ####-####-####"
End If

End Sub

Private Sub CheckSecurityField(Heading As String, value As String)

If value = "" Then
  SecurityTroubleText = Replace(Heading, ":", "") & " cannot be blank"
End If

End Sub

Private Sub CheckViewPrint()

Dim Ok As Boolean
Dim FileIndex As Integer
Dim Scan As Long
Dim Which As Long
Dim Style As Long
Dim RetCode As Long
Dim GridSize As Long
Dim Thickness As Long
Dim BlockRows As Long
Dim BlockCols As Long
Dim ErrorCorrection As Long
Dim EmbeddedDataBytes As Long
Dim UTF8 As String
Dim Filename As String
Dim EmbeddedData() As Byte

Rem  Clear it in case we fail
ViewPicture.Cls

Rem  See which data option is selected
For Which = 0 To 5
  If DataOption(Which) Then
    Exit For
  End If
Next Which

Rem  Get UTF-8 string
UTF8 = UnicodeToUTF8(RichTextUnicode(DataText))

Rem  Handle each data option
Select Case Which

  Case WebAddress
    If Left(UTF8, 7) <> "http://" And Left(UTF8, 8) <> "https://" Then
      SSTab.Tab = TextTab
      MsgBox "The data selection is Web address (URL), but the text doesn't begin with http:// or https://." & vbCrLf & vbCrLf & "Please include the correct prefix, or go to the Style tab and select Text instead of Web address (URL).", vbExclamation + vbOKOnly, "Not Text"
      Exit Sub
    End If

  Case TextOnly
    If Left(UTF8, 7) = "http://" Or Left(UTF8, 8) = "https://" Then
      SSTab.Tab = TextTab
      MsgBox "The data selection is Text, but the text begins with either http:// or https://." & vbCrLf & vbCrLf & "Please remove the prefix, or go to the Style tab and select Web address (URL) instead of Text.", vbExclamation + vbOKOnly, "Not A Web Address (URL)"
      Exit Sub
    ElseIf UTF8 = "" Then
      SSTab.Tab = TextTab
      MsgBox "The data selection is Text, but no text has been entered." & vbCrLf & vbCrLf & "Please either enter some text, or go to the Style tab and select another choice.", vbExclamation + vbOKOnly, "Text Missing"
      Exit Sub
    End If

  Case TextPlusPicture, PictureOnly
    If JpegFileText = "" Then
      SSTab.Tab = PictureTab
      MsgBox "The data selection includes a picture, but no picture has been entered.", vbExclamation + vbOKOnly, "Missing Picture"
      Exit Sub
    ElseIf DataOption(TextPlusPicture) And UTF8 = "" Then
      SSTab.Tab = TextTab
      MsgBox "The style selected is Text plus a picture, but no text has been entered." & vbCrLf & vbCrLf & "Please either enter some text, or go to the Style tab and select another choice.", vbExclamation + vbOKOnly, "Text Missing"
      Exit Sub
    End If

  Case ZippedFile
    If ZipFileText = "" Then
      SSTab.Tab = ZipTab
      MsgBox "The style selected is Zipped HTML File, but the text begins with either http:// or https://." & vbCrLf & vbCrLf & "Please remove the prefix, or go to the Style tab and select Web address (URL) instead of Text.", vbExclamation + vbOKOnly, "Not Text Style"
      Exit Sub
    End If

  Case AuthorizationHDBarcode
    Rem

End Select

If StyleOption(Embossed) Then
  If EmbossFileText = "" Then
    SSTab.Tab = EmbossTab
    MsgBox "The style selected is Dots with an embossed picture, but no embossed file has been entered.", vbExclamation + vbOKOnly, "Missing Emboss Picture"
    Exit Sub
  End If
End If

GridSize = GridSizeScroll
Style = IIf(StyleOption(FromLines), 1, 2)
Thickness = ThicknessScroll

Select Case AutomaticSizeCheck
  Case vbChecked
    BlockRows = 0
    BlockCols = 0
  Case vbUnchecked
    BlockRows = IIf(BlockRowsScroll = 0, 1, BlockRowsScroll * 2)
    BlockCols = IIf(BlockColsScroll = 0, 1, BlockColsScroll * 2)
End Select

Select Case AutomaticErrorCheck
  Case vbChecked
    ErrorCorrection = 0
  Case vbUnchecked
    ErrorCorrection = 4 + ErrorCorrectionScroll * 2
End Select

Filename = ""
If SSTab.TabEnabled(PictureTab) Then
  Filename = QualityTempFile
ElseIf SSTab.TabEnabled(ZipTab) Then
  Filename = ZipFileText
End If

If Not ExchangePacket(Chr(SetGeometry) & Chr(BlockRows) & Chr(BlockCols) & Chr(ErrorCorrection) & Chr(GridSize) & Chr(Style) & Chr(Thickness)) Then
  Exit Sub
End If

If Not ExchangePacket(Chr(SetText) & UTF8) Then
  Exit Sub
End If

If Filename > "" Then
  If Not SendBinaryData(Filename) Then
    Exit Sub
  End If
End If

If UniversalOption Or UniqueOption Or CascadedOption Then
  If Not ExchangePacket(Chr(SetIdentificationTag) & UnicodeToUTF8(IdentificationTagText)) Then
    Exit Sub
  End If
End If

If Not PublicOption Then
  If Not ExchangePacket(Chr(SetSecretPhrase) & UnicodeToUTF8(SecretPhraseText(0))) Then
    Exit Sub
  End If
End If

If PublicOption Then
  Ok = ExchangePacket(Chr(GeneratePublic))
ElseIf PrivateOption Then
  Ok = ExchangePacket(Chr(GenerateCompanyPrivate))
Else
  Ok = ExchangePacket(Chr(IIf(TemporaryCheck.value = vbChecked, GenerateTemporaryAuth, GeneratePermanentAuth)) & IIf(UniversalOption, "", SecretPhraseText(1)))
End If
If Not Ok Then
  Exit Sub
End If

BlockRows = Asc(Mid(Incoming, 3, 1))
BlockCols = Asc(Mid(Incoming, 4, 1))
ErrorCorrection = Asc(Mid(Incoming, 5, 1))
BlockRowsScroll = BlockRows \ 2
BlockColsScroll = BlockCols \ 2
ErrorCorrectionScroll = ErrorCorrection - 2
SizeX = GridSize + (GridSize * BlockCols * 8) + IIf(Style = 1, Thickness, 0) + GridSize
SizeY = GridSize + (GridSize * BlockRows * 8) + IIf(Style = 1, Thickness, 0) + GridSize

TotalBytesText = Format(BlockRows * BlockCols * 14, "#,###,##0")
ErrorBytesText = Format(BlockRows * BlockCols * (2 + ErrorCorrection / 2), "#,###,##0")
UserBytesText = Format(Val(TotalBytesText) - Val(ErrorBytesText), "#,###,##0")

If Val(ResolutionText) <= 0 Then
  SymbolWidthText = ""
  SymbolHeightText = ""
Else
  SymbolWidthText = Round(SizeX / Val(ResolutionText), 3) & """"
  SymbolHeightText = Round(SizeY / Val(ResolutionText), 3) & """"
End If

If Not RecoverBitmap Then
  Exit Sub
End If

Debug.Assert FileLen(ViewPrintFile) = 62 + (4 * ((SizeX + 31) \ 32)) * SizeY

ViewPicture_Paint

End Sub

Private Sub ChooseEmbossPicture_Click()

EmbossFileText = ""
Dialog.CancelError = True
Dialog.flags = cdlOFNNoChangeDir
Dialog.Filter = "*.jpg (JPEG files)|*.jpg|*.bmp (Bitmap files)|*.bmp"
On Error Resume Next
Dialog.ShowOpen
If Err.Number = cdlCancel Then
  Exit Sub
End If

EmbossFileText = Dialog.Filename
EmbossPicture_Paint

End Sub

Private Sub ChooseJpegCommand_Click()

JpegFileText = ""
Dialog.CancelError = True
Dialog.flags = cdlOFNNoChangeDir
Dialog.Filter = "*.jpg (JPEG files)|*.jpg"
On Error Resume Next
Dialog.ShowOpen
If Err.Number = cdlCancel Then
  Exit Sub
End If

JpegFileText = Dialog.Filename
BeforeJpegPicture_Paint
QualityScroll_Change

End Sub

Private Sub ChooseZipCommand_Click()

ZipFileText = ""
Dialog.CancelError = True
Dialog.flags = cdlOFNNoChangeDir
Dialog.Filter = "*.zip (Zip files)|*.zip"
On Error Resume Next
Dialog.ShowOpen
If Err.Number = cdlCancel Then
  Exit Sub
End If

ZipFileText = Dialog.Filename

End Sub

Private Sub CompanyNameText_Change()

WriteIniFile "Security", "CompanyName", CompanyNameText.Text

End Sub

Private Sub DataOption_Click(Index As Integer)

SSTab.TabEnabled(TextTab) = Index <= 2
SSTab.TabEnabled(PictureTab) = Index = 2 Or Index = 3
SSTab.TabEnabled(ZipTab) = Index = 4
If Index >= 3 Then
  DataText = ""
End If

End Sub

Private Sub DataText_Change()

Dim Cursor As Long

Static Recursion As Boolean

If Not Recursion Then
  Recursion = True
  Cursor = DataText.SelStart
  DataText.SelStart = 0
  DataText.SelLength = 2 * Len(DataText.Text)
  DataText.SelFontSize = 14
  DataText.SelLength = 0
  DataText.SelStart = Cursor
  Recursion = False
End If

End Sub

Private Sub EmbossPicture_Paint()

EmbossPicture.Cls
If EmbossFileText > "" Then
  UpdatePicture EmbossPicture, EmbossFileText
End If

End Sub

Private Sub ErrorCorrectionScroll_Change()

ErrorCorrectionLabel = (ErrorCorrectionScroll * 2 + 4) & "/48 bytes reserved" & vbCrLf & (ErrorCorrectionScroll + 2) & "/48 bytes correctable"
If SSTab.Tab = GeometryTab Then
  AutomaticErrorCheck = vbUnchecked
End If

End Sub

Private Function ExchangePacket(Stream As String) As Boolean

Dim Scan As Long

Incoming = ""
TcpTimer.Enabled = True
On Error Resume Next
TcpWinsock.SendData StreamToPacket(Stream)
If Err.Number <> 0 Then
  LostConnection
  Exit Function
End If
Do
  DoEvents
  If Right(Incoming, 1) = Chr(EndPacketByte) Then
    TcpTimer.Enabled = False
    Exit Do
  ElseIf Not TcpTimer.Enabled Then
    Rem  Must have had a TCP/IP error -- just bail out
    Exit Function
  End If
Loop

'Debug.Print ,
'For Scan = 1 To Len(Incoming)
'  Debug.Print Right("0" & Hex(Asc(Mid(Incoming, Scan, 1))), 2); " ";
'Next Scan
'Debug.Print

Debug.Assert Left(Incoming, 1) = Left(Stream, 1)
Incoming = Left(Incoming, Len(Incoming) - 1)

Incoming = Replace(Incoming, Chr(EscPacketByte) & Chr(EndPacketByte Xor 255), Chr(EndPacketByte))
Incoming = Replace(Incoming, Chr(EscPacketByte) & Chr(EscPacketByte Xor 255), Chr(EscPacketByte))

If Mid(Incoming, 2, 1) = Chr(NoError) Then
  ExchangePacket = True
ElseIf Incoming <> Chr(RetrieveNextLine) & Chr(NoMoreLines) Then
  MsgBox "Unexpected error code 0x" & Hex(Asc(Mid(Incoming, 2, 1))) & " to command code " & Hex(Asc(Left(Stream, 1))), vbInformation, "Unexpected error"
End If

End Function

Private Sub Form_Load()

Dim RetCode As Long
Dim Use As String
Dim Msg As String

Rem  Change caption
Caption = App.ProductName & "   Version " & App.Major & "." & App.Minor

Rem  Now change directory if it looks like program files
If InStr(App.Path, Environ("ProgramFiles")) = 1 Then
  Use = Environ("AppData") & "\HDBarcode"
  On Error Resume Next
  MkDir Use
  On Error GoTo 0
  ChDrive Use
  ChDir Use
End If

Rem  More stuff
gdipLoad
DataOption(WebAddress) = True
StyleOption(FromLines) = True
DataText = "http://www.hdbarcode.com"
GridSizeScroll_Change
ThicknessScroll_Change
ErrorCorrectionScroll_Change

QualityTempFile = CurDir & "\Quality.tmp"
ViewPrintFile = CurDir & "\HDBarcode.bmp"

CompanyNameText = ReadIniString("Security", "CompanyName", "")
IdentificationTagText = ReadIniString("Security", "IdentificationTag", "")
SecretPhraseText(0) = ReadIniString("Security", "SecretPhrase", "")

RedoResolution
RedoSecurityTab
SecurityTroubleText = "Looking for Code Generator on network"
SSTab.Tab = SecurityTab

End Sub

Private Sub Form_Unload(Cancel As Integer)

gdipUnLoad

End Sub

Private Function GetSecretPhraseText() As String

If PrivateOption Then
  GetSecretPhraseText = SecretPhraseText(0)
ElseIf UniqueOption Or CascadedOption Then
  GetSecretPhraseText = SecretPhraseText(1)
Else
  GetSecretPhraseText = ""
End If

End Function

Private Sub GridSizeScroll_Change()

GridSizeLabel = GridSizeScroll & "-pixel line separation"

End Sub

Private Sub IdentificationTagText_Change()

WriteIniFile "Security", "IdentificationTag", IdentificationTagText.Text
RedoSecurityTab

End Sub

Private Sub LostConnection()

On Error Resume Next
TcpWinsock.Close
UdpWinsock.Close
Authorized = False
TcpTimer.Enabled = False
UdpTimer.Enabled = False
MsgBox "The connection to the Code Generator was interrupted", vbExclamation, "Connection Interrupted"
SecurityTroubleText = "Looking for Code Generator on network"
SSTab.Tab = SecurityTab
UdpTimer.Enabled = True

End Sub

Private Sub NormalPrint()

Printer.ScaleMode = vbPixels
Printer.PaintPicture oBmp, (Printer.ScaleWidth - Width) / 2, Printer.ScaleY(0.25, vbInches, vbPixels), SizeX, SizeY
Printer.CurrentX = Printer.ScaleWidth / 2
Printer.CurrentY = Printer.ScaleY(1, vbInches, vbPixels) + SizeY
PrintWithLabel "Width", SymbolWidthText & """"
PrintWithLabel "Height", SymbolHeightText & """"
PrintWithLabel "Grid size", GridSizeScroll
If StyleOption(FromLines) Then
  PrintWithLabel "Thickness", ThicknessScroll
Else
  PrintWithLabel "Dot size", ThicknessScroll
End If
Printer.EndDoc

End Sub

Private Sub PagePrint()

Dim X As Long
Dim Y As Long
Dim SizeX As Long
Dim SizeY As Long
Dim LastY As Long
Dim FirstY As Long
Dim GridSizeAtStart As Long
Dim ThicknessAtStart As Long
Dim Msg As String

Printer.ScaleMode = vbPixels
X = Printer.ScaleX(0.25, vbInches, vbPixels)
Y = Printer.ScaleX(0.25, vbInches, vbPixels)
ThicknessAtStart = ThicknessScroll
GridSizeAtStart = GridSizeScroll
Do
  CheckViewPrint
  If X + SizeX + Printer.ScaleX(1, vbInches, vbPixels) > Printer.ScaleWidth Then
    If ThicknessScroll = ThicknessScroll.Max Then
      Exit Do
    End If
    ThicknessScroll = ThicknessScroll + 1
    GridSizeScroll = GridSizeAtStart + ThicknessScroll - ThicknessAtStart
    X = Printer.ScaleX(0.25, vbInches, vbPixels)
    Y = LastY + Printer.ScaleY(0.25, vbInches, vbPixels)
    CheckViewPrint
  End If
  If Y + SizeY + Printer.ScaleY(0.5, vbInches, vbPixels) > Printer.ScaleHeight Then
    Exit Do
  End If
  FirstY = Y
  Printer.PaintPicture oBmp, X, Y, SizeX, SizeY
  Printer.CurrentX = X + SizeX / 2
  Printer.CurrentY = FirstY + SizeY + Printer.ScaleY(0.125, vbInches, vbPixels)
  Printer.Print GridSizeScroll & "/" & ThicknessScroll
  If Printer.CurrentY > LastY Then
    LastY = Printer.CurrentY
  End If
  Y = FirstY
  GridSizeScroll = GridSizeScroll + 1
  X = X + SizeX + Printer.ScaleX(0.25, vbInches, vbPixels)
Loop
Printer.EndDoc

ThicknessScroll = ThicknessAtStart
GridSizeScroll = GridSizeAtStart

End Sub

Private Sub PrintCommand_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

Select Case Shift
  Case 0
    NormalPrint
  Case vbAltMask + vbCtrlMask
    PagePrint
End Select

End Sub

Private Sub PrintWithLabel(ByVal Label As String, What As String)

Dim X As Long

X = Printer.CurrentX
Label = Label & ": "
Printer.CurrentX = Printer.CurrentX - Printer.TextWidth(Label)
Printer.Print Label & What
Printer.CurrentX = X

End Sub

Private Sub PrivateOption_Click()

RedoSecurityTab

End Sub

Private Sub PublicOption_Click()

RedoSecurityTab

End Sub

Private Sub QualityScroll_Change()

BeforeSizeLabel = Format(FileLen(JpegFileText), "#,###,##0") & " bytes"
QualityLabel = QualityScroll.value & "%"
SaveAsJPEG LoadPicture(JpegFileText), QualityTempFile, QualityScroll.value
If FileLen(QualityTempFile) < FileLen(JpegFileText) Then
  AfterSizeLabel = Format(FileLen(QualityTempFile), "#,###,##0") & " bytes"
Else
  AfterSizeLabel = "using original since smaller"
  FileCopy JpegFileText, QualityTempFile
End If
UpdatePicture AfterJpegPicture, QualityTempFile

End Sub

Public Function ReadIniString(Section As String, Key As String, Default As String) As String

Dim Buffer As String

Buffer = Space(400)
GetPrivateProfileString Section, Key, Default, Buffer, Len(Buffer), CurDir & "\" & App.EXEName & ".ini"
ReadIniString = Trim(Left(Buffer, InStr(Buffer & Chr(0), Chr(0)) - 1))

End Function

Private Function RecoverBitmap() As Boolean

Dim Ok As Boolean
Dim Build As String
Dim Header As String
Dim FileIndex As Integer

Ok = ExchangePacket(Chr(RetrieveFirstLine))
If Not Ok Then
  Exit Function
End If

Header = Mid(Incoming, 3)
Do
  Ok = ExchangePacket(Chr(RetrieveNextLine))
  If Not Ok Then
    Exit Do
  ElseIf MirrorCheck Then
    Build = Mid(Incoming, 3) & Build
  Else
    Build = Build & Mid(Incoming, 3)
  End If
Loop

FileIndex = FreeFile
Open ViewPrintFile For Output As #FileIndex
Print #FileIndex, Header;
Print #FileIndex, Build;
Close #FileIndex

Set oBmp = LoadPicture(ViewPrintFile)
SizeX = ScaleX(oBmp.Width, vbHimetric, vbPixels)
SizeY = ScaleY(oBmp.Height, vbHimetric, vbPixels)

RecoverBitmap = True

End Function

Private Sub RedoResolution()

Dim Across As Double

Rem  Figure out printer resolution (Printer.ScaleX doesn't work on the DYMO label printer)
ResolutionText = ""
On Error Resume Next
Printer.ScaleMode = vbInches
Across = Printer.ScaleWidth
Printer.ScaleMode = vbPixels
ResolutionText = Round(Printer.ScaleWidth / Across)
Printer.KillDoc

End Sub

Private Sub RedoSecurityTab()

Dim RetCode As Long
Dim BlockRows As Long
Dim BlockCols As Long
Dim ErrorCorrection As Long

Rem  Adjust page according to which option selected
If PublicOption Then
  TemporaryCheck.Enabled = False
  IdentificationTagText.Enabled = False
  SecretPhraseText(0).Enabled = False
  SecretPhraseText(1).Enabled = False
  SecretPhraseLabel(0).Caption = "Secret Phrase:"
  SecretPhraseLabel(1).Caption = "Not Applicable:"
ElseIf PrivateOption Then
  TemporaryCheck.Enabled = False
  IdentificationTagText.Enabled = True
  SecretPhraseText(0).Enabled = True
  SecretPhraseText(1).Enabled = False
  SecretPhraseLabel(0).Caption = "Secret Phrase:"
  SecretPhraseLabel(1).Caption = "Not Applicable:"
  SecretPhraseText(0).PasswordChar = "*"
ElseIf UniversalOption Then
  TemporaryCheck.Enabled = True
  IdentificationTagText.Enabled = True
  SecretPhraseText(0).Enabled = True
  SecretPhraseText(1).Enabled = False
  SecretPhraseLabel(0).Caption = "Secret Phrase:"
  SecretPhraseLabel(1).Caption = "Not Applicable:"
  SecretPhraseText(0).PasswordChar = "*"
ElseIf UniqueOption Then
  TemporaryCheck.Enabled = True
  IdentificationTagText.Enabled = True
  SecretPhraseText(0).Enabled = True
  SecretPhraseText(1).Enabled = True
  SecretPhraseLabel(0).Caption = "Secret Phrase:"
  SecretPhraseLabel(1).Caption = "Reader Serial Number:"
  SecretPhraseText(0).PasswordChar = "*"
  SecretPhraseText(1).PasswordChar = ""
Else ' CascadedOption
  TemporaryCheck.Enabled = True
  IdentificationTagText.Enabled = True
  SecretPhraseText(0).Enabled = True
  SecretPhraseText(1).Enabled = True
  SecretPhraseLabel(0).Caption = "New Secret Phrase:"
  SecretPhraseLabel(1).Caption = "Old Secret Phrase:"
  SecretPhraseText(1).PasswordChar = "*"
End If

Rem  Fix text colors
SetTextColors IdentificationTagText, IdentificationTagLabel
SetTextColors SecretPhraseText(0), SecretPhraseLabel(0)
SetTextColors SecretPhraseText(1), SecretPhraseLabel(1)

Rem  Used to encrypt this symbol
UsageCheck(12) = IIf(PrivateOption Or CascadedOption, vbChecked, vbUnchecked)
UsageCheck(22) = vbUnchecked
UsageCheck(32) = vbUnchecked
UsageCheck(42) = IIf(PrivateOption, vbChecked, vbUnchecked)
UsageCheck(52) = IIf(UniqueOption Or CascadedOption, vbChecked, vbUnchecked)

Rem  Embedded in this symbol
UsageCheck(13) = IIf(UniversalOption Or UniqueOption Or CascadedOption, vbChecked, vbUnchecked)
UsageCheck(23) = vbUnchecked
UsageCheck(33) = IIf(UniversalOption Or UniqueOption Or CascadedOption, vbChecked, vbUnchecked)
UsageCheck(43) = IIf(UniversalOption Or UniqueOption Or CascadedOption, vbChecked, vbUnchecked)
UsageCheck(53) = vbUnchecked

Rem  Stop now if now authorized
If Not Authorized Then
  Exit Sub
End If

Rem  Assume success
SecurityTroubleText = ""
SecurityTroubleText.ForeColor = vbRed

If UniversalOption Or UniqueOption Or CascadedOption Then
  DataOption(AuthorizationHDBarcode) = True
ElseIf DataOption(AuthorizationHDBarcode) Then
  DataOption(WebAddress) = True
End If

If Not PublicOption Then
  CheckSecurityField SecretPhraseLabel(0), SecretPhraseText(0)
  If SecurityTroubleText > "" Then
    Exit Sub
  End If
End If

If UniqueOption Then
  CheckReaderSerialNumber
  If SecurityTroubleText > "" Then
    Exit Sub
  End If
ElseIf CascadedOption Then
  CheckSecurityField SecretPhraseLabel(1), SecretPhraseText(1)
  If SecurityTroubleText > "" Then
    Exit Sub
  End If
End If

End Sub

Private Sub ResolutionText_Change()

If ActiveControl Is ResolutionText Then
  CheckViewPrint
  ResolutionText.SetFocus
End If

End Sub

Private Sub SecretPhraseText_Change(Index As Integer)

If Index = 0 Then
  WriteIniFile "Security", "SecretPhrase", SecretPhraseText(Index).Text
End If
RedoSecurityTab

End Sub

Private Sub SelectPrinterCommand_Click()

Dialog.ShowPrinter
RedoResolution

End Sub

Private Function SendBinaryData(Filename) As Boolean

Dim CommandCode As Byte
Dim BytesLeft As Long
Dim FileIndex As Integer
Dim Chunk As String

FileIndex = FreeFile
Open Filename For Binary As #FileIndex
Chunk = Space(1000)
CommandCode = SetBinary
BytesLeft = LOF(FileIndex)
Do
  Get #FileIndex, , Chunk
  If Len(Chunk) > BytesLeft Then
    Chunk = Left(Chunk, BytesLeft)
  End If
  If Not ExchangePacket(Chr(CommandCode) & Chunk) Then
    Close #FileIndex
    Exit Function
  End If
  BytesLeft = BytesLeft - Len(Chunk)
  If BytesLeft <= 0 Then
    Exit Do
  End If
  CommandCode = AppendBinary
Loop
Close #FileIndex
SendBinaryData = True

End Function

Private Sub SetTextColors(TextControl As TextBox, LabelControl As Label)

If TextControl.Enabled Then
  TextControl.ForeColor = vbBlack
  TextControl.BackColor = vbWhite
  LabelControl.Enabled = True
Else
  TextControl.ForeColor = RGB(128, 128, 128)
  TextControl.BackColor = BackColor
  LabelControl.Enabled = False
End If

End Sub

Private Sub SSTab_Click(PreviousTab As Integer)

If Not Authorized Then
  SSTab.Tab = SecurityTab
ElseIf SSTab.Tab = ViewPrintTab Then
  CheckViewPrint
End If

End Sub

Private Sub StyleOption_Click(Index As Integer)

SSTab.TabEnabled(EmbossTab) = (Index = Embossed)
ThicknessScroll_Change

End Sub

Private Sub StylePicture_Click(Index As Integer)

StyleOption(Index) = True

End Sub

Private Sub TcpTimer_Timer()

TcpTimer.Enabled = False
LostConnection

End Sub

Private Sub TcpWinsock_Connect()

SecurityTroubleText = ""
Authorized = True
SSTab.Tab = StyleTab

End Sub

Private Sub TcpWinsock_DataArrival(ByVal bytesTotal As Long)

Dim Data As String

TcpWinsock.GetData Data
Incoming = Incoming & Data
'Debug.Print "DataArrival of " & Len(Data) & " bytes"

End Sub

Private Sub TcpWinsock_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)

TcpTimer.Enabled = False
LostConnection

End Sub

Private Sub ThicknessScroll_Change()

If StyleOption(FromLines) Then
  ThicknessLabel = ThicknessScroll & "-pixel line thickness"
Else
  ThicknessLabel = ThicknessScroll & " dot size"
End If

End Sub

Private Sub UdpTimer_Timer()

UdpWinsock.RemoteHost = "255.255.255.255"
UdpWinsock.RemotePort = CodeGeneratorPort
UdpWinsock.SendData UDP_QUERY

End Sub

Private Sub UdpWinsock_DataArrival(ByVal bytesTotal As Long)

Dim Response As String

UdpWinsock.GetData Response
CompanyNameText = Mid(Response, InStr(Response, "=") + 1)
CodeGeneratorIPAddrText = UdpWinsock.RemoteHostIP
UdpTimer.Enabled = False
TcpWinsock.RemoteHost = UdpWinsock.RemoteHostIP
UdpWinsock.Close
TcpWinsock.RemotePort = CodeGeneratorPort
TcpWinsock.Connect

End Sub

Private Sub UniqueOption_Click()

SecretPhraseText(1).Text = ""
RedoSecurityTab

End Sub

Private Sub UniversalOption_Click()

RedoSecurityTab

End Sub

Private Sub UpdatePicture(Picture As PictureBox, ByVal Filename As String)

Dim SizeX As Long
Dim SizeY As Long
Dim Better As Double
Dim Mag As Double

On Error Resume Next
Set oBmp = LoadPicture(Filename)
If Err.Number <> 0 Then
  Exit Sub
End If

SizeX = ScaleX(oBmp.Height, vbHimetric, vbPixels)
SizeY = ScaleY(oBmp.Width, vbHimetric, vbPixels)

Mag = Picture.ScaleWidth / SizeX
If Height * Mag > Picture.ScaleHeight Then
  Mag = Picture.ScaleHeight / SizeY
End If
Mag = Mag * 0.8

Picture.BackColor = vbWhite
Picture.Cls

If Not Picture Is ViewPicture Then
  Picture.PaintPicture oBmp, (Picture.ScaleWidth - Mag * SizeX) / 2, (Picture.ScaleHeight - Mag * SizeY) / 2, SizeX * Mag, SizeY * Mag, 0, 0, SizeX, SizeY
  Exit Sub
End If

Better = 4
While Better > Mag
  Better = Better / 2
Wend
Mag = Better

Picture.PaintPicture oBmp, (Picture.ScaleWidth - Mag * SizeX) / 2, (Picture.ScaleHeight - Mag * SizeY) / 2, SizeX * Mag, SizeY * Mag, GridSizeScroll, GridSizeScroll, SizeX - GridSizeScroll, SizeY - GridSizeScroll

End Sub

Private Sub ViewCommand_Click()

ShellExecute hWnd, "Open", ViewPrintFile, vbNull, CurDir, SW_MAXIMIZE

End Sub

Private Sub ViewPicture_Paint()

UpdatePicture ViewPicture, ViewPrintFile

End Sub

Public Sub WriteIniFile(Section As String, Key As String, ByVal Text As String)

WritePrivateProfileString Section, Key, Text, CurDir & "\" & App.EXEName & ".ini"

End Sub
