Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Error with grdFooter - Height: Exp. eval. to an illegal
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01407367
Message ID:
01408307
Vues:
70
This message has been marked as the solution to the initial question of the thread.
Updated code in the ProblemGrid.Init(). The problem is happening because the grid height is small, 20, at design time and when machines are set to fonts larger than normal in Windows the design-time setting is not enough and fails. So I have devised this brute force method to save the grid from collapsing at runtime. Hope this is useful to people.

Sadly, such a problem grid still needs to have a larger height value at design time so that it can startup in any font setting. I think 50 is a safe bet, but I don't know what user might have set :)

Hope this helps and any improvements are welcome.

Thanks.

*** for special small in height grids
Height = 50 && I wanted 20
nMinHeight = 50
nRequiredHeight = 20

*** for special regular in height grids
Height = 159
nMinHeight = 50
nRequiredHeight = 0

GridBaseClass.Init()
LOCAL llHeightOkay, lnI, loErr, lnOrignalHeight


IF (NOT EMPTY(THIS.nRequiredHeight)) OR THIS.HEIGHT < 50
	*** 24/06/2009 set the nMinHeight based on the valid grid height
	***            this in conjunction with Height_Assign()
	***            to avoid height is illegal value error
	lnOrignalHeight = THIS.HEIGHT
	llHeightOkay    = .T.


	FOR lnI = 50 TO 1 STEP -1
		llHeightOkay = .F.


		*** go through each height possibilities
		TRY
			*** have to do this as there is an _assign that triggers
			THIS.nMinHeight = lnI
			THIS.HEIGHT     = lnI

		CATCH TO loErr
			IF loErr.ERRORNO = 1881  && Error with grdFooter - Height : Expression evaluated to an illegal value.
				*** we found the minimum height -1 because it errored
				llHeightOkay = .T.
			ELSE
				*** some other error it's parents turn to handle it
				THROW
			ENDIF
		ENDTRY


		IF llHeightOkay
			*** we found a height that is valid so exit
			THIS.nMinHeight = THIS.HEIGHT

			EXIT
		ENDIF
	ENDFOR
	

	*** try to give back the original height to the grid else the minimum height possible
	THIS.HEIGHT = MAX(lnOrignalHeight, THIS.nMinHeight)
	
	*** if you have filled in a nRequiredHeight we try to set that rather than the design time one
	IF NOT EMPTY(THIS.nRequiredHeight)
		THIS.HEIGHT = MAX(THIS.nRequiredHeight, THIS.nMinHeight)
	ENDIF
ENDIF


RETURN DODEFAULT()
GridBaseClass.Height_Assign
LPARAMETERS vNewVal


*** 23/06/2009 in conjunction with the code in Init()
***            to avoid height is illegal value error
THIS.HEIGHT = MAX(THIS.nMinHeight, m.vNewVal, THIS.HEADERHEIGHT)
Regards
Bhavbhuti
___________________________________________
Softwares for Indian Businesses at:
http://venussoftop.tripod.com
___________________________________________
venussoftop@gmail.com
___________________________________________
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform