Mit GuiXT Controls können Sie eine Windows Form als PopUp anzeigen. In diesem Tutorial stellen wir als Beispiel einen Barcode (optoelektronisch lesbare Schrift) in einem Popup dar. 1. Schritt: Einen
geeigneten Barcodegenerator auswählen 2. Schritt: Eine Windows Forms Anwendung
mit folgenden Elementen erstellen:
Wichtig: Damit die Position der Form zur Laufzeit festgelegt werden kann, ändern Sie bitte in den Eigenschaften folgenden Punkt:
3. Schritt: Eine Funktion für das Generieren und Anzeigen des Barcodes implementieren: |
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
4. Schritt:
Ein GuiXT Script sowie InputScript erstellen:
Für dieses Beispiel verwenden wir
ein eigenes Eingabefeld, in dem Sie den String eintragen, der als Barcode
dargestellt werden soll. In einer konkreten Anwendung könnten Sie hier z.B. die
Artikelnummer aus einem SAP-Feld entnehmen.
GuiXT
// Barcode anzeigen
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
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
Ergebnis:
5. Schritt:
Die Windows Form in das SAP GUI einbetten
Das Verschieben, Schließen und Interagieren mit dem Barcodedialog ist nicht vorgesehen, daher empfiehlt es sich, die Form bzw. den Dialog in das SAP GUI Fenster einzubetten. Ändern Sie bitte dazu zunächst wieder die Eigenschaften der Form ab. Dies ist auch die Standardeinstellung bei neu erstellten Dialogen.
Legen Sie im GuiXT Script einen Container für den Barcodedialog an und rufen die Initialisierungsroutine auf:
GuiXT
Control (3,45) (5,85) progID="Shell.Explorer" name="r1" initFlag="r1init"
Danach rufen Sie dann die VB.NET Methode auf, die den Dialog innerhalb des Containers anzeigt:
if V[r1init]
CallVB tutorials.barcodeviewer.embed_barcode "&F[MARA-EAN11]" "200" "27" "ean13" "&V[r1]"
endif
In Ihrem VB.NET Projekt können Sie die Methode create_barcode im Wesentlichen übernehmen, bis auf folgende Änderungen (rote Zeilennummerierung):
VB.NETPublic Function embed_barcode(ByVal text As String, _
ByVal posX As String, _
ByVal posY As String, _
ByVal p_type As String, ByVal w As Object) 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()
' embed into SAP GUI window
guixt.EmbedForm(b, w)
Catch ex As Exception
'An error occured
Return ex.Message
End Try
Return "0"
End Function
Ergebnis von Schritt 5 (in Transaktion MM03):