Microsoft KB Archive/223368

= FIX: setChecked Not Working on Context Menu =

Article ID: 223368

Article Last Modified on 6/14/2006

-

APPLIES TO


 * Microsoft Visual J++ 6.0 Standard Edition

-



This article was previously published under Q223368



SYMPTOMS
When displaying a context menu with submenu items on a control, such as the List View control, the setChecked method does not correctly display a check mark on the context menu's submenu item when a different item is selected.



CAUSE
The WM_INITMENUPOPUP message is not being correctly forwarded to a control's contextMenu.



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

This bug was corrected in Visual Studio 6.0 Service Pack 3. For more information about Visual Studio service packs, please see the following articles in the Microsoft Knowledge Base:

194022 INFO: Visual Studio 6.0 Service Packs, What, Where, Why

194295 HOWTO: Tell That Visual Studio 6.0 Service Packs Are Installed



Steps to Reproduce Behavior
 Create a new Windows Application project, Project1, with Visual J++ 6.0. Add a WFC List View control, listView1, to the form. Select the items properties from listView1's Properties window and add two new items, listItem1 and listItem2. Add a WFC ContextMenu control, contextMenu1. Select the contextMenu property from the listView1 Properties window and associate it to contextMenu1. Double-click on contextMenu1 and one item, menuItem1.</li> Continue by adding subitems menuItem2, named small, and menuItem3, named large.</li>  Double-click on menuItem2 and add the following function call to the Click function: listView1.setView(ViewEnum.SMALLICON); </li>  Double-click on menuItem3 and add the following function call to the Click function: listView1.setView(ViewEnum.LARGEICON); </li>  Add the following method: private void contextMenuPopup(Object source, Event e) { MenuItem currentItem = null; switch (listView1.getView) {     case ViewEnum.LARGEICON: currentItem = menuItem3; break;

case ViewEnum.SMALLICON: currentItem = menuItem2; break; }

menuItem2.setChecked(false); menuItem3.setChecked(false);

currentItem.setChecked(true); }                   </li> Select contextMenu1 and, in the Properties window, select the events listing and associate the pop-up event with the contexMenuPopup method created above.</li> Compile and run the sample.</li> Right-mouse click on List View control and notice the "small" menu item is selected.</li> Select the "large" menu item and close the context menu.</li> Bring up the context menu again and notice that the "small" menu item is selected.</li></ol>

<div class="references_section">