560 likes | 825 Views
An Introduction to Controls. Rainer Becker dFPUG / ISYS GmbH Germany. About 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
E N D
An Introduction to Controls Rainer Becker dFPUG / ISYS GmbH Germany
About 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
Whats included • Short Introduction to principles of Properties/Events/Methods • Guided Tour through all Controls - walking all properties upstairs • Some words about Containers, Naming, Builders
Whats 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
Form Designer Toolbars • Controls • Libs • Locks • Properties • Data • Method • Layout • Other • Layout • Palette • Design
Vocabulary • What are Properties ? • What are Methods ? • What are Events ? • How to avoid confusion? • How to reference objects ?
What 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
What 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!
What 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!
Avoid 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)
Syntax • objectvariable.[form.]control.property = Setting • THIS. • THISFORM. • THISFORMSET. • _SCREEN. • WITH.. ..ENDWITH, COUNT / PAGES • ACTIVEFORM. • ACTIVEPAGE. • ACTIVECONTROL. • PARENT.
Controls - 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
Not all of them are new! Renamed Controls • Text => Label control • GET-Field => Text box • Edit Region => Edit box • Popup => Combo box • Radio button => Optionb. • Push button => Command • Screen(Set) => Form (Set) • Picture => Image • Really new are: • Timers • Page • Grid • OCX • Nearly all are enhanced!
Lets 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
Timer & 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
Basic 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
Basic 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
Lines • 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
Click & 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
Drag & 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
PropertiesVisible 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
Shapes --- --- BackColor/Style, FillColor/Style, ColorScheme/Source, ToolTip SpecialEffect, Curvature --- - Shapes in front block the click event • Data • Methods • Layout • Other • Tips
PropertiesPlain 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 Above=Source • ToolTipText ToolTip if Form.ShowTips=.T. • SpecialEffect Plain or 3D • Curvature 0=rectangle - 99=circle
Images • Data • Methods • Layout • Other • Tips --- --- Picture(Bitmap, Icon) Stretch (Clip/Isometric/Stretch) --- - Stretch also used for OLE
Labels • Data • Methods • Layout • Other • Tips --- --- Caption, FONT, COLOR AutoSize, WordWrap, Alignment --- - The Caption can be a function
Layout 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
Command Buttons • Data • Methods • Layout • Other • Tips TerminateRead ErrorMessage, see EVENTS DownPicture, DisabledPicture StatusBarText, (Style=Inv.) TabIndex, TabStop (Forms!) Default, Cancel (not \! or \? ) - Use small fonts with pictures - Use StatusBarText instead
Eventsfor 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!)
Option 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!
Avoid Confusion • Name object name • Caption title • ControlSource differs • memvar • field • function • Value object value
Check Boxes • Data • Methods • Layout • Other • Tips --- InteractiveChangeEvent ProgrammaticChangeEvent --- --- - ProgrammaticChange important!
Text 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!
Selected Text • SelStart Begin of selection • SelLength Number of chars • SelText Complete Selected text • HideSelection Show after LostFocus • SelectedForeColor Text color • SelectedBackColor Background color
Edit Boxes • Data • Methods • Layout • Other • Tips MaxLength --- ScrollBars (vert. & horiz.) AllowTabs - “Selected text” applies here
Spinners • Data • Methods • Layout • Other • Tips KeyboardHigh/LowValue, Spin- nerHigh/LowValue, Increment UpEvent, DownEvent --- --- - Use High/LowValues instead of RangeEvents
Combo 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
LayoutCombo box • ColumnCount Number of Columns • ColumnLines Show column lines • ColumnWidth Width of columns (colon-delimited) • ItemBack/ForeColor • SelectedItemBack/ForeColor • DisabledItemBack/ForeColor
DataCombo 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
Methods & 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
What 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 (0=None), (1=Value) )
ID-MethodsCombo box • AddItem Add at position • AddListItem Add with ID • RemoveItem Remove from position • RemoveListItem Remove with ID • Clear Delete all items • IndexToItemID Position -> ID • ItemIDToIndex ID -> Position
List Boxes • Data • Methods • Layout • Other • Tips --- --- --- MultiSelect - Use DisplayValue and Value together for text and offset
Container 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
Option/Command Button Groups • Data • Methods • Layout • Other • Tips --- AddObject, RemoveObject ButtonCount Buttons - ChangeEvents only in Groups - No Inheritance for new buttons
Page Frames • Data • Methods • Layout • Other • Tips ActivePage --- PageCount, PageHeight/Width, Tabs, TabStretch Pages (Array) -Drop objects on top for all pages
Pages • Data • Methods • Layout • Other • Tips Controls (Array) --- ControlCount PageOrder, KeyPreview - Reference all with PAGES.
Grids • See: Using the Grid Control - Whil Hentzen
OLE-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
Container-Confusion • Container Objects • FrameSet, Frame, PageFrame, Page, Grid, Column, Option Group, Command Group • Control Objects • protected • Custom Objects • non-visual
Naming 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