The HistoryBox is a TextBox that has been extended by the property to temporarily store a certain number of entries. In the HistoryBox, you can use the arrow keys ↑ and ↓ to search for input that has already been entered, for example, like in a console, and then call it up.
The classes HistoryBox, History and _HistoryOptions have been developed by Tobias Boege.
Figure 16.10.1: Icon for the component HistoryBox
As with all components, the HistoryBox was also given an icon by the authors, which you can see in the IDE's properties window under 'Form'. The icon must be inserted in the project directory in an invisible folder .hidden/control as an image of type 'png', so that it can be seen in the IDE in the virtual folder 'Project'.
The chapter '21.3.5 Project GUI MySQL' describes in detail the use of a HistoryBox for the database client presented there. You will also find the three classes HistoryBox, History and _HistoryOptions as well as the icon mentioned above in the project archive.
Figure 16.10.2: GUI for the console program 'mysql'.
For this reason, the relevant source code can be shortened considerably in relation to the component HistoryBox:
' Gambas class file ... Public Sub Form_Open() FMain.Center FMain.Resizable = True ... txbHistoryEingabe.Foreground = Color.Gray txbHistoryEingabe.Alignment = Align.Center txbHistoryEingabe.Text = "*** Enter the SQL statement and activate it with the ENTER key! ***" txbHistoryEingabe.ReadOnly = True txbHistoryEingabe.History = New History(50) ' 50 entries are stored internally ... End ' Form_Open() Public Sub btnProcessStart_Click() ... txbHistoryEingabe.Alignment = Align.Normal End ' btnProcessStart Public Sub btnTextAreaClear_Click() ... txbHistoryEingabe.SetFocus End ' btnTextAreaClear ... Public Sub ProcessStart() Dim sCommand As String txbHistoryEingabe.Foreground = Color.Black txbHistoryEingabe.Clear ... txbHistoryEingabe.ReadOnly = False txbHistoryEingabe.SetFocus End ' ProcessStart() ... Public Sub txbHistoryEingabe_Activate() If txbHistoryEingabe.Text = "" Then Return txbHistoryEingabe.Text = Trim(txbHistoryEingabe.Text) WriteToMyProcess(txbHistoryEingabe.Text) ' txbHistoryEingabe.Clear ---> This is done by the History-Box itself! End ' txbHistoryEingabe_Activate() ... Public Sub Form_Close() ... End ' Form_Close()
Die HistoryBox ist eine TextBox, die um die Eigenschaft erweitert wurde, eine bestimmte Anzahl von Eingaben temporär zu speichern. Sie können in der HistoryBox die Pfeiltasten ↑ und ↓ benutzen, um zum Beispiel wie in einer Konsole nach bereits eingegebenen Eingaben zu suchen und diese dann aufrufen.
Die Klassen HistoryBox, History und _HistoryOptions wurden von Tobias Boege entwickelt.
Abbildung 16.10.1: Icon für die Komponente HistoryBox
Wie bei allen Komponenten üblich, wurde auch der HistoryBox von den Autoren ein Icon spendiert, das Sie in der IDE im Fenster Eigenschaften unter 'Form' sehen. Das Icon muss im Projektverzeichnis in einem unsichtbaren Ordner .hidden/control als Bild vom Typ 'png' eingefügt werden, damit es in der IDE im virtuellen Ordner 'Projekt' zu sehen ist.
Im Kapitel '21.3.5 Projekt GUI MySQL' wird der Einsatz einer HistoryBox für den dort vorgestellten Datenbank-Client ausführlich beschrieben. Sie finden dort auch die o.a. drei Klassen HistoryBox, History und _HistoryOptions sowie das erwähnte Icon im Projekt-Archiv.
Abbildung 16.10.2: GUI für das Konsolen-Programm 'mysql'
Deshalb kann hier der relevante Quelltext – bezogen auf die Komponente HistoryBox – stark verkürzt angegeben werden:
' Gambas class file ... Public Sub Form_Open() FMain.Center FMain.Resizable = True ... txbHistoryEingabe.Foreground = Color.Gray txbHistoryEingabe.Alignment = Align.Center txbHistoryEingabe.Text = "*** SQL-Anweisung eingeben und mit ENTER-Taste aktivieren ***" txbHistoryEingabe.ReadOnly = True txbHistoryEingabe.History = New History(50) ' 50 Eingaben werden intern gespeichert ... End ' Form_Open() Public Sub btnProcessStart_Click() ... txbHistoryEingabe.Alignment = Align.Normal End ' btnProcessStart Public Sub btnTextAreaClear_Click() ... txbHistoryEingabe.SetFocus End ' btnTextAreaClear ... Public Sub ProcessStart() Dim sCommand As String txbHistoryEingabe.Foreground = Color.Black txbHistoryEingabe.Clear ... txbHistoryEingabe.ReadOnly = False txbHistoryEingabe.SetFocus End ' ProcessStart() ... Public Sub txbHistoryEingabe_Activate() If txbHistoryEingabe.Text = "" Then Return txbHistoryEingabe.Text = Trim(txbHistoryEingabe.Text) WriteToMyProcess(txbHistoryEingabe.Text) ' txbHistoryEingabe.Clear ---> Das erledigt die History-Box selbst! End ' txbHistoryEingabe_Activate() ... Public Sub Form_Close() ... End ' Form_Close()