The information in this article applies to:
- Microsoft Visual FoxPro for Windows, version 3.0
SUMMARY
After Creating a form with the Screen Wizard, you may want to change the
colors of text boxes and edit boxes. The colors displayed by the text boxes
can be changed by editing the backcolor, forecolor, disabledbackcolor, and
disabledforecolor properties on the property sheet. However, edit boxes are
not disabled and enabled by the edit button as are text boxes. The Readonly
property of the edit box is changed when the edit/revert or add/save
buttons are clicked.
MORE INFORMATION
Edit box colors can be changed by adding code to the Click events of the
add/save and edit/revert buttons as in the following example:
- Use the employee table, and build a wizard form using the last_name
field and the notes memo field.
- Add the following code to the Click event of the edit/revert button:
TXTBTNS.CMDEDIT::CLICK && scope resolution operator
&& to make sure Wizstyle.vcx code is executed
If !THISFORM.notes1.READONLY
THISFORM.notes1.FORECOLOR= THISFORM.last_name1.FORECOLOR
THISFORM.notes1.backcolor= THISFORM.last_name1.BACKCOLOR
ELSE
THISFORM.notes1.FORECOLOR= THISFORM.last_name1.DISABLEDFORECOLOR
THISFORM.notes1.BACKCOLOR= THISFORM.last_name1.DISABLEDBACKCOLOR
ENDIF
In this code, the edit box is called notes1 and the text box is called
last_name1.
- Place the same code in the add/save button. Replace cmdEdit with cmdAdd.
This code will allow the edit box colors to stay in sync with the text
box colors. Alternate colors may be used by specifying RGB colors in
the code instead of forecolor, backcolor, disabledforecolor, or
disabledbackcolor.
- If you changed the disabled colors of the text boxes in the Property
sheet, add the following two lines of code to the Init event of the
form:
THISFORM.notes1.FORECOLOR= THISFORM.last_name1.DISABLEDFORECOLOR
THISFORM.notes1.BACKCOLOR= THISFORM.last_name1.DISABLEDBACKCOLOR
|