************************************************** *-- Class: ctbrlookup (e:\work\dcg\pvr\src\libs\pvr.vcx) *-- ParentClass: toolbar *-- BaseClass: toolbar *-- Time Stamp: 02/19/04 01:50:02 AM * #INCLUDE "c:\...\include.h" * DEFINE CLASS ctbrlookup AS toolbar Caption = "Lookup List" Height = 28 Left = 0 Sizable = .F. Top = 0 Width = 298 ControlBox = .F. oparentform = .NULL. oparentobject = .NULL. Name = "ctbrlookup" nincseek = .F. ltimer = .F. *-- Works with the lErrorOverride. If an error occurs this property will be true lerroroccurred = .F. *-- Set this property to true to override the form's error routine. Set it back when you are done. Sets the lErrorOccurred property if an error exists. lerroroverride = .F. ADD OBJECT cmblist AS combobox WITH ; FontName = "Arial", ; FontSize = 10, ; RowSourceType = 6, ; Height = 22, ; Left = 5, ; Style = 2, ; ToolTipText = "Type to search through list...", ; Top = 3, ; Width = 288, ; DisplayCount = 20, ; Name = "cmbList" ADD OBJECT tmrlookup AS timer WITH ; Top = 3, ; Left = 292, ; Height = 0, ; Width = 0, ; Name = "tmrLookup" PROCEDURE updatetoolbar * we need to attach this object to the datasession of the form * the toParentObject must have a controlsource: COLUMN LPARAMETERS toParentForm LOCAL lnSelect, lcAlias, lnRecno WITH THIS IF PARAMETERS() >= 1 * We need to be able to see the tables from the Calling Form SET DATASESSION TO toParentForm.DATASESSIONID .oParentForm = toParentForm lcAlias = "" lnRecno = 0 IF TYPE("toParentForm.oColumn") = "O" .oParentObject = toParentForm.oColumn lcAlias = .oParentObject.ControlSource lcAlias = SUBSTR(lcAlias, 1, AT(".", lcAlias)-1) ELSE .oParentObject = NULL ENDIF IF !EMPTY(lcAlias) AND USED(lcAlias) SELECT (lcAlias) lnRecno = IIF(BOF() OR EOF(), 0, RECNO()) ELSE lcAlias = "" lnRecno = 0 ENDIF ENDIF lnSelect = SELECT() DO CASE CASE PARAMETERS() < 1 OR EMPTY(lcAlias) OR RECCOUNT(lcAlias) = 0 .cmbList.ROWSOURCE = NULL .cmbList.CONTROLSOURCE = NULL .cmbList.VALUE = NULL .cmbList.TOOLTIPTEXT = "Lookup List is not available." *CASE UPPER(.oParentObject.Class) <> "CTXTORDERCOLUMN" * leave the object alone CASE PARAMETERS() >= 1 AND !EMPTY(lcAlias) AND ; VARTYPE(EVAL(toParentForm.oColumn.ControlSource)) = "C" AND ; INLIST(UPPER(ALLTRIM(.oParentObject.Class)), "CTXTORDERCOLUMN", "CEDTORDERCOLUMN") * numeric data types do not work so well .cmbList.FORMAT = "!" .cmbList.ROWSOURCE = .oParentObject.ControlSource .cmbList.CONTROLSOURCE = .oParentObject.ControlSource .cmbList.VALUE = EVAL(.oParentObject.ControlSource) .cmbList.TOOLTIPTEXT = "" IF lnRecno > 0 GOTO lnRecno ELSE GO TOP ENDIF .cmbList.REFRESH() OTHERWISE .cmbList.ROWSOURCE = NULL .cmbList.CONTROLSOURCE = NULL .cmbList.VALUE = NULL .cmbList.TOOLTIPTEXT = "Lookup List is not available for this datatype." ENDCASE ENDWITH SELECT (lnSelect) ENDPROC PROCEDURE Init DODEFAULT() * Restore the toolbar's position *IF !THIS.RestoreWindowPos() * Default is to dock toolbar at top THIS.DOCK(TOOL_TOP) *ENDIF ENDPROC PROCEDURE Destroy * Save the toolbar's position *THIS.SaveWindowPos() * Make the toolbar disappear faster THIS.ENABLED = .F. ENDPROC PROCEDURE cmblist.KeyPress LPARAMETERS nKeyCode, nShiftAltCtrl * every keypress will reset the timer This.Parent.tmrLookup.Reset() ENDPROC PROCEDURE cmblist.GotFocus DODEFAULT() WITH THIS.Parent .nIncSeek = _INCSEEK _INCSEEK = .75 * enable the timer - milliseconds .tmrLookup.Interval = _INCSEEK * 1000 ENDWITH ENDPROC PROCEDURE cmblist.LostFocus WITH THIS.Parent * disable the timer .tmrLookup.Interval = 0 _INCSEEK = .nIncSeek ENDWITH DODEFAULT() ENDPROC PROCEDURE cmblist.InteractiveChange WITH THIS.Parent * this will wait for _INCSEEK time before processing .tmrLookup.Reset() DODEFAULT() .lTimer = .T. ENDWITH ENDPROC PROCEDURE tmrlookup.Timer LOCAL lcBaseClass, llLockScreen, lnTimer WITH THIS.PARENT * only process when we are asked to by the LookUp IF .lTimer AND !CHRSAW() * turn off the timer while processing lnTimer = THIS.Interval THIS.Interval = 0 .lTimer = .F. llLockScreen = .oParentForm.LOCKSCREEN lcBaseClass = UPPER(.oParentObject.BASECLASS) DO CASE CASE lcBaseClass == "COLUMN" * point to the grid WITH .oParentObject.PARENT .AFTERROWCOLCHANGE(.ACTIVECOLUMN) ENDWITH ENDCASE .oParentForm.LOCKSCREEN = llLockScreen * turn on the timer when completed THIS.Interval = lnTimer ENDIF ENDWITH ENDPROC ENDDEFINE * *-- EndDefine: ctbrlookup **************************************************