Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
GRIDHITTEST
Message
From
15/05/2001 06:19:12
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
14/05/2001 14:47:13
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00506979
Message ID:
00507188
Views:
12
>I am trying to use the gridhittest function to find out if the user has moved rows in a grid.
>
>How do you use it and is this the best way to capture the event to update a table with information from the grid row you are leaving?
>
>Thanks,
>
>Mitch

Mitch,
Since VFP6 introduced it's easier to find if a row leave is attempted using gridhittest. Consider these 2 code portions in BeforeRowColChange :
*pre VFP6
LPARAMETERS nColIndex
llChangingRow = .f.
with this
	oColumn = .columns(.FindColumn(nColIndex))
	if lastkey() = 145 && Adding new rec
        	.nLastValidRec = .nCurrec
	endif
	thisform.LockScreen = .lInGrid
	if mdown()
		lnBottom	= .top+.headerheight+.relativerow * .rowheight
		lnTop		= lnBottom - this.rowheight
		lnMouseRowPos	= mrow(wontop(),3)
		lnMouseColPos	= mcol(wontop(),3)
		llChangingRow	= !(between(lnMouseRowPos,lnTop, lnBottom) ;
		                  and between(lnMouseColPos,.left,.left+.width))
	else
		llChangingRow	= inlist(lastkey(),24,5,18,3,145,148)
	endif

	if llChangingRow and !.CanLeave()
          nodefault
          *...
        else
          *...
        endif
endwith 
*VFP6
*mdown portion changes
if mdown()
 store 0 to nWhere, nRelrow, nRelCol
 llLeavingRow = !This.GridHittest(mcol(wontop(),3), mrow(wontop(),3), ;
         @nWhere, @nRelRow, @nRelCol) ; 
         or !(nWhere=3 and this.RelativeRow = nRelRow )
else
*...
endif
Even with rowbuffering user could be prevented to change record. However though it fires even if you click outside of grid just BRCC code is not sufficient to control it. You should support the code with grid.valid too.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform