Microsoft KB Archive/195527

= BUG: Protection Fault with Reserved System WNDCLASS Names =

Article ID: 195527

Article Last Modified on 3/7/2005

-

APPLIES TO


 * Microsoft Visual J++ 6.0 Standard Edition
 * Microsoft Software Development Kit for Java 3.1
 * Microsoft Software Development Kit for Java 3.2

-



This article was previously published under Q195527



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 that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce Behavior
 Compile and run the following code. Click the button.  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); }

} 

