FIX: Calling Cursor.setPosition When Using showDialog Crashes NT
ID: Q223341
|
The information in this article applies to:
-
Microsoft Visual J++, version 6.0
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 this to be a bug in the Microsoft products 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:
Q194022 INFO: Visual Studio 6.0 Service Packs, What, Where, Why
Q194295 HOWTO: Tell That Visual Studio 6.0 Service Packs Are Installed
MORE INFORMATION
Steps to Reproduce Behavior
- Create a new Windows Application Project using VJ++ 6.0.
- In the Form's constructor, include the following:
public Form1()
{
super();
new Form2().showdlg(5000);
initForm();
}
- 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());
}
}
- 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 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/
http://support.microsoft.com/support/java/
Additional query words:
Keywords : kbservicepack kbVJ600 kbVJ600bug kbGrpJava kbVS600sp2 kbVS600SP1 kbVS600sp3fix
Version : WINDOWS:6.0
Platform : WINDOWS
Issue type : kbbug