FIX: setChecked Not Working on Context Menu

ID: Q223368


The information in this article applies to:


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 this to be a bug in the Microsoft products 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:

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

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


MORE INFORMATION

Steps to Reproduce Behavior

  1. Create a new Windows Application project, Project1, with Visual J++ 6.0.


  2. Add a WFC List View control, listView1, to the form.


  3. Select the items properties from listView1's Properties window and add two new items, listItem1 and listItem2.


  4. Add a WFC ContextMenu control, contextMenu1.


  5. Select the contextMenu property from the listView1 Properties window and associate it to contextMenu1.


  6. Double-click on contextMenu1 and one item, menuItem1.


  7. Continue by adding subitems menuItem2, named small, and menuItem3, named large.


  8. Double-click on menuItem2 and add the following function call to the Click function:


  9. 
    listView1.setView(ViewEnum.SMALLICON);	 
  10. Double-click on menuItem3 and add the following function call to the Click function:


  11. 
    listView1.setView(ViewEnum.LARGEICON);	 
  12. Add the following method:


  13. 
    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);
    } 
  14. Select contextMenu1 and, in the Properties window, select the events listing and associate the pop-up event with the contexMenuPopup method created above.


  15. Compile and run the sample.


  16. Right-mouse click on List View control and notice the "small" menu item is selected.


  17. Select the "large" menu item and close the context menu.


  18. Bring up the context menu again and notice that the "small" menu item is selected.


© Microsoft Corporation 1999, All Rights Reserved.
Contributions by Rafael M. Munoz, Microsoft Corporation


REFERENCES

For the latest Knowledge Base articles and other support information on Visual J++ and the SDK for Java, please see the following pages on the Microsoft Technical Support site:

http://support.microsoft.com/support/visualj/

http://support.microsoft.com/support/java/

Additional query words:


Keywords          : kbservicepack kbVJ600 kbVS600sp2 kbVS600SP1 kbVS600sp3fix 
Version           : WINDOWS:6.0
Platform          : WINDOWS 
Issue type        : kbbug 

Last Reviewed: May 20, 1999