FIX: Calling Cursor.setPosition when using showDialog crashes NT

SYMPTOMS

When an application calls Cursor.setPosition in the constructor of a Form before handle creation and the Form is shown using showDialog, WinNT/SP3 or Win98 will lock up completely, requiring you to reboot the system.

RESOLUTION

You could work around the problem in the following ways:


  • Instead of using ShowDialog() use show() in the commented out code in the sample given below.
  • Add an onCreateHandle() event to the Form and call Cursor.setPosition() in the createhandle event code as shown in the commented out code 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

Steps to Reproduce Behavior

  1. Create a new Windows Application Project using VJ++ 6.0.
  2. In the Form's constructor, include the following:
    public Form1(){   super();   new Form2().showdlg(5000);   initForm();}
  3. Select Project.AddForm and Create another Form called Form2.java and add the following:
    import com.ms.wfc.app.*;import com.ms.wfc.core.*;import com.ms.wfc.ui.*;import com.ms.wfc.html.*;public class Form2 extends Form{   public Form2()   {      super();      initForm();          //WorkAround1:      //  uncomment the line below and comment out the next three lines      //addOnCreateHandle(new EventHandler(createHandle));      Rectangle r = getClientRect ();      Point p = new Point (r.x + r.width / 2, r.y + r.height / 2);      Cursor.setPosition (pointToScreen (p));   }   private void createHandle(Object source, Event e)   {      Rectangle r = getClientRect ();      Point p = new Point (r.x + r.width / 2, r.y + r.height / 2);      Cursor.setPosition (pointToScreen (p));   }   public void dispose()   {      super.dispose();      components.dispose();   }   public void showdlg(int time)   {      if(time>=0)         splashTimer.setInterval(time);      splashTimer.setEnabled(true);      //WORKAROUND2:      //   uncomment the line below and comment out the next line      //show();       this.showDialog();   }   private void splashTimer_timer(Object source, Event e)   {      splashTimer.setEnabled(false);      this.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();   Timer splashTimer = new Timer(components);   private void initForm()   {      this.setText("SplashScreen");      this.setAutoScale(false);      this.setAutoScaleBaseSize(new Point(5, 13));      this.setBorderStyle(FormBorderStyle.NONE);      this.setClientSize(new Point(418, 298));      this.setControlBox(false);      this.setShowInTaskbar(false);      this.setStartPosition(FormStartPosition.CENTER_SCREEN);      this.setTopMost(true);      splashTimer.setInterval(2500);      splashTimer.addOnTimer(new EventHandler(this.splashTimer_timer));      /* @designTimeOnly splashTimer.setLocation(new Point(324, 200)); */       this.setNewControls(new Control[] {});   }   /**    * 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 Form2());   }}
  4. Build and run the Project. You will notice that the application locks up the system at the point when the form is being displayed during the showDialog call.

REFERENCES

For support information about Visual J++ and the SDK for Java, visit the following Microsoft Web site:
Svojstva

ID članka: 223341 - posljednja izmjena: 14. velj 2017. - verzija: 1

Microsoft Visual J++ 6.0 Standard Edition

Povratne informacije