The following list shows the 22 controls for which PowerBASIC provides special support.
Button | Frame | ImgButton | ListBox | StatusBar |
---|---|---|---|---|
Check3State | Graphic | ImgButtonX | ListView | TAB |
Checkbox | Image | Label | Option | TextBox |
ComboBox | ImageX | Line | Progress Bar | Toolbar |
Scrollbar | TreeView |
Some PowerBASIC controls are actually derivations of the Windows Common Controls, so if you review the MSDN documentation you won't find every PowerBASIC control listed. Here's a list which maps derived PowerBASIC controls to the corresponding Windows common control.
Common Control | PowerBASIC Control |
---|---|
edit control | textbox |
static control | graphic, image, imagex, label, line |
button control | button, check3state, checkbox, frame, imgbutton, imgbuttonx, option |
In the following table, use the corresponding Windows common control data to get style/exstyle values for a PowerBASIC control.
Control Categories
The following categorized list of the supported controls will help understand the basic capabilities of the available controls.
|
Label, TextBox |
| Button, Check3State, CheckBox, Option Button, Progress Bar, Statusbar |
| ComboBox, ListBox |
| ListView, TreeView, Toolbar |
| Graphic, Image, ImageX, ImgButton, ImgButtonX |
| Frame, Tab |
Source code for creating each of these controls is discussed below. More detailed examples are provided on each of the specific control pages.
PowerBASIC CONTROL Statements
The various CONTROL statements, which include CONTROL ADD, provide most
of the functions needed to create and manage child controls. As will be
discussed below, there are also control-specific statements which supplement
the CONTROL statements.
The starting point for creating controls and placing them on a dialog is is the CONTROL ADD statement. It defines the basic size/location and visual look of a control.
Other CONTROL statements are available to further manage controls, such as getting or setting control properties, as well as deleting or disabling the controls.
Here is a summary of all available CONTROL statements and a short description of the capabilities they provide.
one for each of 22 control types
| disables a specific control
| enables a specific control
| 6 versions (CHECK, CLIENT, LOC, SIZE, TEXT, USER)
| returns Windows handle of control
| remove child from dialog
| place message in queue
| redraw a control
| send message to control
| 14 versions (CHECK, CLIENT, LOC SIZE, TEXT, USER, ...)
| set visible state
| |
Note that there are several versions of the CONTROL GET and CONTROL SET, corresponding the 20 different control properties they can access or set.
In addition to CONTROL statements, PowerBASIC provides statements that are specific to eight of the controls (ComboBox, ImageList, ListView, ProgressBar, Scrollbar, Statusbar, Toolbar, and TreeView). The control-specific statements are discussed on the individual control pages.
Finally, there are other PowerBASIC statements, such as FONT NEW, which can be used to modify how a control looks or behaves. These too are covered in the individual control pages.
CONTROL ADD Statements
The CONTROL ADD statement is used to create all controls. Fortunately, the
syntax is the same for all of the controls, with only a few differences for
controls which use images or which display lists.
Here's the syntax for the CONTROL ADD statement, along with a few specific examples.
Syntax: CONTROL ADD BUTTON, hDlg,id&,text$,x,y,xx,yy,style&,exstyle& CALL callback Examples: CONTROL ADD BUTTON, hDlg, 500&, "OK", 100,100,300,300 CONTROL ADD CHECKBOX, hDlg, 501&, "Vote", 100,100, 300,300 CONTROL ADD LABEL, hDlg, 502&, "Title", 100,100,300,300
The above examples demonstrate the minimum code needed to create a control - the handle of the parent dialog, a control ID, text content, upper/left coordinates and width/height.
And here is a description of each of the arguments.
parent dialog handle
| programmer assigned ID
| control text OR resource file image name
| upper left x coordinate
| upper left y coordinate
| width of control
| height of control
| primary style (optional)
| extended style (optional)
| named callback function (optional)
| |
The style&, exstyle& and CALL arguments are optional. The default values used when style&/exstyle& are omitted are listed further down this page, as is a full list of the style&/exstyle& values each control can use.
CONTROL ADD Notes
While the syntax above applies to all controls, there are some slight
variations on the content of the arguments, depending on the control
involved.
CONTROL Statements
In addition to the CONTROL ADD statement there are another 28 CONTROL statements
that manage controls once they are created. A simple one-line description
of each is provided below, followed by the syntax for using the statement.
CONTROL DISABLE disable
hDlg, id&
CONTROL ENABLE enable
hDlg, id&
CONTROL GET CHECK check state
hDlg, id& TO iResult1&
CONTROL GET CLIENT top/left location
hDlg, id& TO wide&, high&
CONTROL GET LOC top/left location
hDlg, id& TO x&, y&
CONTROL GET SIZE width/height
hDlg, id& TO width&, height&
CONTROL GET TEXT text
hDlg, id& TO txt$
CONTROL GET USER get user data
hDlg, id&, index& TO retvar&
CONTROL HANDLE window handle for control id
hDlg, id& TO hCtl&
CONTROL KILL remove control
hDlg, id&
CONTROL POST put message in queue (non-blocking)
hDlg, id&, Msg&, wParam&, lParam&
CONTROL REDRAW schedule redraw of control
hDlg, id&
CONTROL SEND send message to control, wait for processing
hDlg, id&, Msg&, wParam&, lParam& TO iResult2&
CONTROL SET CHECK set check for 3state or checkbox
hDlg, id&, checkstate&
CONTROL SET CLIENT change client size
hDlg, id&, wide&, high&
CONTROL SET COLOR set fg/bg color
hDlg, id&, fgcolor&, bgcolor&
CONTROL SET FOCUS set focus
hDlg, id&
CONTROL SET FONT select font for a control
hDlg, id&, fonthandle&
CONTROL SET LOC relocate control within dialog
hDlg, id&, x&, y&
CONTROL SET OPTION set check state of option control
hDlg, id&, minid&, maxid&
CONTROL SET SIZE change control size
hDlg, id&, width&, height&
CONTROL SET TEXT change control text
hDlg, id&, text$
CONTROL SET USER set user data
hDlg, id&, index&, uservalue&
CONTROL SHOW STATE toggle visibility
hDlg, id&, showstate& TO iResult3&
And here is a description of the arguments for the CONTROL statements listed above. For each of the arguments, the CONTROL statements that apply are also listed.
background color(SET COLOR, SET COLOR)
| check state (SET CHECK)
| foreground color (SET CHECK, SET COLOR)
| font handle returned by FONT NEW (SET FONT)
| Window-assigned handle (HANDLE)
| parent dialog handle (ALL)
| width of control (GET SIZE, SET SIZE)
| width of client area (GET CLIENT, SET CLIENT)
| programmer assigned control ID (ALL)
| index number of 8 user values (GET USER, SET USER)
| 2nd msg$ parameter, message-dependent content (POST/SEND)
| 0-unchecked, 1-checked, 2-grayed (GET CHECK)
| SEND - return value from a msg$ (SEND)
| 0-was invisible, non-zero if was visible (SHOW STATE)
| top end of range to unset (SET OPTION)
| low end of range to unset (SET OPTION)
| message (POST/SEND)
| image name (Image, ImageX, ImgButton, ImgButtonX)
| visible state (SHOW STATE)
| text from edit portion of the control (SET TEXT)
| value of selected user value (SET USER)
| width of client area (GET CLIENT, SET CLIENT)
| width of contol (GET SIZE, SET SIZE)
| 1st msg$ parameter, message-dependent content (POST/SEND)
| top/left horizontal position (SET LOC)
| top/left vertical position (SET LOC)
| |
Default Style& and ExStyle& Values
The style& and exstyle& arguments define the way a control looks,
allowing the programmer a means of adjusting the controls visible
features as needed in an application. Use of style& and exstyle&
is optional on all controls. If not specified, the following default
values are used by PowerBASIC.
Control | Default Style& | Default ExStyle& |
---|---|---|
BUTTON |
%BS_CENTER %BS_VCENTER %WS_TABSTOP |
%WS_EX_LEFT |
CHECK3STATE |
%BS_LEFT %BS_VCENTER %WS_TABSTOP | %WS_EX_LEFT |
CHECKBOX |
%BS_LEFT %BS_VCENTER %WS_TABSTOP | %WS_EX_LEFT |
COMBOBOX |
%CBS_DROPDOWN %CBS_SORT %WS_TABSTOP |
%WS_EX_LEFT %WS_EX_CLIENTEDGE |
FRAME |
%BS_LEFT %BS_TOP | %WS_EX_LEFT |
GRAPHIC |
%WS_CHILD %WS_VISIBLE %SS_OWNERDRAW | -no default- |
IMAGE | -no default- | %WS_EX_LEFT |
IMAGEX | -no default- |
%WS_EX_LEFT |
IMGBUTTON | %WS_TABSTOP |
%WS_EX_LEFT |
IMGBUTTONX | %WS_TABSTOP |
%WS_EX_LEFT |
LABEL | %SS_LEFT | %WS_EX_LEFT |
LINE | %SS_ETCHEDFRAME | %WS_EX_LEFT |
LISTBOX |
%LBS_SORT %LBS_NOTIFY %WS_TABSTOP %WS_VSCROLL |
%WS_EX_LEFT %WS_EX_CLIENTEDGE |
LISTVIEW |
%WS_TABSTOP %LVS_REPORT %LVS_SHOWSELAWAYS | %WS_EX_LEFT |
OPTION |
%WS_TABSTOP %BS_LEFT %BS_VCENTERv | %WS_EX_LEFT |
PROGRESSBAR | %WS_BORDER | -no default- |
SCROLLBAR | %SBS_HORZ | %WS_EX_LEFT |
STATUSBAR | %CCS_BOTTOM | -no default- |
TAB |
%WS_CHILD %WS_TABSTOP | -no default- |
TEXTBOX |
%WS_TABSTOP %WS_BORDER %ES_LEFT %ES_AUTOHSCROLL |
%WS_EX_CLIENTEDGE %WS_EX_LEFT |
TOOLBAR |
%WS_CHILD %WS_VISIBLE %WS_BORDER %CCS_TOP %TBSTYLE_FLAT | -no default- |
TREEVIEW |
%WS_TABSTOP %TVS_HASBUTTONS %TVS_HASLINESATROOT %TVS_HASLINES %TVS_SHOWSELALWAYS | %WS_EX_LEFT |
Managing Controls - Style, ExStyle
Style and extended style values determine the visual
look of a control. Microsoft documents the allowed
values at its MSDN site.
I've pulled the information for the controls supported by PowerBASIC to create the following list of style and extended values for each control.
As noted earlier, some of the PowerBASIC controls are derivations of the Windows common controls. So, in the following table, use the corresponding Windows common control data to get style/exstyle values for a PowerBASIC control.
If you have any suggestions or corrections, please let me know.