Article ID: 129207
Article Last Modified on 8/3/2000
This.&cOButton..Caption="Button"-cOldbNo && Originally used one period This.&cOButton..Picture='' *** ... This.&cButton..Caption="" && These lines are farther This.&cButton..Picture='c:\vfp\fox.bmp' && down in the exampleNOTE: Macro substitution can usually be replaced by the superior EVALUATE() function, but using EVALUATE() requires an additional line of code. In this example, program execution is faster and the amount of executable code generated by the compiler/linker is smaller. For example:
This.&cOButton..Picture=''Use:
oRef=EVAL("THIS."+cOButton)
oRef.Picture=''
oMyForm = CREATEOBJECT("MyForm")
oMyForm.show
READ EVENTS
DEFINE CLASS MyForm AS FORM
nCurrentb=1
ADD OBJECT Button1 AS COMMANDBUTTON WITH ;
top=1,left=1,height=2,width=10,caption="",picture='c:\vfp\fox.bmp'
ADD OBJECT Button2 AS COMMANDBUTTON WITH ;
top=7,left=1,height=2,width=10
ADD OBJECT Button3 AS COMMANDBUTTON WITH ;
top=13,left=1,height=2,width=10
PROCEDURE Button1.Click
This.Parent.ChangeProp(1)
ENDPROC
PROCEDURE Button2.Click
This.Parent.ChangeProp(2)
ENDPROC
PROCEDURE Button3.Click
This.Parent.ChangeProp(3)
ENDPROC
PROCEDURE ChangeProp
PARAMETERS nNewbutton
cOldbNo=''
cNewbNo=''
cOButton=''
cButton=''
* Clear .bmp on old button
cOldbNo=ALLTRIM(STR(This.nCurrentb))
cOButton="Button"-cOldbNo
This.&cOButton.Caption="Button"-cOldbNo && WILL NOT WORK
This.&cOButton.Picture='' && WILL NOT WORK
* Display .bmp on new button
cNewbNo=ALLTRIM(STR(nNewbutton))
cButton="Button"-cNewbNo
This.&cButton.Caption="" && WILL NOT WORK
This.&cButton.Picture='c:\vfp\fox.bmp' && WILL NOT WORK
This.nCurrentb=nNewbutton
ENDPROC
ENDDEFINE
Additional query words: VFoxWin 3.00 akz
Keywords: kberrmsg KB129207