BUG: getForeColor() Returns Color(0,0,0) for Bound Elements (196876)



The information in this article applies to:

  • Microsoft Visual J++ 6.0
  • Microsoft SDK for Java 3.1

This article was previously published under Q196876

SYMPTOMS

Black [Color(0,0,0)] is returned when you call getForeColor() on a bound element.

CAUSE

The Windows Foundation Classes (WFC) classes cannot retrieve the foreground color of an object until it is programmatically set.

RESOLUTION

Use the setForeColor() method to programmatically set the element's foreground color.

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce Behavior

  1. In Visual J++, select New Project from the File menu.
  2. In the New Project dialog box, click the New tab.
  3. In the Visual J++ Projects tree, click Web Pages.
  4. Click Code-Behind HTML.
  5. Click Open to create the project.
  6. Modify Class1.java as follows:
    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());
          }
       }
    }
    						
  7. Modify Page1.html as follows:
    <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>
    						
  8. Run the project.
RESULT: The following web page appears:

Testing... ForeColor:com.ms.wfc.ui.Color [0, 0, 0] ForeColor:com.ms.wfc.ui.Color [0, 0, 255]

REFERENCES

For support information about Visual J++ and the SDK for Java, visit the following Microsoft Web site:

Modification Type:MajorLast Reviewed:6/14/2006
Keywords:kbBug kbInetDev kbpending kbWFC KB196876