Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How can I determine, if I changed row by clicking on header
Message
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Title:
How can I determine, if I changed row by clicking on header
Miscellaneous
Thread ID:
00556166
Message ID:
00556166
Views:
61
Hi everyone,

I'm trying to implement a feature of showing Header in red, if it was clicked and the column re-ordered. I created the following class for the Header:
********************************************************************
*  Description.......: myHeader.Definition
*  Calling Samples...:
*  Parameter List....: tcCaption
*  Created by........: Cetin Basoz & David Frankenbach
*  Modified by.......: Nadya Nosonovsky 05/25/2001 10:26:56 AM
********************************************************************
define class MyHeader as header
	mcArrowName = ""    && name of the arrow used for all headers of the grid
	mlAscending = .f.   && flag for sort order
	mlColumnMoved = .f. && flag indicating column was moved
	mnColumnOrder = 0   && original column order
	mlColumnSized = .f. && flag indicating column was resized
	mnColumnWidth = 0   && original size of column
	nOriginalForeColor = 0  && original ForeColor

	procedure init
	lparameters tcCaption
	local ix, lcProperty
	if vartype(m.tcCaption) # "C" ;
			or empty(m.tcCaption)
		tcCaption = this.caption
	endif
	this.caption = m.tcCaption
	this.alignment = 2
endproc

	procedure click
	local nTempCurRec, lcTagName
	with this
		if ! .mlColumnMoved and ! .mlColumnSized
* sortable column that was clicked
			.mlAscending = ! .mlAscending
			thisform.lockscreen = .t.
			lcTagName=justext(.parent.controlsource)
			select (.parent.parent.recordsource)
			if tagno(m.lcTagName)> 0
			    .ForeColor=16711935 && Red
				if .mlAscending
					set order to tag (m.lcTagName) ;
						in (.parent.parent.recordsource) ascending
				else
					set order to tag (m.lcTagName) ;
						in (.parent.parent.recordsource) descending
				endif
				nTempCurRec = recno(.parent.parent.recordsource)
				.parent.parent.refresh
				if type('thisform.navstand.name')='C'
					thisform.navstand.lstOrders.value=m.lcTagName
				endif
				if between(m.nTempCurRec,1,reccount(.parent.parent.recordsource))
					go m.nTempCurRec in (.parent.parent.recordsource)
				endif
			endif
			thisform.lockscreen = .f.
		endif
	endwith
endproc

	procedure mousedown
	lparameters nButton, nShift, nXCoord, nYCoord

	with this
* initialize items that will be tested in MouseUp
		.mnColumnOrder = this.parent.columnorder
		.mnColumnWidth = this.parent.width
		.nOriginalForeColor=.ForeColor
	endwith
endproc

	procedure mouseup
	lparameters nButton, nShift, nXCoord, nYCoord

	with this
* check to see if this was a resize or move
		.mlColumnMoved = ( this.parent.columnorder != .mnColumnOrder )
		.mlColumnSized = ( this.parent.width != .mnColumnWidth )
*		.ForeColor=.nOriginalForeColor				    	
	endwith

endproc
	procedure dblclick
	this.parent.parent.SetOrder(this.parent.controlsource)
endproc
enddefine
Now, I'm trying to restore color back to original, if I click on another column header or another column. Could you please help me here?

Thanks in advance.
If it's not broken, fix it until it is.


My Blog
Next
Reply
Map
View

Click here to load this message in the networking platform