Can't make SaveFileDialog.Filter work

G

Guest

When I set a Filter on my SaveFileDialog, the dialog box comes up correctly. However, if I change value of the "Save As Type" drop-down, all files and directories are removed from the dialog box, even those that match the specification. The main part of the dialog box where files and directories are normally displayed is just an empty white rectangle. The only way to get file names back is to type in a filename containing a wildcard and click OK.

I see this exact problem reported in the thread:
http://groups.google.com/groups?hl=...&selm=%23JMQe7bmCHA.2828%40tkmsftngp04&rnum=3

When I tried the identical code in the 3rd post of the above thread, whose author couldn't reproduce the problem, the problem still happened to me.

I then created a new project which just opened a SaveFileDialog box and nothing else, and the problem didn't occur! So there has to be something that is going on in my code prior to bringing up the SaveFileDialog that breaks it. Any idea what this could be? I am coding in Managed C++, and the test code is:

SaveFileDialog* sfd = new SaveFileDialog();
sfd->Filter=S"Text files (*.txt)|*.txt|All files (*.*)|*.*";
sfd->FilterIndex=1;
sfd->DefaultExt=S"txt";
sfd->ShowDialog();

Since it is a over a year since the above-referenced post, I am hoping that someone else has gained some insight into this problem. In the mean time I'll start reorganizing my code to see if I can figure out what sets it off...

Thanks...

Dave
 
G

Guest

OK I found what sets off this problem. It sure looks like a bug to me. Here's the recepie to make it
happen in VC++.NET 2003 Standard Edition. Can someone who has C# or VB try it

1) Create a new Project that is a Windows Forms application
2) From the Toolbox, drag a MainMenu onto the form
3) Enter "Dialog" as the upper-left menu name
4) Double click on "Dialog" to bring up the code
5) Enter the following code into function menuItem1_Clic
SaveFileDialog* sfd = new SaveFileDialog()
sfd->Filter=S"Text files (*.txt)|*.txt|All files (*.*)|*.*"
sfd->FilterIndex=1
sfd->DefaultExt=S"txt"
sfd->ShowDialog()
6) Copy a bitmap file into the project directory. Right click on project name. Select Add/Add Existing Item
and add the bitmap file to the project. It will show up under "Resource Files"
7) From the Toolbox, drag an ImageList onto the form
8) In the Properties window, click on the ImageList's Images property (Collection)..
9) add the bitmap file from step 6 to the collectio

Compile and run the program. Click on the Dialog menu. Change the value of the "Save as type"
dropdown and observe the dialog box blank out

If you delete the .bmp file added in step 9 from the ImageList's Images collection, the dialog box works correctly

I've tried this with 2 bitmap files
1) 24x23 8-color
2) 23x18 monochrom
Both files were created with Adobe Photoshop

Can anyone confirm this bug and/or suggest a workaound? I really want to use a toolbar with .bmp image
in an ImageList in my form

If anyone from MS would like me to email them my project, I would be happy to

Thanks for the help

Dav
----- Dave wrote: ----

When I set a Filter on my SaveFileDialog, the dialog box comes up correctly. However, if I change value of the "Save As Type" drop-down, all files and directories are removed from the dialog box, even those that match the specification. The main part of the dialog box where files and directories are normally displayed is just an empty white rectangle. The only way to get file names back is to type in a filename containing a wildcard and click OK

I see this exact problem reported in the thread
http://groups.google.com/groups?hl=...8&selm=%23JMQe7bmCHA.2828%40tkmsftngp04&rnum=

When I tried the identical code in the 3rd post of the above thread, whose author couldn't reproduce the problem, the problem still happened to me

I then created a new project which just opened a SaveFileDialog box and nothing else, and the problem didn't occur! So there has to be something that is going on in my code prior to bringing up the SaveFileDialog that breaks it. Any idea what this could be? I am coding in Managed C++, and the test code is

SaveFileDialog* sfd = new SaveFileDialog()
sfd->Filter=S"Text files (*.txt)|*.txt|All files (*.*)|*.*"
sfd->FilterIndex=1
sfd->DefaultExt=S"txt"
sfd->ShowDialog()

Since it is a over a year since the above-referenced post, I am hoping that someone else has gained some insight into this problem. In the mean time I'll start reorganizing my code to see if I can figure out what sets it off..

Thanks..

Dave
 
G

Guest

After fighting with this all day, I have some additional info

1) The simple example given in my 2nd post of this thread no longer reproduces the problem. It appears
I have to cause the problem in my full app before the simple example breaks. Sigh...

2) The problem is still readily reproducible in my full app. It appears to be caused by passin
a bitmap resource to ImageList.Images

3) The problem breaks OpenFileDialog as well as SaveFileDialog

4) If I create the Bitmap at runtime from a file, using the code
imageList.Images.Add(new Bitmap(fileName))
the problem goes away. This is my workaround for the moment

5) I used ResXGen/ResXResourceWriter to convert my bitmap file to a ResX file, added that resX fil
to my project, and retrieved it in my code using ResourceManager. The problem still occured

6) I added the bitmap file to my project as a Win32 resource, retrieved it using Win32 API LoadBitmap
and converted it to a .NET bitmap with Image.FromHbitmap. The problem still occurred

For now I am giving up and sticking with #4. If anyone else has any insight into this problem,
please post or email me directly at dave(don't_spam_me)@altosdesign.com

Thanks..

Dave Laske

----- Dave wrote: ----

OK I found what sets off this problem. It sure looks like a bug to me. Here's the recepie to make it
happen in VC++.NET 2003 Standard Edition. Can someone who has C# or VB try it

1) Create a new Project that is a Windows Forms application
2) From the Toolbox, drag a MainMenu onto the form
3) Enter "Dialog" as the upper-left menu name
4) Double click on "Dialog" to bring up the code
5) Enter the following code into function menuItem1_Clic
SaveFileDialog* sfd = new SaveFileDialog()
sfd->Filter=S"Text files (*.txt)|*.txt|All files (*.*)|*.*"
sfd->FilterIndex=1
sfd->DefaultExt=S"txt"
sfd->ShowDialog()
6) Copy a bitmap file into the project directory. Right click on project name. Select Add/Add Existing Item
and add the bitmap file to the project. It will show up under "Resource Files"
7) From the Toolbox, drag an ImageList onto the form
8) In the Properties window, click on the ImageList's Images property (Collection)..
9) add the bitmap file from step 6 to the collectio

Compile and run the program. Click on the Dialog menu. Change the value of the "Save as type"
dropdown and observe the dialog box blank out

If you delete the .bmp file added in step 9 from the ImageList's Images collection, the dialog box works correctly

I've tried this with 2 bitmap files
1) 24x23 8-color
2) 23x18 monochrom
Both files were created with Adobe Photoshop

Can anyone confirm this bug and/or suggest a workaound? I really want to use a toolbar with .bmp image
in an ImageList in my form

If anyone from MS would like me to email them my project, I would be happy to

Thanks for the help

Dav
----- Dave wrote: ----

When I set a Filter on my SaveFileDialog, the dialog box comes up correctly. However, if I change value of the "Save As Type" drop-down, all files and directories are removed from the dialog box, even those that match the specification. The main part of the dialog box where files and directories are normally displayed is just an empty white rectangle. The only way to get file names back is to type in a filename containing a wildcard and click OK

I see this exact problem reported in the thread
http://groups.google.com/groups?hl=...8&selm=%23JMQe7bmCHA.2828%40tkmsftngp04&rnum=

When I tried the identical code in the 3rd post of the above thread, whose author couldn't reproduce the problem, the problem still happened to me

I then created a new project which just opened a SaveFileDialog box and nothing else, and the problem didn't occur! So there has to be something that is going on in my code prior to bringing up the SaveFileDialog that breaks it. Any idea what this could be? I am coding in Managed C++, and the test code is:

SaveFileDialog* sfd = new SaveFileDialog();
sfd->Filter=S"Text files (*.txt)|*.txt|All files (*.*)|*.*";
sfd->FilterIndex=1;
sfd->DefaultExt=S"txt";
sfd->ShowDialog();

Since it is a over a year since the above-referenced post, I am hoping that someone else has gained some insight into this problem. In the mean time I'll start reorganizing my code to see if I can figure out what sets it off...

Thanks...

Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top