Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Browse.prg
Message
De
27/07/2011 06:15:02
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Titre:
Browse.prg
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Divers
Thread ID:
01519297
Message ID:
01519297
Vues:
137
I'm using this little piece of code frequently. I wrote it to make my browses more readable - nulls are gray, blanks are pinkish, logicals have checkboxes, and font is what I say, not what I got by default in my foxuser or registry, and it remembers the position.

You should have a currently selected alias before you Do Browse, or else you'll get a blank form.

Feel free to add whatever you find useful and please post back here.
* browse.prg
LPARAMETERS justaparameter
*[2002/05/29 03:53:34] nDragan - poslednja neobeležena verzija
*[2011/03/13 14:44:51] nDragan - dynamicbackcolor
oForm=CREATEOBJECT("browform")
oForm.SHOW()
READ events
RETURN oForm

DEFINE CLASS browform AS FORM
	ADD OBJECT oGrid AS GRID WITH RECORDSOURCE=ALIAS()
	KEYPREVIEW=.T.

	PROCEDURE ACTIVATE
		THIS.CAPTION="Browse "+THIS.oGrid.RECORDSOURCE
		THIS.RESIZE()
	ENDPROC

*---------------------------------------------------
	PROCEDURE INIT()
*-- dn 2011/03/13
* this is the object which saves/restores position. Roll your own or delete this line:
		THIS.NEWOBJECT("srpos","srposition","generall.vcx","", "top,left,height,width")

*---------------------------------------------------
	PROCEDURE KEYPRESS(tnKey, tnSCA)
*-- dn 2011/03/13
		IF tnKey=27
			THIS.RELEASE()
			CLEAR EVENTS
		ENDIF

*---------------------------------------------------
	PROCEDURE oGrid.INIT
		LOCAL i, N
		SET PROCEDURE TO BROWSE.prg
		FOR i=1 TO THIS.COLUMNCOUNT
			WITH THIS.COLUMNS[i]
				cSource=.CONTROLSOURCE
				cType=TYPE(cSource)
				DO CASE
					CASE cType="L"
						.ADDOBJECT("check","gcheck")
						.CHECK.VISIBLE=.T.
						.REMOVEOBJECT("text1")
						.CURRENTCONTROL="check"
						.CHECK.READONLY=.F.
						.SPARSE=.F.
				ENDCASE
				.DYNAMICBACKCOLOR="icase(ISNULL("+.CONTROLSOURCE+"), 0xcecece, ISblank("+.CONTROLSOURCE+"), 0xceffce,0xffffff)"
			ENDWITH
		ENDFOR
		WITH THIS AS GRID
			.GRIDLINECOLOR=0xcaaaaa
			.SETALL("fontname","consolas")
			.AUTOFIT()
		ENDWITH
	ENDPROC

	PROCEDURE RESIZE
		WITH THIS.oGrid
			.TOP=0
			.LEFT=0
			.WIDTH=THIS.WIDTH
			.HEIGHT=THIS.HEIGHT
			.SETALL("selectonentry",.F.)
		ENDWITH
	ENDPROC

ENDDEFINE


DEFINE CLASS gcheck AS CHECKBOX

	caption_yes = ("Yes")
	caption_no = ("No")
	caption_null= ("<null>")
	NAME = "gcheck"


	PROCEDURE INIT
* fire value_assign
		THIS.VALUE=THIS.VALUE
	ENDPROC

	PROCEDURE value_assign(tu_val)
		DO CASE
			CASE ISNULL(tu_val)
				THIS.CAPTION=THIS.caption_null
			CASE EMPTY(tu_val)
				THIS.CAPTION=THIS.caption_no
			OTHERWISE
				THIS.CAPTION=THIS.caption_yes
		ENDCASE
		THIS.REFRESH()
		THIS.VALUE = tu_val
	ENDPROC


	PROCEDURE INTERACTIVECHANGE
		THIS.VALUE=THIS.VALUE
	ENDPROC


	PROCEDURE CLICK
		DODEFAULT()
		THIS.REFRESH
		NODEFAULT
	ENDPROC


ENDDEFINE

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform