How to create GUI application
To create GUI based application you just have to use UI(User Interface) module and its commands.
ThinBASIC allows you to create modal and modeless dialog, place controls inside and handle events the controls receive.
Dialog is rectangular window on the screen. It can be created using DIALOG NEW statement.
Dialog has three main parts by default:
- caption
- client area
- border
Caption is border with name of the dialog, and it can contain buttons for maximization, minimalization and closing the dialog. It can also contain "Help" icon, which can be programmed to show some kind of help to the user. Programmer can also define custom icon for the dialog.
Client area is the are inside body of the dialog, where you can place the controls and where the 99% of interaction with user occurs.
Dialog border is thin frame around the dialog. It can be programmed to provide resizing of the dialog.
Dialogs can be shown using DIALOG SHOW command in 2 basic ways:
DIALOG SHOW MODAL will show dialog in classic way, that means it shows on the screen and further script execution is stopped until the dialog is closed. It is also impossible to interact with other windows created by the program by the time dialog is visible on the screen.
DIALOG SHOW MODELESS will show dialog on the screen, but the further script execution is still performed. This is useful for various tool windows and other dialogs which allow user interaction with other opened windows of the program.
The number of dialog windows script opens is not limited. To be able to differentiate between dialogs, each dialog is identified by dialog handle - automatically generated 32bit integer value.
Control is element of user interface, which allows some kind of interaction. Controls are for example buttons, text boxes and other you know from using Windows programs. They are placed to dialog client area using CONTROL ADD statements.
ThinBASIC dialog engine allows building dynamic, resizeable interfaces very easily, by specifying anchors using CONTROL SET RESIZE statement.
The number of controls in dialog is not limited. To be able to differentiate between control, each dialog is identified by handle of dialog it belongs to and control id. Control id can be completely user defined.
Alternativelly, controls can be identified by single control handle too.
Events are essential principle working of user interface is based on. Both dialogs and controls can react on events generated by user represented by messages.
You can learn more about them in following chapter of this tutorial.
|