BUG: Protection Fault with Reserved System WNDCLASS Names

ID: Q195527


The information in this article applies to:
  • Microsoft Visual J++, version 6.0
  • Microsoft SDK for Java, versions 3.1, 3.2


SYMPTOMS

When sub-classing a pre-defined Win32 Window class by calling CreateHandle(CreateParams) in Windows Foundation Classes (WFC), certain reserved system Window classes may cause one of the following error messages. This occurs if the param field of CreateParams is not set correctly or the WM_CREATE message is not passed on to defWndProc or if other particulars are not met that are similarly required when sub-classing pre-defined system window classes in traditional windows programming:

Access violation, General Protection Fault, or java.lang.UnknownError: Exception 0xc0000005 occurred in native code at 0x77e83564


RESOLUTION

Rather than sub-classing in this manner, extend the WFC Java class that corresponds to the reserved system Window class that you want to sub-class. Or, be sure that the required windows protocols are followed when sub- classing with createHandle(), such as passing WM_CREATE on to defWndProc or setting the CreateParam.param member to either null or to refer to an instance of the required STRUCT declared with the @dll.struct compiler directive as described in the WFC createHandle() documentation.


STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.


MORE INFORMATION

Steps to Reproduce Behavior

  1. Compile and run the following code.


  2. Click the button.


  3. This will be followed by a dialog box saying an exception or illegal operation has occurred. For example: java.lang.UnknownError: Exception 0xc0000005 occurred in native code at 0xSomeAddr.
    
    import com.ms.wfc.app.*;
    import com.ms.wfc.core.*;
    import com.ms.wfc.ui.*;
    import com.ms.wfc.html.*;
    import com.ms.win32.*;
    
    /**
     * This class can take a variable number of parameters on the command
     * line. Program execution begins with the main() method. The class
     * constructor is not invoked unless an object of type 'Form1' is
     * created in the main() method.
     */ 
    public class Form1 extends Form
    {
       public Form1()
       {
          // Required for Visual J++ Form Designer support
          initForm();
    
          // TODO: Add any constructor code after initForm call
       }
    
       /**
        * Form1 overrides dispose so it can clean up the
        * component list.
        */ 
       public void dispose()
       {
          super.dispose();
          components.dispose();
       }
    
       private void button1_click(Object source, Event e)
       {
          CreateParams cp = new CreateParams();
          cp.className = "MDICLIENT";
    
          // Uncomment this next line to correct the problem
          // cp.param = new CLIENTCREATESTRUCT(0, 1);
    
          Window w = new Window();
          w.createHandle(cp);
       }
    
       /**
        * 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();
       Button button1 = new Button();
    
       private void initForm()
       {
          this.setText("Form1");
          this.setAutoScaleBaseSize(new Point(5, 13));
          this.setClientSize(new Point(292, 273));
    
          button1.setLocation(new Point(56, 72));
          button1.setSize(new Point(168, 80));
          button1.setTabIndex(0);
    
          button1.setText("Create MDIClient Window Class");
          button1.addOnClick(new EventHandler(this.button1_click));
    
          this.setNewControls(new Control[] {
                              button1});
       }
    
       /**
        * The main entry point for the application.
        *
        * @param args Array of parameters passed to the application
        * via the command line.
        */ 
       public static void main(String args[])
       {
          Application.run(new Form1());
       }
    
    } 



REFERENCES

For additional information about getting an Unhandled Exception when using a system classname such as LISTBOX, please see the following article in the Microsoft Knowledge Base:

Q195160 PRB: Wjview.exe Causes Unhandled Exception on Handle Creation

© Microsoft Corporation 1999, All Rights Reserved.
Contributions by Robert LaCasse, Microsoft Corporation

Additional query words:

Keywords : kbVJ600bug kbSDKJava310 kbwfcui kbSDKJava320bug
Version : WINDOWS:3.1,6.0
Platform : WINDOWS
Issue type : kbbug


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