| FIX: WFC ActiveX Controls Do Not Fire Custom Events in VBID: Q223362 
 | 
When creating an ActiveX control using WFC, custom events are not fired in the target/client application.
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
Private Sub MyControl1_errorEvent(ByVal Parameter0 As Object, ByVal Parameter1 As Object)
End Sub 
Private Sub Form_Load()
MyControl1.myProp = 201
End Sub 
 // MyControl.java
import com.ms.wfc.ui.* ;
import com.ms.wfc.core.* ;
import com.ms.lang.Delegate;
/**
 * @com.register ( clsid=428B4065-E8B5-11D2-A801-00C04FB624C0, typelib=428B4064-E8B5-11D2-A801-00C04FB624C0 )
 */ 
public class MyControl extends Control 
{
  private int myProp = 1;
  public int getMyProp()
  {
    return myProp;
  }
  public void setMyProp(int value)
  {
    // Fires error event if property value exceeds 200
    if(value > 200)
    {
      onErrorEvent(new ErrorEvent(1020, "Invalid value"));
    }
    myProp = value;
  }
  protected void onPaint( PaintEvent p)
  {
    super.onPaint(p);
    Graphics g=p.graphics;
    g.drawString( getText(), 0, 0);
  }
  // event setup to be able to fire event "ErrorEvent"
  private ErrorEventHandler errDelegate = null;
  public final void addOnErrorEvent(ErrorEventHandler handler)
  {
    errDelegate = (ErrorEventHandler)Delegate.combine(errDelegate,
                                                      handler);
  }
  public final void removeOnErrorEvent(ErrorEventHandler handler)
  {
    errDelegate = (ErrorEventHandler)Delegate.remove(errDelegate,
                                                     handler);   
  }
  protected void onErrorEvent(ErrorEvent event)
  {
    if(errDelegate != null)
    {
      errDelegate.invoke(this, event);
    }   
  }
  
  public static class ClassInfo extends Control.ClassInfo
  {
    public static final PropertyInfo myProp = new 
                                              PropertyInfo(MyControl.class, "myProp", int.class);
    public void getProperties(IProperties props)
    {
      super.getProperties(props);
      props.add(myProp);
    }
    
    public static EventInfo evt = new EventInfo(MyControl.class, 
                                                "errorEvent", ErrorEventHandler.class);
    public void getEvents(IEvents events)
    {
      super.getEvents(events);
      events.add(evt);
    }
  }
}
// ErrorEventHandler.java
import com.ms.wfc.core.*;
public final multicast delegate void ErrorEventHandler(Object sender, 
  ErrorEvent event)
;
// ErrorEvent.java
import com.ms.wfc.core.*;
public class ErrorEvent extends Event
{
  public final int errorNumber;
  public final String errorText;
  public ErrorEvent( int eNum, String eTxt)
  {
    this.errorNumber = eNum;
    this.errorText   = eTxt;
  }
} 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/
© Microsoft Corporation 1999, All Rights Reserved.
Contributions by Robert LaCasse, Microsoft Corporation
Additional query words:
Keywords          : kbservicepack kbCOMt kbCtrlCreate kbJava kbJavaVM kbSDKJava kbVJ600bug kbGrpJava kbVS600sp2 kbVS600SP1 kbVS600sp3fix 
Version           : WINDOWS:3.1,6.0
Platform          : WINDOWS 
Issue type        : kbbug Last Reviewed: July 13, 1999