Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

This article was previously published under Q319992

↑ Back to the top


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.

↑ Back to the top


Cause

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

↑ Back to the top


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.

↑ Back to the top


Status

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

↑ Back to the top


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".

↑ Back to the top


References

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

↑ Back to the top


Keywords: KB319992, kbpending, kbdhtml, kbbug

↑ Back to the top

Article Info
Article ID : 319992
Revision : 4
Created on : 5/18/2007
Published on : 5/18/2007
Exists online : False
Views : 433