Buchempfehlung
Visual Basic 6 Kochbuch
Visual Basic 6 Kochbuch
Viele praktische Tipps zum Programmieren mit Visual Basic 6, die sich oft auch auf FB übertragen lassen. [Mehr Infos...]
FreeBASIC-Chat
Es sind Benutzer im FreeBASIC-Chat online.
(Stand:  )
FreeBASIC bei Twitter
Twitter FreeBASIC-Nachrichten jetzt auch über Twitter erhalten. Follow us!

Simple GUI

Projektzusammenfassung
Projekt-Maintainer:MitgliedLothar Schirm Projektseite angelegt:14.01.2015
Lizenzierung:k. A. Letzte Bearbeitung:09.02.2015
Projektkategorie:Graphical User Interface      [Zurück zur Übersicht]

The project provides a small source code library for a simple GUI to be used on a FreeBasic graphics window. The following controls are implemented (Feb 09, 2015):
- Label
-TextBox
- Button
- Listbox
- DataGrid (editable)
- Trackbar
- Progressbar.
The purpose is to enable a very easy coding with a simple event loop for small projects.

The project was inspired by some code examples of BasicCoder2 and dodicat on the english forum and is introduced here: Externer Link!http://www.freebasic.net/forum/viewtopic.php?f=7&t=23202.

Example:

#Include "GUI.bas"

Dim Shared As Button Button_Add, Button_Close
Dim Shared As TextBox Text_a, Text_b, Text_result


Sub CreateWindow()
'Create Window

    OpenWindow                                      (250, 200, "Add two numbers")
    Var Label_a = Label_New             (20, 20, 60, 20, "a:")
    Var Label_b = Label_New             (20, 50, 60, 20, "b:")
    Button_Add = Button_New             (120, 80, 60, 20, "Add")
    Var Label_result = Label_New    (20, 110, 60, 20, "a + b:")
    Text_a = TextBox_New                    (80, 20, 100, 20, "0")
    Text_b = TextBox_New                    (80, 50, 100, 20, "0")
    Text_result = TextBox_New           (80, 110, 100, 20, "0")
    Button_Close = Button_New           (180, 170, 60, 20, "Close")

End Sub


Sub Add()
'Get a and b from textboxes, display a + b:

    Dim As Single a, b, result

    a = Val(TextBox_GetText(Text_a))
    b = Val(TextBox_GetText(Text_b))
    result = a + b
    TextBox_SetText(Text_result, Str(result))

End Sub


'Main:

CreateWindow()

Do
    If TextBox_Event(Text_a) Then TextBox_Edit(Text_a)
    If TextBox_Event(Text_b) Then TextBox_Edit(Text_b)
    If TextBox_Event(Text_result) Then TextBox_Edit(Text_result, 1) 'ReadOnly
    If Button_Event(Button_Add) Then Add()
Loop Until Button_Event(Button_Close) Or Window_Event_Close

End

GUI_Test

The project can be downloaded and will only be updated here:
downloads/bibliotheken/simple-gui-356.html

Please do not use the download shown below, the file names have been changed automatically by the project file management. Therefore the library file GUI.bas may not be found by the other files when compiled. The files are not actual any more. New releases will only be available at the download site above!

Dateimanager
GUI_Test (DataGrid)17.01.15 16:433 kB
GUI_Test (Buttons, TextControls)17.01.15 16:412 kB
GUI_Test (ListBox)17.01.15 16:422 kB
Simple GUI19.01.15 16:2414 kB