Microsoft SDK for Java

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

The information in this article applies to:

SYMPTOMS

If a class that extends the Window class is created with className LISTBOX and overrides wndProc and handles the WM_CREATE message, then Wjview.exe causes an unhanded exception on handle creation.

RESOLUTION

The Window with className LISTBOX must pass the WM_CREATE message on to defWndProc in order for the class to be created correctly.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Create a Java source WndTest.java:
    import com.ms.wfc.app.*;
       import com.ms.win32.*;
    public class WndTest extends Window
       {
         protected void wndProc(Message m)
          {
             switch (m.msg)
             {
               case winw.WM_CREATE:
                            break;
                default :
                   defWndProc(m);
                    break;
             }
          }
       }
  2. Create a Java source Form1.java:
    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 = "LISTBOX";
             cp.style = winw.WS_VISIBLE;
             WndTest w = new WndTest();
             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(112, 128));
            button1.setSize(new Point(75, 23));
            button1.setTabIndex(0);
            button1.setText("button1");
            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());
         }
       }
  3. Compile the Java source files.

  4. Run Form1.

  5. Click the button on the form. This will create a WndTest class with className LISTBOX and style WS_VISIBLE. The WndTest class overrides wndProc such that WM_CREATE is not passed on to defWndProc and everything else is. WJVIEW causes an unhandled exception.

REFERENCES

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/ This link takes you to a site on microsoft.com

http://support.microsoft.com/support/java/ This link takes you to a site on microsoft.com

© 1999 Microsoft Corporation. All rights reserved. Terms of use.