Wiki Home

VTLib


Namespace: VFP
VTLib is a VFP class library that emulates the .NET validation controls.

Now supports RegularExpressionValidator control!

For more information, go here.

Victor Espina



Screenshot of a data entry form using VTLib controls:



Screenshot of VTLib toolbar:


[2006.09.25 05:37:54 PM GMT]
Change the VTLib.PRG file to the codeing below to recurse into Containers & Page Frames.

********************************************************
** VTLib.prg
**
** Support functions for VTControls class library
**
** Author: Victor Espina (http://www.victorespina.com)
** Version: 1.0
**
** History:
** 21-Sep-2006	Created
** 25-Sep-2006  Recurse into Containers & Page Frames [email protected]
*********************************************************


#INCLUDE VTDeclares.h



* VTCheckValidators
* Check all validators controls in a given
* container and check if they are valid
* or not.
*
* Return True if all validators are valid
*
FUNCTION VTCheckValidators
LParameters toContainer, toSummaryValidator
	*
	LOCAL llError
	llError = .F.

	* Loop throu all objets in the container
	* to find Validator objects
	*
	LOCAL oObj
	
	FOR EACH oObj IN toContainer.Controls
		*
		* If object class is VTSummaryValidator, save a referente to it
		IF LOWER(oObj.Class)=="vtvalidationsummary"
			toSummaryValidator=oObj
			LOOP
		ENDIF
	
		* If object belongs to one of the validator classes, calls its Validate method
		Do Case
			*-- Recurse into Page Frames
			Case Upper(oObj.BaseClass) == Upper("PageFrame")
				For Each loPage as Page in oObj.Pages
					If !VTCheckValidators(loPage, toSummaryValidator)
						llError = .T.
					EndIf
				Next
			
			*-- Recurse into containers
			Case Upper(oObj.BaseClass) == Upper("Container")
				If !VTCheckValidators(oObj, toSummaryValidator)
					llError = .T.
				EndIf
	
			Case UPPER(LEFT(oObj.Class,2))=="VT" AND ATC("Validator",oObj.Class)<>0	
				IF NOT oObj.Validate()
					llError = .T.
				ENDIF
		EndCase
	 ENDFOR


	* If a Summary Validator was found, call it's Update() method
	*
	IF VarType(Nvl(toSummaryValidator, "")) == "O"
		toSummaryValidator.Update()
	ENDIF

RETURN !llError


Category Components, Category OOP, Category Developer Tools, Category User Interface
( Topic last updated: 2006.09.25 12:37:54 PM )