FORM Objects + PROPERTIES
Updated: Jan 29, 2011

PROPERTIES Comments (RW numeric or string values):
~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BMP        Loads and draws .bmp resource on BUTTON, IMAGE, TOOLBAR or
           TREEVIEW

           $RESOURCE groovy As "groovy.bmp"
           MyImage.BMP = "groovy"  'String argument is a resource name

           Gets handle of the .bmp resource.  hBMP = MyImage.BMP

           See HBimages.inc for constants for internal Windows bitmaps. 

Caption    Set/get object text; same as .Text
           For FORM, sets application title bar text (default = program name)

           MyObject.Caption = "Bigger than ever":  MyString = MyObject.Caption

Cell       Assigns text to GRID cell.  MyGrid.Cell(i,j) = string
           where i and j are 0-based row and column indeces. 
           Please see .InsertCol and .InsertRow  

           MyGrid.Cell(2,3) = "HotBabe Budget"

           Get text in GRID cell.  MyString = MyGrid.Cell(i,j)
           where i and j are 0-based row and column indeces. 
           Please see .InsertCol and .InsertRow  

           MyString = MyGrid.Cell(2,3)

           Strings from .Cell presently are limited to 4096 characters.
           The author is not sure what limit, if any, Windows supports.

Checked    Set/get checked state [BUTTON CHECKBOX RADIOBUTTON]

Class      Class name string.  MyClass = MyObject.Class

           MyObject.Class = "SysDateTimePick32"

Color      Set/get background color by RGB value 0 - &HFFFFFF

           MyForm.Color = &HDDDDFF: MyGauge.Color = &HFF0000

           The RGB numeric function may be used to create the source value.
           FORM .Color sets the class background and affects all forms.  
           For EDIT, CHECKBOX, RADIOBUTTON, GROUPBOX, SCROLLBAR, IMAGE, LABEL
           and PANEL, .Color sets background color only when the parent is
           FORM or SPLASH.  Do not use .Color for BUTTON which uses Windows
           system colors instead.

           RGBColor = MyObject.Color

ColWidth   For GRID and HEADER, changes column width from initial value.

           MyGrid.ColWidth(n) = 50  'n is 0-based column index 

           For GRID and HEADER, gets column width.  Default = 60.

           cWidth = MyGrid.ColWidth(n)  'n is 0-based column index 

Cursor     Sets cursor.  MyObject.Cursor = handle_cursor.  handle_cursor may
           by a $RESOURCE or one of the Windows internal cursors.

           See HBimages.inc for constants for internal Windows cursors. 

           Gets present class cursor handle.  hCursor = MyObject.Cursor

Enabled    Enables user input with mouse or keyboard to object

           MyObject.Enabled = 0  'now the component is grayed out

           Gets .Enabled state.  MyVar = MyObject.Enabled

ExStyle    Set/get Extended Style.  MyExStyle = MyObject.ExStyle

           Assigns or changes Extended Style

           For FORM, default = &H10000

           MyObject.ExStyle = MyExStyle 'DWORD ExStyle flags

           If .ExStyle change seems to be ignored, see .Recreate method.

           Please see HBguidef.inc in your "inc" directory for detailed listings.

Font       Set font for object text.  MyObject.Font = MyFont

           Get font handle.  hFont = MyObject.Font

Height     Set/get object height.  If set for IMAGE, IMAGE may be resized.

Icon       Loads and draws .ico resource on BUTTON or IMAGE

           $RESOURCE hotbabe As "hotbabe.ico"
           MyButton.Icon = "hotbabe"  'String argument is a resource name

           Note: Microsoft Windows internal icon constants may be used:

           MyButton.Icon = 32515  'IDI_EXCLAMATION

           See HBimages.inc for constants for internal Windows icons.

           In contrast, for FORM or SPLASH, .Icon specifies application icon
           file:

           MyForm.Icon = "MyApp.ico"  'icon file becomes a resource

           Gets handle of icon resource.  hIcon = MyImage.Icon

ItemIndex  Set/get selected item.
           [COMBOBOX FILELISTBOX LISTBOX RICHEDIT RICHEDIT2 TABCONTROL
            TREEVIEW (set only)]

           MyListBox.ItemIndex = 5

           For TREEVIEW, the handle of an item is used as the index value.
           For the RICHEDIT's, .ItemIndex = integer sets cursor to line.

           Gets 0-based index of selected item else -1

           MySelected = MyListBox.ItemIndex
           CurrentLine = MyRichEdit.ItemIndex + one

Left       Set/get object left position

Menu       FORM menu handle.  hMenu = MyForm.Menu

           MyForm.Menu  'use application menu in MyForm           

Modified   Set/get modified state. [EDIT RICHEDIT RICHEDIT2]

           MyVar = MyEdit.Modified

           MyEdit.Modified = true 'or false

Parent     Set/get handle of .Parent to object.  MyObject.Parent = MyObject

           Set automatically with steps 1 to 5 in the introduction above.

           To define child-of-child objects, assign the .Parent property.

           MyChild.Parent = MyParent

           If the .Parent of an additional FORM is set to the main FORM, the
           user can move the child FORM anywhere in the parent FORM.  Therefore,
           if a .Parent of a FORM must be assigned, better results may be
           obtained if the parent is a PANEL or some other child window of the
           main FORM. 

           hParent = MyObject.Parent

Pixel      Sets pixel x, y; same as Pset.  MyObject.Pixel(x, y)=rgb_color

           Gets RGB color of pixel x, y.  rgb_color = MyObject.Pixel(x, y)

           May be used in an .OnPaint routine where Device Context is
           automatically defined, or within .GetDC / .ReleaseDC or
           .BeginPaint / .EndPaint code blocks.

Position   Set/get position within working .Range
           [GAUGE SCROLLBAR TRACKBAR UPDOWN]

           MyGauge.Position = Percent 'where Percent is an integer

           CurrentPosition = MyGuage.Position

SelEnd     Set/get selected text end [EDIT RICHEDIT RICHEDIT2]

           MyEdit.SelEnd = EndPosition  '0-based position
           EndPosition = MyEdit.SelEnd  '.SelStart + .SelLength

SelLength  Set/get selected text length [EDIT RICHEDIT RICHEDIT2]

           MyEdit.SelLength = LengthSelected  '1-based length
           LengthSelected = MyEdit.SelLength  '.SelEnd - .SelStart

SelStart   Set/get selected text start [EDIT RICHEDIT RICHEDIT2]

           MyEdit.SelStart = StartPosition  '0-based position
           StartPosition = MyEdit.SelStart

SelText    Set/get selected text [EDIT RICHEDIT RICHEDIT2]

           If no text is selected, then .SelText inserts text:

           MyRichEdit.SelText = "insert this at cursor"

           If text is selected, then .SelText replaces the selection:

           MyRichEdit.SelText = "replace selected text with this"

           For RICHEDIT2 only,

           Text$ = MyRichEdit2.SelText  'get selected text

Style      Set/get Style.  For FORM, default = &HCF0000

           MyObject.Style = MyStyle 'DWORD Style flags

           MyObject.Style = MyObject.Style OR &H100  'set style bit
           MyObject.Style = MyObject.Style XOR &H100 'clear style bit

           If .Style change seems to be ignored, see .Recreate method.

           Please see HBguidef.inc in your "inc" directory for detailed listings.

Tag        Set/get arbitrary value associated with object.  MyEdit.Tag = 12

Text       Set/get object text; same as .Caption.

           PreviousText = MyObject.Text: MyObject.Text = "Better than ever"

TextColor  Set/get RGB color of text.
           [CHECKBOX EDIT FILELISTBOX GRID GROUPBOX LABEL LISTBOX PANEL
            RADIOBUTTON RICHEDIT RICHEDIT2 TREEVIEW]

           MyGrid.TextColor = &H0000FF 'red

           Except for GRID, RICHEDIT2 and TREEVIEW, .TextColor is displayed
           if .Color is defined.

           RGBColor = MyObject.TextColor

           For RICHEDIT2 .TextColor, if the object is empty, new typed text
           is colored.  If you load text, then use .TextColor to set the
           color of all text in the RICHEDIT2.

TextLimit  Limit of text length [COMBOBOX EDIT RICHEDIT RICHEDIT2]

           MyRichEdit2.TextLimit = 5000000  'edit file up to 5 megs!
           The maximum for RICHEDIT appears to be about 64k.

           CurrentLimit = MyEdit.TextLimit

Top        Set/get object top position

Visible    Displays or hides object (default = 1)

           MyObject.Visible = 0  'now we hide MyObject

           Gets .Visible state.  MyVar = MyObject.Visible

Width      Set/get object width.  If set for IMAGE, IMAGE may be resized.   


Read only properties are similer to string and numeric functions.

PROPERTIES (Read Only String):
~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
Item       Item text
           [COMBOBOX FILELISTBOX HEADER LISTBOX RICHEDIT RICHEDIT2 TABCONTROL
            TOOLBAR TREEVIEW]

           MyString = MyListBox.Item(index)
           where index = 0 to MyListBox.ItemCount - 1


PROPERTIES (Read Only Numeric):
~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
At present, all numeric values are returned as LONG, signed integers.
For certain values, like .Style, conversion to DWORD may better display flags.

BeginPaint Get DC (device context) handle for FORM and SPLASH drawing/painting.

           MyDC = MyObject.BeginPaint

           .BeginPaint should not be used in .OnPaint procedures.

ClientHeight Client area height.  cHeight = MyForm.ClientHeight

           .ClientHeight = Form height - border - title - menu (if any).

ClientWidth Client area width.  cWidth = MyForm.ClientWidth

FindText   Finds text in current selection, returning 0-based character
           position of found text or -1 (not found).  [RICHEDIT2]

           MyVar = MyRE2.FindText(text_string, mode_integer)

           where mode_integer is an OR of one or more search constants:
           FT_UP 0; FT_DOWN 1; FT_WHOLEWORD 2; and FT_MATCHCASE 4

           Typical FindText code would use .SelStart and .SelEnd to 
           select the RICHEDIT2 text to be searched, and then use
           .FindText to find the first instance of the text_string
           in the selected text, if any, and its character position.

Focus      Focus. MyVar = MyObject.Focus  'true (1) if MyObject has focus.

GetDC      DC handle.  hDC = MyObject.GetDC

           Must be followed after drawing methods by .ReleaseDC.
           Often used in main program code, but not in .OnPaint procedures.

           MyDC = MyObject.GetDC
           'draw/paint code
           MyObject.ReleaseDC  'always follows .GetDC

Handle     Object handle
           If no property is stated, .handle is assumed:

           MyForm.Font = MyFont      'for MyFont.Handle
           MyObject.Parent = MyForm  'for MyForm.Handle

           hObject = MyObject.Handle

ID         Object ID assigned internally at object creation

IndexOf    Index of MyString [COMBOBOX FILELISTBOX LISTBOX]

           MyLong = MyListBox.IndexOf(MyString)
           Similar to .IndexOf function in LIST object.
           MyLong = -1 if MyString has no exact match in MyListBox

ItemCount  Item count
           [COMBOBOX GRID FILELISTBOX HEADER LISTBOX RICHEDIT RICHEDIT2
            TABCONTROL TOOLBAR TREEVIEW]

           MyCount = MyListBox.ItemCount

Length     Length of object text (if referenced without an index)

           MyLen = RICHEDIT.Length

LineCount  Same as .ItemCount

MouseX     Mouse x position in object rectangle; MyLong = MyForm.MouseX

MouseY     Mouse y position in object rectangle; MyLong = MyForm.MouseY

SelCount   Number of selected items [FILELISTBOX LISTBOX]

Selected   True (not zero) if item selected
           [FILELISTBOX LISTBOX TOOLBAR TREEVIEW]

           IsSelected = MyListBox.Selected(index)
           where index = 0 to MyListBox.ItemCount - 1

Status     FORM StatusBar handle.  hStatusBar = MyForm.Status

TextHeight Height in pixels of text string argument.

           MyHeight = MyForm.TextHeight(MyString$)

TextWidth  Width in pixels of text string argument.

           MyWidth = MyForm.TextWidth(MyString$)

           .TextWidth and .TextHeight work only when a device context
           is defined -- in all .OnPaint procedures and in
           .BeginPaint/.EndPaint or .GetDC/.ReleaseDC code blocks.


###########
Please see example code in downloads such as HotWin, HotToys, HotDialog,
HotFind and HotDraw.


+ Penthouse (registered) version

Copyright 2003-2011 James J Keene PhD
Original Publication: Nov 18, 2003
