Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Form caption in Main prg
Message
From
12/02/2008 10:07:57
 
 
To
12/02/2008 09:27:39
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01291771
Message ID:
01291808
Views:
10
Make sure you backup all of your forms FIRST. You will need to verify every form afterward you modify it (you can write a small prg to open the form for you so you can check each one). Put a copy of your forms in another directory and use those for test purposes. In the example below, I modify the activate of every form by adding 2 lines of code (just an example - maybe refresh or init or load could be modified):

THISFORM.Caption = gcCaption && assume this set in main.prg
DODEFAULT()
CLOSE ALL
CLEAR ALL
RELEASE ALL
CLEAR
ON ERROR DO errprg WITH ERROR()
SET SAFETY OFF
SET CONFIRM OFF

LOCAL lcnewvalue					&& line of code to add to the method
lcnewvalue = "THIS.CAPTION=gcCaption" +CHR(13)+"DODEFAULT()" +CHR(13)	&& Add this line to the end of the method
lcDefaultdir =  GETDIR() && point to the temporary directory of forms to modify
SET DEFAULT TO (lcDefaultdir)
? sys(2003)
?[Default set to:]+lcDefaultdir

=ADIR(myforms,'*.scx')		&& directory of forms
FOR i = 1 TO ALEN(myforms,1)			&& step through each form
	lcorgvalue = ''
	lcreplvalue = ''
	CLOSE ALL
	IF FILE(''+myforms(i,1))
		lcfile = ''+ LEFT(myforms(i,1),AT('.',myforms(i,1))-1)
		?lcfile
		TRY
			lccommand = "MODIFY FORM "+lcfile+" NOWAIT"	&& specify the form to modify
			?lccommand
			&lccommand
			TRY
				ASELOBJ(laform, 1)
				loform = laform(1)
				IF TYPE('loForm') = "O" .AND. !ISNULL(loform) .AND. ALLTRIM(UPPER(loform.BASECLASS)) = "FORM" ;
						.AND. UPPER(PEMSTATUS(loform,'ACTIVATE',3)) = "EVENT" ;
						.AND. UPPER(loform.NAME)<>"SCREEN"
					lcorgvalue = loform.READMETHOD('ACTIVATE')
					lcorgvalue = NVL(lcorgvalue,'')
					lcorgvalue = STRTRAN(lcorgvalue,[CHR(13)chr(13)],CHR(13))
					?lcorgvalue
					IF TYPE('lcORgValue') = "C" .and. LEN(lcORgvalue) < 255 .and. ! UPPER(ALLTRIM(lcReplValue)) $ UPPER(lcorgvalue)
						lcreplvalue = lcorgvalue+CHR(13)+ALLTRIM(lcnewvalue)+CHR(13)
						?lcreplvalue
						IF loform.WRITEMETHOD('ACTIVATE',lcreplvalue)
							lcnewvalue = loform.READMETHOD('ACTIVATE')
							? lcnewvalue + " ---->>>> ************* SUCCESS ****************"
							CLEAR TYPEAHEAD
							INKEY(.1)
							KEYBOARD '{CTRL+W}'
							KEYBOARD CHR(121)
							DOEVENTS
							IF LASTKEY() = 27
								EXIT
							ENDIF
						ELSE
							? "Error writing method to "+myforms(i,1)
						ENDIF
					ENDIF
				ELSE
					? myforms(i,1)+' form is not an object'
				ENDIF
			CATCH
				? 'Error accessing '+myforms(i,1)+' as a form'
			ENDTRY
		CATCH
			? ' Unable to modify '+myforms(i,1)
		ENDTRY
	ELSE
		? myforms(i,1)+ ' is not a file.'
	ENDIF
	IF LASTKEY() = 27
		EXIT
	ENDIF
ENDFOR
CLOSE ALL
CLEAR ALL
RETURN


PROCEDURE errprg
LPARAMETERS errnum
?"Error: "
??errnum
RETURN
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Previous
Reply
Map
View

Click here to load this message in the networking platform