creates a Form or dialog box in a GLL using a dialog box syntax.
Dialog hd%,x%,y%,w%,h%,tit$ [,flag% [,height%,font$] ]
EndDialog
hd%,x%,y%,w%,h%,flag%,height%:integer expression
tit$, font$:sexp
Dialog boxes are used for interaction between the program and the user. In contrast with GFA-BASIC 16 dialog boxes created with the Dialog command are OCX Forms. As such it is easier to create a dialog as a Form using the Form editor.
The Dialog command is a hold over from GFA-BASIC 16. The way they are used in GFA-BASIC 32 is the same as in GFA-BASIC 16. In particular, when a dialog box is created in a GLL the syntax and message handling is the same.
Formally, a Dialog structure has the following layout:
Dialog
Dialog control elements
EndDialog
The Dialog structure control elements are specified within the Dialog-EndDialog definition. The Dialog structure header marks the Dialog definition. It is followed by six parameters:
hd%: | Dialog structure number (0 to 31) |
x%,y%: | X, Y coordinates of upper left corner of Dialog box |
w%: | Dialog box width in pixels |
h%: | Dialog box height in pixels |
tit$: | Dialog structure title |
Optionally three other parameters can be defined:
flags%: | WS_Style flags to be used by the Dialog |
height%: | Font-height (normally negative) |
font$: | Typeface name of the font |
flags% can be a combination (binary Or) of the following values:
WS_BORDER ($00800000) | window with a border |
WS_CAPTION ($00C00000) | creates a window with a title. To make a system menu visible in such a window the WS_CAPTION and WS_POPUPWINDOW style elements must be combined. |
WS_CHILD ($40000000) | a window with child windows |
WS_CHILDWINDOW | a child window |
WS_CLIPCHILDREN ($02000000) | clips all window output to the area outside of a child window. |
WS_CLIPSIBLINGS ($04000000) | clips all window output within a child window to its client area. |
WS_DISABLED ($08000000) | a window, which is initially inactive. |
WS_DGLFRAME ($00400000) | a window with a double border but without a title. |
WS_GROUP ($00020000) | marks the first control element within a group of control elements (used only in dialog boxes). |
WS_HSCROLL ($00100000) | a window with a horizontal scroll bar. |
WS_ICONIC ($20000000) | a window which is initially displayed as an icon. |
WS_MAXIMIZE ($01000000) | a window with maximum dimensions |
WS_MAXIMIZEBOX ($00010000) | a window with a maximize box. |
WS_MINIMIZE ($20000000) | a window with minimal dimensions. |
WS_MINIMIZEBOX ($00020000) | a window with a minimize box. |
WS_OVERLAPPED ($00000000) | an overlapping window. The window contains a border and a title. The client area overlaps with window border and title. |
WS_OVERLAPPEDWINDOW (0xCF0000) | an overlapping window with following style elements: WS_OVERLAPPED WS_CAPTION WS_SYSMENU WS_THICKFRAME WS_MINIMIZEBOX WS_MAXIMIZEBOX |
WS_POPUP ($80000000) | a popup window. Such window can't have the WS_CHILD attribute. |
WS_POPUPWINDOW (0x80880000) | a popup window with following style elements: WS_BORDER WS_POPUP WS_SYSMENU |
WS_SYSMENU ($00080000) | a window with a system menu in the title bar. Used only in windows with a title bar. |
WS_TABSTOP ($00010000) | a window with a number of control elements which the user can arrive at by tapping the tab key. Used only in dialog boxes. |
WS_THICKFRAME ($00040000) | a window with a thick border which is used to "size" the window. |
WS_VISIBLE ($10000000) | a window which is initially visible, i.e. is displayed as a top window. |
WS_VSCROLL ($00200000) | a window with a vertical scroll bar. |
DS_LOCALEDIT | Specifies that edit controls in the Dialog box will use memory in the application's data segment. By default, all edit controls in Dialog boxes use memory outside the application's data segment. This feature can be suppressed by adding the DS_LOCALEDIT flag to the STYLE command for the Dialog box. If this flag is not used, EM_GETHANDLE and EM_SETHANDLE messages must not be used since the storage for the control is not in the application's data segment. This feature does not affect edit controls created outside of Dialog boxes. |
DS_MODALFRAME | Creates a Dialog box with a modal Dialog box frame that can be combined with a title bar and System menu by specifying the WS_CAPTION and WS_SYSMENU styles. |
DS_NOIDLEMSG | Suppresses WM_ENTERIDLE messages that Windows would otherwise send to the owner of the Dialog box while the Dialog box is displayed. |
DS_SYSMODAL | Creates a system-modal Dialog box. |
A Dialog is a Form object and does not have the WS_POPUP style as a normal API dialog box. As with any other Form a Dialog box is a WS_OVERLAPPED window. It is simply another way to open a Form.
A program can define several Dialog structures, which are referred to by their Dialog number. After a dialog structure has been defined it can be displayed by using the ShowDialog command, where only the number of the dialog structure must be specified.
A dialog box is a Form object, unless used in a GLL. In a GLL the dialog box is plain API dialog box that is to be filled with plain controls. You can still use plain controls in a dialog, but you cannot respond to event subs.
Because the dialog is a Form, they need an object name. The Dialog command accepts a unique number in the range from 0 to 31. The dialog box with number #0 is named Dlg_0, the dialog box with #1 is called Dlg_1, etc. Properties and methods are invoked as Dlg_1.Property and Dlg_1.Method. The events for the dialog box are the same as for a form and have the form of Dlg_n_event. For instance, the event sub to handle posted messages, which are retrieved from the message queue:
Sub Dlg_1_Message(hWnd%, Mess%, wParam%, lParam%)
' Code
EndSub
As with any Form, controls may be created the API way or the OLE way, using the OCX command. An advantage of using OCX controls is the way notification messages from the control are handled, because messages from the OCX controls are handled in OCX event subs.
OCX type name
OCX type name = "Caption", x, y, w, h
OCX type name = "Caption", id, x, y, w, h
OCX type name = "Caption", id, x, y, w, h, style
type | Name of the GFA-BASIC 32 OCX type: Command, Option, CheckBox, RichEdit, ImageList, Label, ListBox, TreeView, ListView, TextBox, Image, Timer, Scroll, Slider, ProgressBar, ToolBar, StatusBar, ComboBox, Frame, TabStrip, Animation, UpDown, Form. |
name | name of the global variable for the OCX. Defines the names for the event subs: name_event |
Caption | Specifies text that is displayed with the control. |
ID% | Optional. Specifies the control identifier. (0through 65,535). Normally, GFA-BASIC 32 assigns OCX controls an identifier, but for GFA-BASIC 16 programs it may be handy to keep the identifier value. |
x%, y% | Specifies the x- and y-coordinate of the left top side of the control relative to the left top side of the dialog box. The coordinate is in dialog units and is relative to the origin of the dialog box, window, or control containing the specified control. |
width% | Specifies the width of the control. |
height% | Specifies the height of the control. |
style% | Optional. Specifies the control styles. Use the bitwise OR (|) operator to combine styles. |
The dialog box can also contain plain controls. In a GLL only plain controls can be used. For instance, to create a simple left justified static text control:
LText text$, ID%, x%, y%, width%, height% [,style%]
All control statements use the same syntax:
CtrlName text$, ID%, x%, y%, width%, height% [,style%]
CtrlName | Name of the GFA-BASIC 32 control statement: LText, RText, CText, Icon, PushButton, DefPushButton, CheckBox, AutoCheckBox, RadioButton, AutoRadioButton, ListBox, ComboBox, EditText, Scrollbar, AnimateCtrl, TabCtrl, HeaderCtrl, ListViewCtrl, TreeViewCtrl, ProgressCtrl, TrackBarCtrl, StatusCtrl, ToolBarCtrl, UpDownCtrl. RichEditCtrl. |
text$ | Specifies text that is displayed with the control. |
ID% | Specifies the control identifier. (0through 65,535) |
x%, y% | Specifies the x- and y-coordinate of the left top side of the control relative to the left top side of the dialog box. The coordinate is in dialog units and is relative to the origin of the dialog box, window, or control containing the specified control. |
width% | Specifies the width of the control. |
height% | Specifies the height of the control. |
style% | Specifies the control styles. Use the bitwise OR (|) operator to combine styles. |
Note - There is no Static control command, Static is used to declare static local variables. Use the general Control statement instead.
In a normal program the messages from plain controls are handled in the parent's event sub _Message() (for posted messages) or _MessageProc() (for all messages). In a GLL the messages are handled in the Gfa_CB() callback sub.
The Control statement
The Control statement is used to create a plain control. In a GLL try to avoid the general Control statement to create a child window, these controls use the system font, rather than the DEFAULT_ GUI_FONT.
Control text$,ID%,class$,style%,x%,y%,w%,h%,
Control creates a program defined control window with width w% and height h% at coordinates specified in x% and y%. The window shows the text specified in text$ and can be referred to with the value specified in ID%.
class$ specifies the class of the control elements which the control window can assign.
Call demodialog() // dialog structure
// activate DefPushButton
~SetFocus(DlgItem(1, 103))
Do
Sleep // to wait of a message
Until MouseK = 2 // till left mouse key pressed
CloseDialog # 1 // close dialog
Procedure demodialog() // to build the dialog
Local i%, a%
Local dlgf&, s%, style1%, style2%
Local style3%, style4%, style5%
Local style6%, style7%, style8%, v%
DlgBase Pixel // dialog in pixels
Dialog # 1, 10, 100, 600, 360, "Demo Dialog"
DlgBase Unit
// rest of it in UNITS (1/4 sign width, 1/8 sign height
style1% = WS_TABSTOP
style2% = BS_DEFPUSHBUTTON | WS_TABSTOP
style3% = BS_GROUPBOX | WS_TABSTOP
style4% = BS_AUTORADIOBUTTON | WS_TABSTOP
style5% = BS_AUTOCHECKBOX | WS_TABSTOP
style6% = ES_UPPERCASE | WS_BORDER | _
WS_TABSTOP
style7% = LBS_NOTIFY | LBS_SORT | _
LBS_STANDARD _
| WS_BORDER | WS_VSCROLL
style8% = CBS_DROPDOWN | CBS_SORT | _
CBS_HASSTRINGS | WS_VSCROLL
// type title / contents Id x y w h style
PushButton "Pushbutton 1", 100, 12, 14, 72, 14, _
style1%
PushButton "Pushbutton 2", 101, 12, 32, 72, 14, _
style1%
PushButton "Pushbutton 3", 102, 12, 50, 72, 14, _
style1%
DefPushButton "DefPushbutton", 103, 12, 68, 72, 14, _
style2%
ScrollBar "", 104, 0, 143, 283, 9, SBS_HORZ
ScrollBar "", 105, 283, 0, 9, 152, SBS_VERT
GroupBox "Radiobuttons", 106, 89, 14, 56, 53, style3%
RadioButton "Radio 1", 107, 93, 25, 39, 12, style4%
RadioButton "Radio 2", 108, 93, 36, 39, 12, style4%
RadioButton "Radio 3", 109, 93, 47, 39, 12, style4%
CheckBox "Checkbox 1", 110, 17, 94, 61, 12, style5%
CheckBox "Checkbox 2", 111, 17, 107, 61, 12, style5%
CheckBox "AutoCheckbox", 112, 17, 120, 61, 12, _
style5%
EditText "", 113, 89, 94, 59, 12, style6%
EditText "", 114, 89, 107, 59, 12, style6%
EditText "", 115, 89, 120, 59, 12, style6%
ListBox "", 116, 154, 16, 64, 113, style7%
EndDialog
// Fill List- and Combobox
For i% = 1 To 50
s% = LB_ADDSTRING
v% = Rand(100)
~SendMessage(DlgItem(1, 116), s%, 0, Str$(v%, 2) _
+ ".String")
s% = CB_ADDSTRING
v% = Rand(500)
~SendMessage(DlgItem(1, 117), s%, 0, Str$(v%, 4) _
+ ".String")
Next i%
// Init Scrollbars
~SetScrollRange(DlgItem(1, 104), SB_CTL, 0, 200, 1)
~SetScrollPos(DlgItem(1, 104), SB_CTL, 100, 1)
~SetScrollRange(DlgItem(1, 105), SB_CTL, 0, 200, 1)
~SetScrollPos(DlgItem(1, 105), SB_CTL, 100, 1)
ShowDialog # 1
EndProc
Note - GFA-BASIC 32 also provides keywords like ProgressBar, Toolbar, Header, etc. These keywords are not statements to create controls, but they are OCX types. As such these keywords are used to declare variables or to create OCX controls. For instance:
Dim pb1 As ProgressBar ' declare a variable pb
Ocx ProgressBar pb1 ' create OCX & declare global variable pb1
Note - The Dialog command is useful for converting GFA-BASIC 16 programs and in GLL extensions. In a normal program use Form instead.
OCX types are not allowed in a GLL.
ShowDialog, CloseDialog, PushButton, DefPushButton, EditText, CText, RText, LText, Static, ScrollBar, ComboBox, ListBox
{Created by Sjouke Hamstra; Last updated: 11/08/2022 by James Gaite; Other Contributors: Jean-Marie Melanson}