BUG: getForeColor() Returns Color(0,0,0) for Bound ElementsID: Q196876
|
Black [Color(0,0,0)] is returned when you call getForeColor() on a bound element.
The Windows Foundation Classes (WFC) classes cannot retrieve the foreground color of an object until it is programmatically set.
Use the setForeColor() method to programmatically set the element's foreground color.
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.
import com.ms.wfc.html.*;
import com.ms.wfc.core.*;
import com.ms.wfc.ui.*;
public class Class1 extends DhDocument
{
public Class1()
{
initForm();
}
private void initForm() {
}
protected void onDocumentLoad(Object sender, Event event)
{
DhElement el = this.findElement("coloredText");
try
{
this.newLine();
this.addText("ForeColor:"+el.getForeColor().toString());
}
catch(Exception e1)
{
this.newLine();
this.addText(e.toString());
}
try
{
el.setForeColor(Color.BLUE);
this.newLine();
this.addText("ForeColor:"+el.getForeColor().toString());
}
catch(Exception e2)
{
this.newLine();
this.addText(e.toString());
}
}
}
<HTML>
<BODY>
<hr>
<OBJECT classid="java:com.ms.wfc.html.DhModule"
height=0 width=0 ... VIEWASTEXT>
<PARAM NAME=__CODECLASS VALUE=Class1>
<PARAM NAME=CABBASE VALUE=Project1.CAB>
</OBJECT>
<!-- Insert HTML here -->
<FONT color=BLUE>
<SPAN id="coloredText">Testing...</SPAN>
</FONT>
</BODY>
</HTML>
Testing... ForeColor:com.ms.wfc.ui.Color [0, 0, 0] ForeColor:com.ms.wfc.ui.Color [0, 0, 255]
For the latest Knowledge Base articles and other support information on Visual J++ and the SDK for Java,
please see the following pages on the Microsoft Technical Support site:
http://support.microsoft.com/support/visualj/
http://support.microsoft.com/support/java/
© Microsoft Corporation 1998, All Rights Reserved.
Contributions by Derek Jamison, Microsoft Corporation
Additional query words:
Keywords : kbVJ600bug kbInetDev kbwfchtml
Version : WINDOWS:3.1,6.0
Platform : WINDOWS
Issue type : kbbug
Last Reviewed: April 8, 1999