an introduction to controls rainer becker dfpug / isys gmbh germany
TRANSCRIPT
An Introduction to ControlsAn Introduction to Controls
Rainer BeckerRainer Becker
dFPUG / ISYS GmbHdFPUG / ISYS GmbH
GermanyGermany
About the SpeakerAbout the Speaker
German FoxPro User GroupGerman FoxPro User Group ISYS GmbHISYS GmbH MS Solution ProviderMS Solution Provider MS Consulting ServicesMS Consulting Services Adress: Adress: Rainer Becker, Messerschmittstr. 2a, Rainer Becker, Messerschmittstr. 2a,
65760 Eschborn, Germany65760 Eschborn, Germany
Phone: 01149-6173-68182, Fax: -65997Phone: 01149-6173-68182, Fax: -65997
CompuServe: 100024,1364 / CompuServe: 100024,1364 / GO MSCESYSGO MSCESYS
Whats includedWhats included
Short Introduction to principles ofShort Introduction to principles of
Properties/Events/MethodsProperties/Events/Methods Guided Tour through all ControlsGuided Tour through all Controls
- walking all properties upstairs- walking all properties upstairs Some words aboutSome words about
Containers, Naming, BuildersContainers, Naming, Builders
Whats excludedWhats excluded
Form DesignerForm Designer Class DesignerClass Designer Grid-ControlGrid-Control OLE-ControlsOLE-Controls
(but you might get a good base for all of that)(but you might get a good base for all of that)
ClassesClasses InheritanceInheritance Non-Visual ObjectsNon-Visual Objects Event-ModelEvent-Model
Form DesignerForm Designer
ControlsControls– LibsLibs– LocksLocks
PropertiesProperties– DataData– MethodMethod– LayoutLayout– OtherOther
LayoutLayout PalettePalette
DesignDesign
ToolbarsToolbars
VocabularyVocabulary
What are What are PropertiesProperties ? ? What are What are MethodsMethods ? ? What are What are EventsEvents ? ? How to avoid confusion?How to avoid confusion? How to reference objects ?How to reference objects ?
What are PROPERTIES?What are PROPERTIES?
Think of them as bound variablesThink of them as bound variables Public vars with a private pathPublic vars with a private path Example: COMMENT, HEIGHTExample: COMMENT, HEIGHT Add your own!Add your own!
Later on you will need them - especiallyLater on you will need them - especially
for non-visual objects or even applicationsfor non-visual objects or even applications
What are METHODS?What are METHODS?
Think of them as old-style snippetsThink of them as old-style snippets Procedures bound to Controls/FormsProcedures bound to Controls/Forms Example: Refresh, SetFocusExample: Refresh, SetFocus Add your own!Add your own!
You will sometimes need themYou will sometimes need them
- but building your own is real fun!- but building your own is real fun!
What are EVENTS?What are EVENTS?
Think of them as old-style snippetsThink of them as old-style snippets Procedures bound to Windows-EventsProcedures bound to Windows-Events Example: old-fashioned VALID, CLICKExample: old-fashioned VALID, CLICK You can not extend! You can not extend!
– Events are methods bound to OS/VFP/USEREvents are methods bound to OS/VFP/USER
You normally need only some of themYou normally need only some of them
- but it is great that there are so many!- but it is great that there are so many!
Avoid ConfusionAvoid Confusion
Events and Methods have a ProcedureEvents and Methods have a Procedure Events could be seen as an Event + MethodEvents could be seen as an Event + Method Some Properties are followed by actionsSome Properties are followed by actions These Categories are not closed boxesThese Categories are not closed boxes There are many - but most are easy to use!There are many - but most are easy to use! Obey Graphical hints:Obey Graphical hints:
BoldBold = changed, = changed, Italic Italic = read-only= read-only Use RESET TO DEFAULT Use RESET TO DEFAULT (right mouse button)(right mouse button)
SyntaxSyntax
objectvariable.[form.]control.property = Settingobjectvariable.[form.]control.property = Setting
THIS.THIS. THISFORM.THISFORM. THISFORMSET.THISFORMSET. _SCREEN._SCREEN.
WITH.. ..ENDWITH, COUNT / PAGESWITH.. ..ENDWITH, COUNT / PAGES
ACTIVEFORM.ACTIVEFORM. ACTIVEPAGE.ACTIVEPAGE. ACTIVECONTROL.ACTIVECONTROL. PARENT.PARENT.
Controls - A Guided TourControls - A Guided Tour
Timers Timers LinesLines ShapesShapes ImagesImages LabelsLabels Command ButtonsCommand Buttons Option ButtonsOption Buttons Check BoxesCheck Boxes Text BoxesText Boxes
Edit BoxesEdit Boxes SpinnersSpinners Combo BoxesCombo Boxes List BoxesList Boxes Option GroupsOption Groups Command GroupsCommand Groups Page Frames Page Frames GridsGrids OLE-ControlsOLE-Controls
Not all of them are new! Not all of them are new! Renamed ControlsRenamed Controls
Text => Label controlText => Label control GET-Field => Text boxGET-Field => Text box Edit Region => Edit boxEdit Region => Edit box Popup => Combo boxPopup => Combo box Radio button => Optionb.Radio button => Optionb. Push button => CommandPush button => Command Screen(Set) => Form (Set)Screen(Set) => Form (Set) Picture => ImagePicture => Image
Really new are:Really new are: TimersTimers PagePage GridGrid OCXOCX
Nearly all are enhanced!Nearly all are enhanced!
Lets start with a new but small one Lets start with a new but small one TimersTimers
DataData MethodsMethods LayoutLayout OtherOther
TipsTips
Comment, TagComment, Tag
BASICBASIC,, TimerEvent, Reset TimerEvent, Reset
COORDINATESCOORDINATES
CLASSCLASS, , IntervalInterval
- Not executed while Menu open- Not executed while Menu open
- Not exact enough for RealTime- Not exact enough for RealTime
Timer & Basic Data/LayoutTimer & Basic Data/Layout
TimerTimer (one of each)(one of each)– TimerEventTimerEvent Procedure called at EventProcedure called at Event– ResetMethodResetMethod Restart timerRestart timer– IntervalProp.IntervalProp. Timer in millisecondsTimer in milliseconds
DataData– CommentComment You should use it!You should use it!– TagTag Free propertyFree property
LayoutLayout– Top, Left, Heigth, WidthTop, Left, Heigth, Width
Basic OtherBasic Other
OtherOther– NameName Naming conventionsNaming conventions– EnabledEnabled logical Flaglogical Flag– ClassClass Objects belong to classesObjects belong to classes– ClassLibraryClassLibrary optional: VCX of the classoptional: VCX of the class– BaseclassBaseclass Base class derived fromBase class derived from– ParentclassParentclass optional: derived fromoptional: derived from– ParentParent runtime: container objectruntime: container object
Basic Events/MethodsBasic Events/Methods
EventsEvents– InitInit Object initialisedObject initialised– DestroyDestroy Object removedObject removed– ErrorError local error-handlerlocal error-handler
MethodsMethods– CloneObjectCloneObject runtime duplicationruntime duplication– SaveAsClassSaveAsClass objects from VCX to VCXobjects from VCX to VCX– Read/WriteExpression/Method at design timeRead/WriteExpression/Method at design time
LinesLines
DataData EventsEvents MethodsMethods LayoutLayout
OtherOther TipsTips
------
CLICK, MOUSE, DRAGCLICK, MOUSE, DRAG
Drag, Move, UIEnable, ZOrderDrag, Move, UIEnable, ZOrder
DragIcon/Mode, BORDER,Draw-DragIcon/Mode, BORDER,Draw-
Mode, MousePointer, Mode, MousePointer, LineSlantLineSlant
HelpContextIDHelpContextID
- No 3D-line-effects- No 3D-line-effects
Click & Mouse EventsClick & Mouse EventsVisible ObjectsVisible Objects
ClickClick– ClickClick Mouse left clickMouse left click– DblClickDblClick Mouse double clickMouse double click– RightClickRightClick Mouse right clickMouse right click
MouseMouse– MouseMoveMouseMove Mouse over objectMouse over object– MouseDownMouseDown Mouse pressed for clickMouse pressed for click– MouseUpMouseUp Mouse releasedMouse released– MousePointerMousePointer 12 pointer versions12 pointer versions
Drag & Drop Drag & Drop Visible ObjectsVisible Objects
DragDrag– DragDropDragDrop End of drag, target eventEnd of drag, target event– DragOver DragOver object over target, target eventobject over target, target event
MethodsMethods– DragDrag Method for manual draggingMethod for manual dragging– MoveMove Method for manual movingMethod for manual moving
PropertiesProperties– DragIconDragIcon Cursor Icon for dragCursor Icon for drag– DragModeDragMode automatic / manualautomatic / manual
PropertiesProperties Visible ObjectsVisible Objects
Bordercolor, -style, -width for borderBordercolor, -style, -width for border VisibleVisible Temporary hide objectTemporary hide object HelpContextIDHelpContextID for HelpCompilerfor HelpCompiler ZOrder Meth.ZOrder Meth. active Page, tlb orderactive Page, tlb order UIEnable Evt.UIEnable Evt. Page activate eventPage activate event DrawmodeDrawmode 16 different modes 16 different modes
(Line/Shape/Form)(Line/Shape/Form)
LineSlantLineSlant special line propertyspecial line property
ShapesShapes
DataData MethodsMethods LayoutLayout
OtherOther
TipsTips
------
------
BackColor/Style, FillColor/Style,BackColor/Style, FillColor/Style,
ColorScheme/Source, ToolTipColorScheme/Source, ToolTip
SpecialEffect, SpecialEffect, CurvatureCurvature
------
- Shapes in front block the click event- Shapes in front block the click event
PropertiesProperties Plain ObjectsPlain Objects
Colors Colors – BackStyleBackStyle Transparent / Opaque (Default)Transparent / Opaque (Default)
– BackColorBackColor RGB-Color for Qpaque objectsRGB-Color for Qpaque objects
– FillColorStyleFillColorStyle Transparent, Solid, LinesTransparent, Solid, Lines
– FillColorFillColor RGB-Color if not transparentRGB-Color if not transparent
– ColorSchemeColorScheme Object/Form/Source/DefaultObject/Form/Source/Default
– ColorSourceColorSource Scheme for Above=SourceScheme for Above=Source
ToolTipTextToolTipTextToolTip if Form.ShowTips=.T.ToolTip if Form.ShowTips=.T. SpecialEffectSpecialEffect Plain or 3DPlain or 3D CurvatureCurvature 0=rectangle - 99=circle0=rectangle - 99=circle
ImagesImages
DataData MethodsMethods LayoutLayout
OtherOther
TipsTips
------
------
PicturePicture (Bitmap, Icon)(Bitmap, Icon)
StretchStretch (Clip/Isometric/Stretch) (Clip/Isometric/Stretch)
------
- Stretch also used for OLE- Stretch also used for OLE
LabelsLabels
DataData MethodsMethods LayoutLayout
OtherOther
TipsTips
------
------
Caption, FONT, COLORCaption, FONT, COLOR
AutoSize, WordWrap, AlignmentAutoSize, WordWrap, Alignment
------
- The Caption can be a function- The Caption can be a function
Layout PropertiesLayout PropertiesObjects with CaptionObjects with Caption
FontName & FontSizeFontName & FontSize FontFlagsFontFlags FontBold, FontItalic, FontStrikeThru, FontBold, FontItalic, FontStrikeThru,
FontOutline, FontUnderline, FontShadowFontOutline, FontUnderline, FontShadow
Color Color DisabledBackColor, (Disabled)ForeColorDisabledBackColor, (Disabled)ForeColor
CaptionCaption Text to be shown (function)Text to be shown (function) AlignmentAlignment Left/Right/CenteredLeft/Right/Centered AutoSizeAutoSize Resize horiz. for textResize horiz. for text WordWrapWordWrap Wrap words/resize verticalWrap words/resize vertical
Command ButtonsCommand Buttons
DataData MethodsMethods LayoutLayout
OtherOther
TipsTips
TerminateReadTerminateRead
ErrorMessage, see EVENTSErrorMessage, see EVENTS
DownPicture, DisabledPictureDownPicture, DisabledPicture
StatusBarText, (Style=Inv.)StatusBarText, (Style=Inv.)
TabIndex, TabStop (Forms!) TabIndex, TabStop (Forms!)
Default, Cancel Default, Cancel (not \! or \? )(not \! or \? )
- Use small fonts with pictures- Use small fonts with pictures
- Use StatusBarText instead- Use StatusBarText instead
EventsEventsfor accessible objectsfor accessible objects
WhenWhen old-fashioned WHENold-fashioned WHEN ValidValid old-fashioned VALIDold-fashioned VALID GotFocusGotFocus Tabbed to itTabbed to it LostFocusLostFocus Tabbed somewhere else...Tabbed somewhere else... SetFocusSetFocus Method (enabled & visible)Method (enabled & visible) KeyPressKeyPress Key Preview Event !Key Preview Event ! RefreshRefresh SHOW GET (Requery,Page)SHOW GET (Requery,Page) MessageMessage Return Message text (Old!)Return Message text (Old!)
Option ButtonsOption Buttons
DataData
MethodsMethods LayoutLayout
OtherOther
TipsTips
ControlSourceControlSource Field or Field or memvarmemvar
ValueValue same type as the same type as the
------ ControlSourceControlSourceAlignment (Left/Right) for buttonAlignment (Left/Right) for button
SpecialEffect not for command buttonSpecialEffect not for command button
------
- Only in Option Button Groups!- Only in Option Button Groups!
Avoid ConfusionAvoid Confusion
NameName object nameobject name CaptionCaption titletitle ControlSource ControlSource differsdiffers
» memvarmemvar
» fieldfield
» functionfunction
ValueValue object valueobject value
Check BoxesCheck Boxes
DataData MethodsMethods
LayoutLayout OtherOther
TipsTips
------
InteractiveChangeEventInteractiveChangeEvent
ProgrammaticChangeEventProgrammaticChangeEvent
------
------
- ProgrammaticChange important!- ProgrammaticChange important!
Text BoxesText Boxes
DataData
MethodsMethods LayoutLayout
OtherOther
TipsTips
Format, InputMask, Margin, Read-Format, InputMask, Margin, Read-
Only, Open/MemoWindowOnly, Open/MemoWindow
RangeHigh, RangeLowRangeHigh, RangeLow
SELECT, Style (SAY-compatible),SELECT, Style (SAY-compatible),
PasswordCharPasswordChar
HideSelectionHideSelection
- Play with selected areas!- Play with selected areas!
Selected TextSelected Text
SelStartSelStart Begin of selectionBegin of selection SelLengthSelLength Number of charsNumber of chars SelTextSelText Complete Selected Complete Selected
texttext HideSelectionHideSelection Show after LostFocusShow after LostFocus SelectedForeColorSelectedForeColor Text colorText color SelectedBackColorSelectedBackColor Background colorBackground color
Edit BoxesEdit Boxes
DataData MethodsMethods LayoutLayout OtherOther
TipsTips
MaxLengthMaxLength
------
ScrollBars (vert. & horiz.)ScrollBars (vert. & horiz.)
AllowTabsAllowTabs
- “Selected text” applies here- “Selected text” applies here
SpinnersSpinners
DataData
MethodsMethods LayoutLayout OtherOther
TipsTips
KeyboardHigh/LowValue, Spin-KeyboardHigh/LowValue, Spin-
nerHigh/LowValue, nerHigh/LowValue, IncrementIncrement
UpEvent, DownEventUpEvent, DownEvent
------
------
- Use High/LowValues instead of - Use High/LowValues instead of RangeEventsRangeEvents
Combo BoxesCombo Boxes
DataData MethodsMethods LayoutLayout
OtherOther
TipsTips
BoundColumn, DisplayValueBoundColumn, DisplayValue
AddItem, AddListItem,AddItem, AddListItem,
ColumnCount, -Lines, -WidthColumnCount, -Lines, -Width
Disabled/Select/Item/Back/ForeCDisabled/Select/Item/Back/ForeC
TopIndex, TopItemID, +NEWTopIndex, TopItemID, +NEW
IncrementalSearch, Listcount,IncrementalSearch, Listcount,
ListIndex, ListIdemIDListIndex, ListIdemID
LayoutLayoutCombo boxCombo box
ColumnCount ColumnCount Number of ColumnsNumber of Columns ColumnLinesColumnLines Show column linesShow column lines ColumnWidth ColumnWidth Width of columns Width of columns
(colon-delimited)(colon-delimited) ItemBack/ForeColorItemBack/ForeColor SelectedItemBack/ForeColorSelectedItemBack/ForeColor DisabledItemBack/ForeColorDisabledItemBack/ForeColor
DataDataCombo boxCombo box
RowSourceTypeRowSourceType9 options9 options RowSourceRowSource name typename type BoundColumnBoundColumn Column bound to ValueColumn bound to Value DisplayValueDisplayValue Text or pos. for displayText or pos. for display ItemDataItemData Additional valueAdditional value ListList Array of textArray of text SortedSorted Alphabetically sortedAlphabetically sorted FirstElement, NumberOfElements for ArraysFirstElement, NumberOfElements for Arrays
Methods & OtherMethods & OtherCombo boxCombo box
MethodsMethods– RequeryRequery Requery SQL/QPR-SourceRequery SQL/QPR-Source
OtherOther– IncrementalSearchIncrementalSearch self-explanatoryself-explanatory– TopIndexTopIndex first visible itemfirst visible item– NewIndexNewIndex last AddItem-positionlast AddItem-position– ListcountListcount Number of itemsNumber of items– ListIndexListIndex (Last) selected item(Last) selected item
What are IDs?What are IDs?Combo boxCombo box
ItemIDDataItemIDData Additional value by IDAdditional value by ID ListItemListItem Array of text by IDArray of text by ID OtherOther
– TopItemIDTopItemID ID of topmost vis. list-itemID of topmost vis. list-item
– NewItemIDNewItemID last AddItem-IDlast AddItem-ID
– ListItemIDListItemID (Last) selected item ID(Last) selected item ID
( List + ListItem / ListIndex + ListItemID)( List + ListItem / ListIndex + ListItemID)
( RowSourceType (0=None), (1=Value) )( RowSourceType (0=None), (1=Value) )
ID-MethodsID-MethodsCombo boxCombo box
AddItemAddItem Add at positionAdd at position AddListItemAddListItem Add with IDAdd with ID RemoveItemRemoveItem Remove from positionRemove from position RemoveListItemRemoveListItemRemove with IDRemove with ID ClearClear Delete all itemsDelete all items IndexToItemIDIndexToItemID Position -> IDPosition -> ID ItemIDToIndexItemIDToIndex ID -> PositionID -> Position
List BoxesList Boxes
DataData MethodsMethods LayoutLayout OtherOther
TipsTips
------
------
------
MultiSelectMultiSelect
- Use DisplayValue and Value- Use DisplayValue and Value
together for text and offsettogether for text and offset
Container Container
FrameSetFrameSet FrameFrame PageFramePageFrame PagePage GridGrid ColumnColumn Option GroupOption Group Command GroupCommand Group
FrameFrame PageF,Grid,ControlsPageF,Grid,Controls PagePage Grid, ControlsGrid, Controls ColumnColumn Header, ControlsHeader, Controls Option ButtonsOption Buttons Command ButtonsCommand Buttons
Hierarchy
Option/Command Button GroupsOption/Command Button Groups
------
AddObject, RemoveObjectAddObject, RemoveObject
ButtonCountButtonCount
ButtonsButtons
- ChangeEvents only in Groups- ChangeEvents only in Groups
- No Inheritance for new buttons- No Inheritance for new buttons
DataData MethodsMethods LayoutLayout OtherOther
TipsTips
DataData MethodsMethods LayoutLayout
OtherOther
TipsTips
ActivePageActivePage
------
PageCount, PageHeight/Width,PageCount, PageHeight/Width,
Tabs, TabStretchTabs, TabStretch
Pages (Array)Pages (Array)
-Drop objects on top for all pages-Drop objects on top for all pages
Page FramesPage Frames
PagesPages
DataData MethodsMethods LayoutLayout OtherOther
TipsTips
Controls (Array)Controls (Array)
------
ControlCountControlCount
PageOrder, KeyPreviewPageOrder, KeyPreview
- Reference all with PAGES.- Reference all with PAGES.
GridsGrids
See: Using the Grid Control - Whil HentzenSee: Using the Grid Control - Whil Hentzen
OLE-ControlsOLE-Controls
OLE Bound ControlsOLE Bound Controls– "bound" to Genearl-fields"bound" to Genearl-fields– no own Eventsno own Events
OLE Container ControlsOLE Container Controls– OCX with own EventsOCX with own Events– OLE unbound to fieldsOLE unbound to fields
See: OLE Custom Controls - Steven BlackSee: OLE Custom Controls - Steven Black
PicClip, Outline,PicClip, Outline,
Word 6.0, O-Gramm,Word 6.0, O-Gramm,
Graph, Excel, Comm,Graph, Excel, Comm,
ClipArt, PowerPoint,ClipArt, PowerPoint,
Formula EditorFormula Editor
Container-ConfusionContainer-Confusion
Container ObjectsContainer Objects– FrameSet, Frame, PageFrame, Page, Grid,FrameSet, Frame, PageFrame, Page, Grid,
Column, Option Group, Command GroupColumn, Option Group, Command Group Control Objects Control Objects
– protectedprotected Custom Objects Custom Objects
– non-visualnon-visual
Naming ConventionsNaming Conventions
chk Check boxchk Check box cbo Combo boxcbo Combo box cmd Command cmd Command cmg Com. groupcmg Com. group cnt Containercnt Container ctl Controlctl Control (cus Custom)(cus Custom) edt Edit boxedt Edit box frm Formfrm Form frs Form setfrs Form set
grd Gridgrd Grid grc Grid columngrc Grid column grh Grid headergrh Grid header img Imageimg Image lbl Labellbl Label lin Linelin Line lst List boxlst List box olb OLE-boundolb OLE-bound ole OLEole OLE opt Option opt Option
buttonbutton
opg Option groupopg Option group (otl Outline)(otl Outline) pag Pagepag Page pgf Page Framepgf Page Frame sep Separatorsep Separator shp Shapeshp Shape spn Spinnerspn Spinner txt Text boxtxt Text box tmr Timertmr Timer tbr Toolbartbr Toolbar
Ease your work! Ease your work! BuildersBuilders
TextboxTextbox EditboxEditbox ListboxListbox Combo-BoxCombo-Box Option GroupOption Group Command GroupCommand Group GridGrid
Design-Only Design-Only MethodsMethods - Read/Write-Method- Read/Write-Method
- Read/Write-Expression- Read/Write-Expression
ASelObj( )ASelObj( )
You will love them!You will love them!
Where to go from here? Where to go from here? Related SessionsRelated Sessions
The Form Designer - Alan SchwartzThe Form Designer - Alan Schwartz Advanced Visual FoxPro Controls - Ted RocheAdvanced Visual FoxPro Controls - Ted Roche Using the Grid Control in the Real World - Whil HentzenUsing the Grid Control in the Real World - Whil Hentzen OLE Custom Controls in Visual FoxPro - Steven BlackOLE Custom Controls in Visual FoxPro - Steven Black Builders in Visual FoxPro - Steven BlackBuilders in Visual FoxPro - Steven Black Using Visual FoxPro Classes - Ken LevyUsing Visual FoxPro Classes - Ken Levy ( The Class Browser - Ken Levy )( The Class Browser - Ken Levy ) ( Building applications using class libraries -T. M. T.-F. )( Building applications using class libraries -T. M. T.-F. )
Questions?Questions?
????????
Check the VFP-sample files!Check the VFP-sample files!
RichTextFormat-Manuals...RichTextFormat-Manuals...(or better: click through the really big help-file)(or better: click through the really big help-file)