Microsoft KB Archive/216813

= DOC: MSDN Sample - Creating Composite WFC Controls =

Article ID: 216813

Article Last Modified on 3/4/1999

-

APPLIES TO


 * Microsoft Visual J++ 6.0 Standard Edition

-



This article was previously published under Q216813



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.

Additional query words: Composite Control WFC Multicast Delegate

Keywords: kbbug kbfix kbjava kbctrlcreate kbdocerr KB216813

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.