Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Subclassing headers
Message
From
04/12/1998 09:39:55
 
 
To
04/12/1998 01:30:06
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00163637
Message ID:
00164064
Views:
26
>>I saw a trick where you can sort a column by clicking on the header. I'd like to use this, but it's too time consuming to add the code to every header. So I thought I'd make a header class. But VFP doesn't like it when I try to do that. Is there a way to subclass the header class?
>>
>>Another issue is putting indexes on every field in every table so it can sort. Is this a good idea? I'm wondering if that would slow things down significantly.
>>
>>Thanks,
>>
>>-Michelle
>Michelle,
>My 2 cents (you gonna be rich:) You can subclass a header and keep it either as a seperate prg or in a VCX (yes you could keep a nonVisual class in a VCX but not easy as it sounds :). The easier one is to define your own header class in a prg. After it's done you have two choices :
>- Add new header to grid on the fly
> In grid.init you could loop and replace all default headers with your header. For an example check multiselectgrid class in files\classes section.
>- Add new header at designtime - a builder. Here is a builder for grids. This builder is so raw that I never registered it to builder.dbf instead whenever I need it I just select one or more of my grids on form, go to command window and run this :
*Gridbuild.prg
>lParameters lcOldClass, lcNewClass, lcClassLib, lcApplyTo, lcKeepProperty, lcParams
>*
>* Quick and dirty builder for grid columns(ix).controls
>* gridbuild(lcOldClass, lcNewClass, lcClassLib [,lcApplyTo] [,lcKeepProperty] [,lcParams])
>* Author : Cetin Basoz - simple tasks library
>* lcOldClass = Class to change ie: header
>* lcNewClass = New Class ie: myheader
>* lcClassLib = vcx or prg containing definition - if prg extension is required
>* lcApplyTo  = Apply to columns list ie: 1,4,5 - all assumed if empty or ignored
>* lcKeepProperty - A property to keep as is if any ie: Caption
>* lcParams - Params passed to new class if any - ie : lnLeft, lnTop
>*
>* Sample calls :
>* 1)Replace all header class with myheader class (from myheaderset.prg) and keep caption property
>* =gridbuild("header","myheader","myheaderset.prg",,"caption")
>*
>* 2)Replace all textbox class with mytextbox class (from myclasses.vcx)
>* =gridbuild("textbox","mytextbox","myclasses")
>*
>* 3)Replace all textbox class with mytextbox class (from myclasses.vcx) in columns 1,3,5
>* gridbuild("textbox","mytextbox","myclasses","1,3,5")
>*
>* Select one or more grids on form and call
>*
>if type("lcOldClass") # "C" ;
>	or type("lcNewClass") # "C" ;
>	or type("lcClassLib") # "C"
>	or empty("lcOldClass") ;
>	or empty("lcNewClass") ;
>	or empty("lcClassLib")
>	wait window nowait "Required params missing."
>	return
>endif	
>
>lcApplyTo = iif(type("lcApplyTo")#"C","0",lcApplyTo)
>lcKeepProperty = iif(type("lcKeepProperty")="C",lcKeepProperty,"name")
>lcParams = iif(type("lcParams")="C",","+lcParams,"")
>if ratc(".prg",lcClassLib)>0
>	if !upper(lcClassLib)$set("Procedure")
>		set proc to (lcClasslib) additive
>	endif
>else
>	if !upper(lcClasslib)$set("classlib")
>		set classlib to  (lcClasslib) additive
>	endif
>endif	
>aselobj(oGrids)
>for each oGrid in oGrids
>    if !oGrid.baseclass = "Grid"
>    	loop
>    endif	
>	for each oColumn in oGrid.columns
> 	 if lcApplyTo=="0" or inlist(oColumn.columnorder, &lcApplyTo)
>	  for each oControl in oColumn.controls
>	   if upper(oControl.class) = upper(lcOldClass)
>		lcKeepName = oControl.name
>		lcKeepPropValue = oControl.&lcKeepProperty
>		oColumn.removeobject(lcKeepName)
>		oColumn.addobject(lcKeepName,lcNewClass &lcParams)
>		with eval("oColumn."+lcKeepName)
>		   .&lcKeepProperty = lcKeepPropValue
>		endwith
>	   endif
>	  endfor
>	 endif
>	endfor
>endfor
Cetin

Yet another way... :) I got lots of good suggestions on how to do this. I'm going to print them all out and see what I can come up with from them.

Thanks,

-Michelle
Previous
Reply
Map
View

Click here to load this message in the networking platform