How to Change the Color of Edit Boxes on a Wizard Form

Last reviewed: December 19, 1995
Article ID: Q141317
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:

  1. Use the employee table, and build a wizard form using the last_name field and the notes memo field.

  2. 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.
    
    

  3. 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.

  4. 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


Additional reference words: 3.00 VFoxwin
KBCategory: kbtool kbhowto kbcode
KBSubcategory: FxtoolWizscreen


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: December 19, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.