Microsoft SDK for Java

Q194772 BUG: SaveFileDialog.showDialog() Fails at Head of Empty if Block

The information in this article applies to:

SYMPTOMS

The Save File dialog box does not appear when a SaveFileDialog.showDialog call is placed in the conditional expression of an if statement that is followed by an empty if code block.

RESOLUTION

Place a line of code such as the following in the if block or following the if statement:

if(...)
   int localint = 0;
-or-
if(...) {
   int localint = 0;
}

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 Microsoft virtual machines 3165 and later.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Save and compile the following code.

  2. Uncomment int localint = 0; to see the Save File dialog box.

  3. Leave int localint = 0; commented to reproduce the behavior.
    import com.ms.wfc.ui.*;
    import com.ms.win32.*;
    public class SFDialogTest
    {
    public static void main(String args[]) {
    SaveFileDialog sfd = new SaveFileDialog();
         if (sfd.showDialog() == DialogResult.OK) {
         //int localint = 0;
         }
        String message = "SaveFileDialog should have been shown by now.";
        message += "\r\n";
        message += "If not, Uncomment the \"int localint = 0;\" line ";
        message += "to make it work.";
        User32.MessageBox(0,
        message,
        "Message Box",
        MessageBox.OK);
       }
    }

REFERENCES

For additional information regarding Microsoft® Visual J++® 6.0, visit the following Web site:

http://msdn.microsoft.com/visualj/ This link takes you to a site on microsoft.com

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