FIX: Creating more than two MDI children throws WFCException

Article translations Article translations
Article ID: 223358 - View products that this article applies to.
This article has been archived. It is offered "as is" and will no longer be updated.
Expand all | Collapse all

On This Page

Symptoms

When creating more than two Multiple Document Interface (MDI) child windows in the constructor of the parent window, a WFCException is thrown with a message that an error has occurred creating a window handle.

Cause

This problem is related to the time at which the Win32 window handles are created, which may not be the same time the child window objects are created in Java code.

Resolution

To work around this problem, limit the number of child windows created in the constructor of the parent to two, and/or create child windows after the parent has been constructed. A third option is to use Control.invokeAsync() as illustrated in the commented code in the sample below.

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

More information

In WFC, handle creation for children of an MDI parent is deferred until the parent Form is made visible.

Steps to Reproduce Behavior

Compile and run the following code using an install of Visual Studio 6.0 that has not had Service Pack 3 applied:
import com.ms.wfc.app.*;
import com.ms.wfc.core.*;
import com.ms.wfc.ui.*;

public class Form1 extends Form
{
  public Form1()
  {
    initForm();		
    createKids();
  }
  
  protected void onCreateHandle(Event e)
  {
    super.onCreateHandle(e);
    //uncomment the following line for workaround
    //invokeAsync(new MethodInvoker(createKids));
  }
  
  public void createKids()
  {
    for (int i = 0; i < 3; i++)
    {
      Form f = new Form();
      f.setMDIParent(this);
      f.show();
    }
  }

  public void dispose()
  {
    super.dispose();
    components.dispose();
  }

  /**
   * NOTE: The following code is required by the Visual J++ form
   * designer. It can be modified using the form editor. Do not
   * modify it using the code editor.
   */ 
  Container components = new Container();

  private void initForm()
  {
    this.setText("Form1");
    this.setAutoScaleBaseSize(new Point(5, 13));
    this.setClientSize(new Point(292, 273));
    this.setIsMDIContainer(true);
  }

  public static void main(String args[])
  {
    Application.run(new Form1());
  }
}
				

References

For support information about Visual J++ and the SDK for Java, visit the following Microsoft Web site:
http://www.microsoft.com/java

Properties

Article ID: 223358 - Last Review: April 15, 2014 - Revision: 1.0
Applies to
  • Microsoft Visual J++ 6.0 Standard Edition
Keywords: 
kbnosurvey kbarchive kbbug kbctrlcreate kbfix kbvs600sp3fix kbwfc KB223358

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com