Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Object reference?
Message
From
17/02/2016 10:56:47
 
 
To
17/02/2016 10:45:43
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 7
OS:
Windows 7
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01631578
Message ID:
01631606
Views:
68
Congratulations!
If all your labels are in the same container, you can write code that don't depend on their names (more robust, you can add-remove labels without modifying the code):
procedure yourLabelClass.click
local oLbl as yourLabelClass
for each oLbl in this.Parent.Controls foxobject
  if m.oLbl.class == this.class
    m.oLbl.ForeColor = iif(m.oLbl = this, RGB(255,0,0), RGB(0,0,0))
    m.oLbl.Underline = m.oLbl = this
  endif
endfor
>I made a label class for menu options (you can make them so much more attractive that command buttons!), with the look I wanted. I then added how many I needed to the form (9 of them). The class name is 'DeMenuBut'. In the form designer, they are DeMenuBut1 thru 9. To change their appearance, signalling to the user which has been clicked, and which haven't, I run the code below, and it sets all the 'menu buttons' properties correctly.
>
>I made a variable to store the name of the object called MenButton, so when any menu button is clicked, it passes it's name to the routine below - the clicked button caption becomes red and underlined, and all the other captions are black, and not underlined. It works beautifully!
>
>
>cnt=0
>FOR cnt = 1 TO 9
>	ObjForecolor='.DeMenuBut'+ALLTRIM(STR(cnt))+'.ForeColor'
>	ObjFontUnderline='.DeMenuBut'+ALLTRIM(STR(cnt))+'.FontUnderline'
>
>	ThisObj='DeMenuBut'+ALLTRIM(STR(cnt))
>	IF ThisObj#MenButton
>		WITH this
>			&ObjForecolor=RGB(0,0,0)
>			&ObjFontUnderline=.f.
>		ENDWITH 
>	ELSE
>		WITH this
>			&ObjForecolor=RGB(255,0,0)
>			&ObjFontUnderline=.t.
>		ENDWITH
>	ENDIF
>NEXT 
>
Thierry Nivelet
FoxinCloud
Give your VFP application a second life, web-based, in YOUR cloud
http://foxincloud.com/
Never explain, never complain (Queen Elizabeth II)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform