Title: An Introduction to Controls
1An Introduction to Controls
- Rainer Becker
- dFPUG / ISYS GmbH
- Germany
2About the Speaker
- German FoxPro User Group
- ISYS GmbH
- MS Solution Provider
- MS Consulting Services
- Adress Rainer Becker, Messerschmittstr. 2a,
- 65760 Eschborn, Germany
- Phone 01149-6173-68182, Fax -65997
- CompuServe 100024,1364 / GO MSCESYS
3Whats included
- Short Introduction to principles of
- Properties/Events/Methods
- Guided Tour through all Controls
- - walking all properties upstairs
- Some words about
- Containers, Naming, Builders
4Whats excluded
- Form Designer
- Class Designer
- Grid-Control
- OLE-Controls
- (but you might get a good base for all of that)
- Classes
- Inheritance
- Non-Visual Objects
- Event-Model
5Form Designer
Toolbars
- Properties
- Data
- Method
- Layout
- Other
6Vocabulary
- What are Properties ?
- What are Methods ?
- What are Events ?
- How to avoid confusion?
- How to reference objects ?
7What are PROPERTIES?
- Think of them as bound variables
- Public vars with a private path
- Example COMMENT, HEIGHT
- Add your own!
- Later on you will need them - especially
- for non-visual objects or even applications
8What are METHODS?
- Think of them as old-style snippets
- Procedures bound to Controls/Forms
- Example Refresh, SetFocus
- Add your own!
- You will sometimes need them
- - but building your own is real fun!
9What are EVENTS?
- Think of them as old-style snippets
- Procedures bound to Windows-Events
- Example old-fashioned VALID, CLICK
- You can not extend!
- Events are methods bound to OS/VFP/USER
- You normally need only some of them
- - but it is great that there are so many!
10Avoid Confusion
- Events and Methods have a Procedure
- Events could be seen as an Event Method
- Some Properties are followed by actions
- These Categories are not closed boxes
- There are many - but most are easy to use!
- Obey Graphical hints
- Bold changed, Italic read-only
- Use RESET TO DEFAULT (right mouse button)
11Syntax
- objectvariable.form.control.property Setting
- THIS.
- THISFORM.
- THISFORMSET.
- _SCREEN.
- WITH.. ..ENDWITH, COUNT / PAGES
- ACTIVEFORM.
- ACTIVEPAGE.
- ACTIVECONTROL.
- PARENT.
12Controls - A Guided Tour
- Timers
- Lines
- Shapes
- Images
- Labels
- Command Buttons
- Option Buttons
- Check Boxes
- Text Boxes
- Edit Boxes
- Spinners
- Combo Boxes
- List Boxes
- Option Groups
- Command Groups
- Page Frames
- Grids
- OLE-Controls
13Not all of them are new! Renamed
Controls
- Text gt Label control
- GET-Field gt Text box
- Edit Region gt Edit box
- Popup gt Combo box
- Radio button gt Optionb.
- Push button gt Command
- Screen(Set) gt Form (Set)
- Picture gt Image
- Really new are
- Timers
- Page
- Grid
- OCX
- Nearly all are enhanced!
14Lets start with a new but small one
Timers
- Data
- Methods
- Layout
- Other
- Tips
Comment, Tag BASIC, TimerEvent,
Reset COORDINATES CLASS, Interval - Not executed
while Menu open - Not exact enough for RealTime
15Timer Basic Data/Layout
- Timer (one of each)
- TimerEvent Procedure called at Event
- ResetMethod Restart timer
- IntervalProp. Timer in milliseconds
- Data
- Comment You should use it!
- Tag Free property
- Layout
- Top, Left, Heigth, Width
16Basic Other
- Other
- Name Naming conventions
- Enabled logical Flag
- Class Objects belong to classes
- ClassLibrary optional VCX of the class
- Baseclass Base class derived from
- Parentclass optional derived from
- Parent runtime container object
17Basic Events/Methods
- Events
- Init Object initialised
- Destroy Object removed
- Error local error-handler
- Methods
- CloneObject runtime duplication
- SaveAsClass objects from VCX to VCX
- Read/WriteExpression/Method at design time
18Lines
- Data
- Events
- Methods
- Layout
- Other
- Tips
--- CLICK, MOUSE, DRAG Drag, Move, UIEnable,
ZOrder DragIcon/Mode, BORDER,Draw- Mode,
MousePointer, LineSlant HelpContextID - No
3D-line-effects
19Click Mouse EventsVisible Objects
- Click
- Click Mouse left click
- DblClick Mouse double click
- RightClick Mouse right click
- Mouse
- MouseMove Mouse over object
- MouseDown Mouse pressed for click
- MouseUp Mouse released
- MousePointer 12 pointer versions
20Drag Drop Visible Objects
- Drag
- DragDrop End of drag, target event
- DragOver object over target, target event
- Methods
- Drag Method for manual dragging
- Move Method for manual moving
- Properties
- DragIcon Cursor Icon for drag
- DragMode automatic / manual
21Properties Visible Objects
- Bordercolor, -style, -width for border
- Visible Temporary hide object
- HelpContextID for HelpCompiler
- ZOrder Meth. active Page, tlb order
- UIEnable Evt. Page activate event
- Drawmode 16 different modes
- (Line/Shape/Form)
- LineSlant special line property
22Shapes
--- --- BackColor/Style, FillColor/Style, ColorSch
eme/Source, ToolTip SpecialEffect,
Curvature --- - Shapes in front block the click
event
- Data
- Methods
- Layout
- Other
- Tips
23Properties Plain Objects
- Colors
- BackStyle Transparent / Opaque (Default)
- BackColor RGB-Color for Qpaque objects
- FillColorStyle Transparent, Solid, Lines
- FillColor RGB-Color if not transparent
- ColorScheme Object/Form/Source/Default
- ColorSource Scheme for AboveSource
- ToolTipText ToolTip if Form.ShowTips.T.
- SpecialEffect Plain or 3D
- Curvature 0rectangle - 99circle
24Images
- Data
- Methods
- Layout
- Other
- Tips
--- --- Picture (Bitmap, Icon) Stretch
(Clip/Isometric/Stretch) --- - Stretch also used
for OLE
25Labels
- Data
- Methods
- Layout
- Other
- Tips
--- --- Caption, FONT, COLOR AutoSize, WordWrap,
Alignment --- - The Caption can be a function
26Layout PropertiesObjects with Caption
- FontName FontSize
- FontFlags FontBold, FontItalic,
FontStrikeThru, - FontOutline,
FontUnderline, FontShadow - Color DisabledBackColor,
(Disabled)ForeColor - Caption Text to be shown (function)
- Alignment Left/Right/Centered
- AutoSize Resize horiz. for text
- WordWrap Wrap words/resize vertical
27Command Buttons
- Data
- Methods
- Layout
- Other
- Tips
TerminateRead ErrorMessage, see
EVENTS DownPicture, DisabledPicture StatusBarText,
(StyleInv.) TabIndex, TabStop (Forms!)
Default, Cancel (not \! or \? ) - Use small
fonts with pictures - Use StatusBarText instead
28Eventsfor accessible objects
- When old-fashioned WHEN
- Valid old-fashioned VALID
- GotFocus Tabbed to it
- LostFocus Tabbed somewhere else...
- SetFocus Method (enabled visible)
- KeyPress Key Preview Event !
- Refresh SHOW GET (Requery,Page)
- Message Return Message text (Old!)
29Option Buttons
- Data
- Methods
- Layout
- Other
- Tips
ControlSource Field or memvar Value same type as
the --- ControlSource Alignment (Left/Right)
for button SpecialEffect not for command
button --- - Only in Option Button Groups!
30Avoid Confusion
- Name object name
- Caption title
- ControlSource differs
- memvar
- field
- function
- Value object value
31Check Boxes
- Data
- Methods
-
- Layout
- Other
-
- Tips
--- InteractiveChangeEvent ProgrammaticChangeEvent
--- --- - ProgrammaticChange important!
32Text Boxes
- Data
- Methods
- Layout
- Other
- Tips
Format, InputMask, Margin, Read- Only,
Open/MemoWindow RangeHigh, RangeLow SELECT, Style
(SAY-compatible), PasswordChar HideSelection -
Play with selected areas!
33Selected Text
- SelStart Begin of selection
- SelLength Number of chars
- SelText Complete Selected text
- HideSelection Show after LostFocus
- SelectedForeColor Text color
- SelectedBackColor Background color
34Edit Boxes
- Data
- Methods
- Layout
- Other
- Tips
MaxLength --- ScrollBars (vert.
horiz.) AllowTabs - Selected text applies here
35Spinners
- Data
- Methods
- Layout
- Other
- Tips
KeyboardHigh/LowValue, Spin- nerHigh/LowValue,
Increment UpEvent, DownEvent --- --- - Use
High/LowValues instead of RangeEvents
36Combo Boxes
- Data
- Methods
- Layout
- Other
- Tips
BoundColumn, DisplayValue AddItem,
AddListItem, ColumnCount, -Lines,
-Width Disabled/Select/Item/Back/ForeC TopIndex,
TopItemID, NEW IncrementalSearch,
Listcount, ListIndex, ListIdemID
37LayoutCombo box
- ColumnCount Number of Columns
- ColumnLines Show column lines
- ColumnWidth Width of columns (colon-delimite
d) - ItemBack/ForeColor
- SelectedItemBack/ForeColor
- DisabledItemBack/ForeColor
38DataCombo box
- RowSourceType 9 options
- RowSource name type
- BoundColumn Column bound to Value
- DisplayValue Text or pos. for display
- ItemData Additional value
- List Array of text
- Sorted Alphabetically sorted
- FirstElement, NumberOfElements for Arrays
39Methods OtherCombo box
- Methods
- Requery Requery SQL/QPR-Source
- Other
- IncrementalSearch self-explanatory
- TopIndex first visible item
- NewIndex last AddItem-position
- Listcount Number of items
- ListIndex (Last) selected item
40What are IDs?Combo box
- ItemIDData Additional value by ID
- ListItem Array of text by ID
- Other
- TopItemID ID of topmost vis. list-item
- NewItemID last AddItem-ID
- ListItemID (Last) selected item ID
- ( List ListItem / ListIndex ListItemID)
- ( RowSourceType (0None), (1Value) )
41ID-MethodsCombo box
- AddItem Add at position
- AddListItem Add with ID
- RemoveItem Remove from position
- RemoveListItem Remove with ID
- Clear Delete all items
- IndexToItemID Position -gt ID
- ItemIDToIndex ID -gt Position
42List Boxes
- Data
- Methods
- Layout
- Other
-
- Tips
--- --- --- MultiSelect - Use DisplayValue and
Value together for text and offset
43Container
Hierarchy
- FrameSet
- Frame
- PageFrame
- Page
- Grid
- Column
- Option Group
- Command Group
- Frame
- PageF,Grid,Controls
- Page
- Grid, Controls
- Column
- Header, Controls
- Option Buttons
- Command Buttons
44Option/Command Button Groups
--- AddObject, RemoveObject ButtonCount Buttons -
ChangeEvents only in Groups - No Inheritance for
new buttons
- Data
- Methods
- Layout
- Other
-
- Tips
45Page Frames
- Data
- Methods
- Layout
-
- Other
-
- Tips
ActivePage --- PageCount, PageHeight/Width, Tabs,
TabStretch Pages (Array) -Drop objects on top
for all pages
46Pages
- Data
- Methods
- Layout
- Other
-
- Tips
Controls (Array) --- ControlCount PageOrder,
KeyPreview - Reference all with PAGES.
47Grids
- See Using the Grid Control - Whil Hentzen
48OLE-Controls
- OLE Bound Controls
- "bound" to Genearl-fields
- no own Events
- OLE Container Controls
- OCX with own Events
- OLE unbound to fields
- See OLE Custom Controls - Steven Black
PicClip, Outline, Word 6.0, O-Gramm, Graph,
Excel, Comm, ClipArt, PowerPoint, Formula Editor
49Container-Confusion
- Container Objects
- FrameSet, Frame, PageFrame, Page, Grid,
- Column, Option Group, Command Group
- Control Objects
- protected
- Custom Objects
- non-visual
50Naming Conventions
- chk Check box
- cbo Combo box
- cmd Command
- cmg Com. group
- cnt Container
- ctl Control
- (cus Custom)
- edt Edit box
- frm Form
- frs Form set
- grd Grid
- grc Grid column
- grh Grid header
- img Image
- lbl Label
- lin Line
- lst List box
- olb OLE-bound
- ole OLE
- opt Option button
- opg Option group
- (otl Outline)
- pag Page
- pgf Page Frame
- sep Separator
- shp Shape
- spn Spinner
- txt Text box
- tmr Timer
- tbr Toolbar
51Ease your work!
Builders
- Textbox
- Editbox
- Listbox
- Combo-Box
- Option Group
- Command Group
- Grid
- Design-Only Methods
- - Read/Write-Method
- - Read/Write-Expression
- ASelObj( )
- You will love them!
52Where to go from here? Related Sessions
- The Form Designer - Alan Schwartz
- Advanced Visual FoxPro Controls - Ted Roche
- Using the Grid Control in the Real World - Whil
Hentzen - OLE Custom Controls in Visual FoxPro - Steven
Black - Builders in Visual FoxPro - Steven Black
- Using Visual FoxPro Classes - Ken Levy
- ( The Class Browser - Ken Levy )
- ( Building applications using class libraries -T.
M. T.-F. )
53Questions?
- Check the VFP-sample files!
- RichTextFormat-Manuals...
- (or better click through the really big
help-file)
????????