PRB: Cannot Generically Set DisabledForeColor on Some Objects

ID: Q147307

3.00 3.00b WINDOWS kbtool kbprb

The information in this article applies to:

  • Microsoft Visual FoxPro for Windows, versions 3.0 and 3.0b

SYMPTOMS

It is possible to set the DisabledForeColor of some objects generically, rather than using an explicit value. One way to do so is to set the DisabledForeColor property to =This.ForeColor to make the DisabledForeColor of most objects identical to the current ForeColor. However, this has no effect on check boxes or on combo boxes that have a Style property of 2-DropDown List.

WORKAROUND

Combo Box Objects

1. Set the Style property of the combo box to 0-Dropdown Combo.

2. Set the DisabledForeColor property of the ComboBox to:

   =THIS.FORECOLOR

3. To make the combo box behave as if its Style property were 2-Dropdown
   List while enabled, place the following code in the KeyPress Event of
   the combo box:

   NODEFAULT

Now the combo box will behave as if its Style property were 2-Dropdown List with a DisabledForeColor identical to the ForeColor.

Check Box Objects

1. When you disable objects on the form, do not disable any check boxes.

2. Create a Custom property of the form to indicate whether objects are

   enabled or disabled that is called, for example, IsEnabled. Set this
   property to false (.F.) if the objects are to be initially disabled or
   true (.T.) if the objects are to be initially enabled.

3. In the GotFocus and MouseUp events of the check box(es), place the
   following code:

   IF !THISFORM.IsEnabled
        NODEFAULT
   ENDIF

Now the check box always has the same ForeColor but can be disabled by changing a custom property on the form such as IsEnabled to false.

STATUS

Microsoft is researching this behavior and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Steps to Reproduce Behavior

1. Create a new form, and place a combo box and check box on the form.

2. Set the combo box Style property to 2-Dropdown List, the RowSourceType

   property to 1-Value, and the RowSource property to "One, Two, Three,
   Four, Five"

4. Set the DisabledForeColor property of both the combo box and the check
   box to =This.ForeColor.

5. Place a command button on the form. Give it a caption of Disable, and
   place the following code in its Click event:

   WITH THISFORM
        .combo1.ENABLED =.f.
        .check1.ENABLED =.f.
   ENDWITH
   THISFORM.REFRESH

6. Run the form, click the combo box, and choose an item from the list.
   Click the Disable button. Note that the check box and the combo box text
   is not the same as the ForeColor when these objects are enabled.

Additional reference words: 3.00 3.00b VFoxWin KBCategory: kbtool kbprb KBSubcategory: FxtoolFormdes
Keywords          : FxtoolFormdes 
Version           : 3.00 3.00b
Platform          : WINDOWS


Last Reviewed: February 24, 1996
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.