Microsoft KB Archive/147307

= PRB: Cannot Generically Set DisabledForeColor on Some Objects =

Article ID: 147307

Article Last Modified on 9/30/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition

-



This article was previously published under Q147307



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.



Combo Box Objects
 Set the Style property of the combo box to 0-Dropdown Combo.  Set the DisabledForeColor property of the ComboBox to: =THIS.FORECOLOR   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
 When you disable objects on the form, do not disable any check boxes. 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.  In the GotFocus and MouseUp events of the check box(es), place the following code: IF !THISFORM.IsEnabled NODEFAULT ENDIF </li></ol>

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.

<div class="status_section">

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

<div class="moreinformation_section">

Steps to Reproduce Behavior
 Create a new form, and place a combo box and check box on the form.</li> 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"</li> Set the DisabledForeColor property of both the combo box and the check box to =This.ForeColor.</li>  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 </li> 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.</li></ol>

Additional query words: VFoxWin

Keywords: KB147307

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.