Creating Controls


Controls are created in a similar way as is done in Win32lib :

constant CONTROLNAME = create(objType, label, hBitmap, pID, x, y, width, height, styleflags)
      -- CONTROLNAME now has the ID of the new control

1) objType - This is an integer designating what sort of control will be created. The TYPE column in the following table lists the ones that can be used. Click on the link in the CLASS column (or the matching link in the navigation panel) for more specific control information, ideally after you have digested all the generic details for parameters 2..9, which of course can be found below the big main objType table currently filling up most of the screen.

CLASS TYPE
Windows Window
Buttons Button, PictureButton, ToggleButton, TogglePictureButton
MarkBoxes RadioButton, CheckBox, TriCheckBox
Group boxes Group
Editable controls EditText, MultiEditText
Labels Label
Tool bars ToolBar, ToolSep
Status bars StatusBar, StatusField
Scroll bars HScroll, VScroll
Track bars HTrackBar, VTrackBar
Progress bars ProgressBar
Menus Menu, MenuItem
List boxes Listbox, ComboBox, ComboDropDownList, ComboDropDown
Tab controls TabControl, TabItem
HyperText controls HyperText

2) label - This parameter holds the text string (if any) to be associated with the control/object. If no string is needed a 0 can be used and will be treated as if an empty string had been specified.

3) hBitmap - This parameter holds the handle of a bitmap that the user wishes to associate with the control/object. If no bitmap handle is to be used then please ensure that a NULL (or 0) is used.

4) pID - This is the ID of the parent control. Only a top-level Window or an un-owned Menu can have no parent, in which case this parameter would be 0.

5) x - This integer indicates the position of the control from the left boundary of it's parent. Toolbar buttons treat this parameter differently, see below for details

6) y - Position of control from the top boundary of it's parent

7) width - Gross width of the control

8) height - Gross height of the control

9) styleflags - Style flags used at the creation of the control. There are 2 kinds of style: Standard style & Extended style. If this parameter is a single atom then ARWEN will assume it holds flags for the Standard style. If this parameter is a sequence it must hold 2 elements only. The first element will be treated as the flags for the Standard style and the second element will be treated as flags for the Extended style. The sorts of flags that can be used for a particular control type vary greatly. Please consult the Win32 API for details. Each element may be composed of a number of individual flags (atoms). ARWEN will ensure the flags are all ORed together to combine into an atom, eg:

        wStyle = {WS_HSCROLL, WS_VSCROLL}
        wStyleEx = {WS_EX_CLIENTEDGE, WS_EX_CONTEXTHELP}

If any flags for the Extended styles are used they must not be combined with the Standard style flags but must reside in the correct atom. Please note that default Standard style flags have already been prepared for many controls. These may be seen in the classes.ew file. The flags supplied by the user at the creation of the control are combined with the existing default style flags; they do not replace them. If you wish to have a different set of default style flags for a control then you can alter the defaults by calling setClassDefaults() and supplying your own flags. Beware that this operation must occur BEFORE the control is created and that the new default style flags will be used during the creation of proceeding controls of the same type. This function returns the previous style flag values. The default styles for a control class may be restored by calling resetClassDefaults(),eg:

        MAINWINDOW = create(Window, "Main Win", 0, 0, 0, 0, 800, 600, 0) -- Normal window is created
        oldstyles = setClassDefaults( Window, wStyle, wStyleEx ) -- flag values as above
        -- Each Window created will have Scroll bars & Context help
        AWINDOW1 = (Window, "A Win1", 0, MAINWINDOW, 10,10, 400, 300, 0)
        AWINDOW2 = ...
        AWINDOW3 = ...
        -- The original style flags for the Window class will now be restored
        void = resetClassDefaults( Window )
        AWINDOW4 = create(Window, "A Win4", 0, MAINWINDOW, 10,10, 400, 300, 0) -- Normal window is created