FORM Objects + INTRODUCTION Updated: Nov 7, 2005 As other features of HotBasic, the collection of GUI FORM objects is designed to allow the coder complete freedom to do whatever Microsoft Windows can do with respect to all of these marvelous visual components. FORM objects, also called "windows" or "controls", presently include: FORM, BUTTON, CANVAS, CHECKBOX, COMBOBOX, DATETIME, EDIT, FILELISTBOX, GAUGE, GRID, GROUPBOX, HEADER, IMAGE, LABEL, LISTBOX, LISTVIEW, PANEL, RADIOBUTTON, RICHEDIT, RICHEDIT2, SCROLLBAR, SPLASH, STATUSBAR, TABCONTROL, TOOLBAR, TRACKBAR, TREEVIEW, UPDOWN RICHEDIT is a multi-line edit control and RICHEDIT2 uses riched20.dll GRID is a report-style ListView which can display a table of strings. SPLASH is an alternate FORM object, which may be used as a drawing surface instead of FORM or as a child of a FORM. If you use SPLASH only, define one or more event routines to close the program (see splash.bas). Related GUI objects are described in the BITMAP, DIALOGS, FONT, MENU and other help files. The read-only MOUSE object gets cursor position (MOUSE.X and MOUSE.Y). The read-write RECT object may be used to hold rectangle data and may be used as arguments in API calls such as the .CopyRect method. The WINDOW(handle).property/method statement or function can do FORM object operations "by handle". SBpanels.inc in the HotInclude download creates STATUSBAR panels. TabStop.inc shows how to navigate the form with the tab key. General GUI coding: (1) Dimension a FORM; e.g., DIM Form As FORM (2) Define properties of your FORM (3) Dimension components of your FORM and their properties. HotBasic automatically sets all components as child windows of your FORM (or the last-dimensioned FORM). (4) For any of these objects, the .OnClick event may be defined to launch subroutines. These subroutines have no defined arguments, but can access the hWnd, uMsg, wParam and lParam associated with their call. (5) Optionally, Dimension another FORM repeating steps 1 - 4 above. CREATE-style form definition code is supported (Statemenst > Dimension). v4.1g adds a simple auto-size and auto-position feature for BUTTON, CHECKBOX, EDIT, LABEL and RADIOBUTTON. For each form, the above objects are created with width=90, height=20, left=10 and start at top=10, incrementing top by 30 for each object added. If any of these values are desired for the above object types, you save a bit of time and shorten your .exe because you do not have to explicitly define them. You can change these values as usual, of course. A GROUPBOX, LABEL (with no text) or PANEL may be set as the "parent" of "child" objects located within it. Properties such as .Enabled and .Visible should affect all child objects in GROUPBOX, LABEL or PANEL containers. For these child-of-child objects, the .OnMouseDown event may be used for mouse input. CANVAS is a "static class" window object with the "owner draw" style, which is a sweet way to say that the programmer uses HotBasic drawing methods or other APIs to paint what it shows. Please see example in hotdraw.bas. Drawing methods (Circle, CopyRect, Draw, Ellipse, etc) apply to FORM, BITMAP and PRINTER objects. To keep the application and the OS in agreement on what should be displayed, FORM object drawing is done in an .OnPaint routine. Internal variable hbDC contains the device context. BITMAP objects may provide source images for .CopyRect and .Draw. A BITMAP image itself is not drawn in an .OnPaint procedure, to avoid changing the device context from that of the object associated with the procedure. Drawing methods are known to work "out of the box" for both the FORM and CANVAS objects. For use on other FORM objects, the WS_OWNERDRAW .Style bit may have to be set, which may also require the .Destroy/.Recreate methods. Numeric Functions useful in GUI applications include MESSAGEBOX, POSTMESSAGE and SENDMESSAGE. Statements useful in GUI applications include DOEVENTS, FREECONSOLE, POPUP, SHOWCONSOLE, SHOWMESSAGE and WINDOW. ########### Please see example code in downloads such as HotWin, HotToys, HotDialog, HotFind and HotDraw. + Penthouse (registered) version Copyright 2003-2005 James J Keene PhD Original Publication: Nov 18, 2003