BUG: Paint Problem Exists with Dynamically Generated Select Box in MFC CHTML View-Based Application (319992)



The information in this article applies to:

  • Microsoft Internet Explorer (Programming) 5.5 SP2
  • Microsoft Internet Explorer (Programming) 6.0

This article was previously published under Q319992

SYMPTOMS

If you dynamically change the text in a select box that is under another select box in a Microsoft Foundation Classes (MFC) hosted Web browser control by clicking the drop-down menu in the top select box, the bottom select box and the new text are not drawn correctly.

CAUSE

The drop-down menu that appears causes problems with the redrawing in an MFC application.

RESOLUTION

You can work around this problem if you arrange the two select boxes in such a manner that the drop-down menu does not cover the bottom select box.

You can also work around this problem if you delay the text change by using the setTimeout function call. The "More Information" section of this article shows you an example.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Create an MFC-hosted Web browser control application. For example, you can create the default Single Document Interface (SDI) MFC CHtmlView class in the application.
  2. Build the application. You do not have to make code changes.
  3. Create a test Hypertext Markup Language (.html) file that contains the following code. This sample has the workaround commented out. Test.htm
    <html>
    <head>
    <script language="javascript">
    function MyOnChange(e)
    {
    	// bug
    	ChangeOptionText();
    	
    	// workaround
    	// setTimeout("ChangeOptionText()", 1);
    	return;
    }
    
    function ChangeOptionText()
    {
    	select2.options[0].text = " Option 1b";
    }
    </script>
    </head>
    <body>
    <select id="select1" onchange="MyOnChange()">
    	<option>Option 1</option>
    	<option>Option 2</option>
    </select><br>
    <select id="select2">
    	<option>Option 1a</option>
    </select>
    </body>
    </html>
    					
  4. Run the MFC application and drag the Test.htm file to the View window of the MFC application. The page appears.
  5. In the top select box, click Option 2. This changes the text of the bottom select box and you can see the problem. This problem does not occur if you test the page in Internet Explorer.NOTE: You can change the test page to use the workaround if you comment the line under the comment "//bug", and then uncomment the line under "//workaround".

REFERENCES

For more information about developing Web-based solutions for Microsoft Internet Explorer, visit the following Microsoft Web sites:

Modification Type:MajorLast Reviewed:5/11/2006
Keywords:kbbug kbDHTML kbpending KB319992