DOC: MSDN Sample - Creating Composite WFC Controls

ID: Q216813


The information in this article applies to:
  • Microsoft Visual J++, version 6.0


SUMMARY

The MSDN sample that demonstrates how to create a composite WFC control using Visual J++ is incorrect. The MessageBox that is added to the code in the final "Debugging the Control" step is not displayed.


MORE INFORMATION

To find the article in MSDN, follow this path on the Contents tab:

MSDN Library Visual Studio 6.0\Visual J++ Documentation\Using Visual J++\Programmer's Guide\WFC Control Development\Creating Composite WFC Controls
The article takes you through the steps to create a composite WFC control. When complete, the control seems to work correctly in the designer and at runtime, but the MessageBox in the final "Debugging the Control" step is never displayed (events are not caught as expected).

NOTE: In the following text, onCheckChanged is the method you add to the composite control and onCheckedChanged is the EventHandler already in the CheckBox control.

The problem is that the onCheckChanged( ) method is never called, so you need to do a bit of extra work that is not included in the MSDN sample. You need to add an EventHandler for the CheckBox's onCheckedChanged( ) event by adding the following line after the call to initForm( ) in the composite control's constructor:

checkBox1.addOnCheckedChanged(new EventHandler(this.onCheckChanged)); 
Unfortunately, the composite control's onCheckChanged( ) method does not fit the required EventHandler prototype. Following is the modified onCheckChanged( ) method:

protected void onCheckChanged(Object source,Event event){
    if(m_CheckChanged != null) m_CheckChanged.invoke(source, event);
} 
The setChecked( ) method in the composite control also has a reference to onCheckChanged( ) that you need to change. Following is the corrected setChecked( ) method:

public void setChecked(boolean value){
    checkBox1.setChecked(value);
    onCheckChanged(this,Event.EMPTY);
    enableControls(this, value);
} 
Now the sample should work as described in the article.

© Microsoft Corporation 1999, All Rights Reserved.
Contributions by Joseph B. Hall, Microsoft Corporation

Additional query words: Composite Control WFC Multicast Delegate

Keywords : kbdocerr kbCtrlCreate kbJava kbVJ600 kbGrpJava
Version : WINDOWS:6.0
Platform : WINDOWS
Issue type : kbbug


Last Reviewed: March 2, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.