With GuiXT Controls it is possible to display a windows form as a popup. In this tutorial we will display a barcode (optical machine-readable representation of data) within a popup.

Step no.1: Choose an appropriate barcode generator.

For our example here we will use the barcode image generation library created by Brad Barnhill:
http://www.codeproject.com/Articles/20823/Barcode-Image-Generation-Library

In order to use this library within our project we have to add a reference to the file BarcodeLib.dll.

You can find a list of common barcodes here:
http://en.wikipedia.org/wiki/Barcode

Step no. 2: Create a new windows forms application and add these elements:

PictureBox: The picture of the created barcode
RichTextBox: Formated text e.g. the ASCII input of the barcode

Step no. 3: Implement a function that generates and displays the barcode:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
Public Function create_barcode(ByVal text As String, _
                                    ByVal posX As String, _
                                    ByVal posY As String, _
                                    ByVal p_type As String) As String
        Try
            Dim b = New barcodeviewer 'New instance of our form
            b.Text = text
            b.RichTextBox1.Text = text 'Display the text below the barcode

            Dim barcode As BarcodeLib.Barcode = New BarcodeLib.Barcode
            Dim type As BarcodeLib.TYPE = BarcodeLib.TYPE.UPCA

            'Choose type of barcode to be generated
            Select Case p_type.ToLower

                Case "upca"
                    type = BarcodeLib.TYPE.UPCA

                Case "code128"
                    type = BarcodeLib.TYPE.CODE128

                Case "ean13"
                    type = BarcodeLib.TYPE.EAN13
            End Select

            'Create the barcode image
            Dim i = barcode.Encode(type, text, 300, 100)

            'Display the barcode image
            b.PictureBox1.Image = i

            'Display the form at position (posX,posY)
            b.Location = New Point(CInt(posX), CInt(posY))
            b.Show()
            
        Catch ex As Exception

            'An error occured
            Return ex.Message

        End Try

        Return "0"

    End Function

Step no. 4: Create a GuiXT script and an InputScript:
 

In this tutorial we use our own inputfield containing the string which will be converted to a barcode. In a more common case the string might represent a material number.
 

// Display a barcode
inputfield (15,1) "Display barcode:" (15,15) size="25" name="barcodetext" default="123456789012" -required
Set
text[barcode_types] "=--- Auswahl Barcode-Typ ---;upca=UPC-A;code128=Code 128;ean13=EAN-13;"
dropdownlist
(15,43) "barcode_types" refer="V[barcode_type]" width="25"
pushbutton
(15,70) "ok" process="display_barcode.txt"
inputfield
(16,1) "(Coordinates:)" (16,18) size="5" name="barcode_position_x" default="0" -numerical
inputfield
(16,25) size="5" name="barcode_position_y" -nolabel default="0" -numerical


display_barcode.txt:

callvb
returncode = tutorials.barcodeviewer.create_barcode "&V[barcodetext]" "&V[barcode_position_x]" "&V[barcode_position_y]" "&V[barcode_type]"

if
not V[returncode=0]
  message "&V[returncode]" title="Return"
endif


return

Result: