Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DynamicBackColor invalid expr if the grid has focus else
Message
From
23/05/2008 05:45:11
 
 
To
23/05/2008 03:43:15
Lutz Scheffler (Online)
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01318705
Message ID:
01319172
Views:
21
>Stefan.
>
>dealing with Dynamics for years I think this is nice for readability - but worst for performance. It will call the method over and over and this will slow down the grid to much.

Hi Agnes,
Interesting point - I never had that impression; made a test that seems to indicate almost no difference, what do you think?

Regards
-Stefan
LOCAL loForm as Form
loForm = CREATEOBJECT('TestForm')
loForm.Show(1)
RETURN

DEFINE CLASS TestForm as Form
	AllowOutput = .F.
	AutoCenter = .T.
	DataSession = 2
	PROCEDURE Load
		CREATE CURSOR temp (test1 Int, test2 Int, test3 Int, test4 Int)
		LOCAL i
		FOR i = 1 TO 500
			INSERT INTO temp VALUES (i,i,i,i)
		ENDFOR
		GO TOP
	ENDPROC

	ADD OBJECT grdTest as Grid WITH ;
		Left = 10, Top = 30, ;
		Width = 350, Height = 210, ;
		Anchor = 15, ;
		RowSource = 'temp', ;
		ColumnCount = 4
	PROCEDURE grdTest.Init
		This.SetAll('DynamicForeColor','This.DynamicX()','Column')
	ENDPROC
	PROCEDURE grdTest.DynamicX
		RETURN IIF(test1%2=0,RGB(0,0,0),RGB(255,0,0))
	ENDPROC

	ADD OBJECT cmdTest as CommandButton WITH ;
		Left = 200, Top = 5, Height = 24, Caption = "dynamic stress"
	PROCEDURE cmdTest.Click
		CLEAR

		LOCAL lcDynamicExpression, lnTimeProperty, lnTimeMethod
		lcDynamicExpression = 'This.DynamicX()'
		Thisform.grdTest.SetAll('DynamicForeColor',m.lcDynamicExpression,'Column')
		lnTimeMethod = SECONDS()
		Thisform.StressTest()
		lnTimeMethod = SECONDS() - m.lnTimeMethod

		lcDynamicExpression = 'IIF(test1%2=0,RGB(0,0,0),RGB(255,0,0))'
		Thisform.grdTest.SetAll('DynamicForeColor',m.lcDynamicExpression,'Column')
		lnTimeProperty = SECONDS()
		Thisform.StressTest()
		lnTimeProperty = SECONDS() - m.lnTimeProperty

		? "DynamicMethod took " + TRANSFORM(m.lnTimeMethod) + " seconds."
		? "DynamicProperty took " + TRANSFORM(m.lnTimeProperty) + " seconds."
	ENDPROC
	PROCEDURE StressTest
		LOCAL i
		FOR i = 1 TO 1000
			REPLACE test1 WITH test1+1 ALL IN temp
			Thisform.grdTest.Refresh()
		ENDFOR
		GO TOP IN temp
	ENDPROC
ENDDEFINE
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform