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
The drop-down menu that appears causes problems with the redrawing in an MFC application.
↑ Back to the top
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
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
Steps to Reproduce the Behavior
- 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.
- Build the application. You do not have to make code changes.
- 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>
- Run the MFC application and drag the Test.htm file to the View window of the MFC application. The page appears.
- 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
For more information about developing Web-based solutions for Microsoft Internet Explorer, visit the following Microsoft Web sites:
↑ Back to the top