wxFileDialog and windows permissions

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
nroberts
Knows some wx things
Knows some wx things
Posts: 44
Joined: Fri Aug 03, 2007 8:07 pm

wxFileDialog and windows permissions

Post by nroberts » Tue Jul 07, 2009 8:55 pm

When I use the wxFileDialog to make a save dialog (using wxFileSelector) I have an inconsistency I want to resolve. When the user tries to save into a directory they have no write access to one of two things happens:

- if the file already exists they get a message box saying, "You do not have permission to save in this directory. See the administrator to obtain permission. Would you like to save in the My Documents folder instead?" Important thing to note here is that this is not my code and happens before the file dialog closes.

- if the file does not already exist then the file dialog closes and control is passed to my program, which tries to open the file for saving and tosses an exception that pops up a dialog saying it couldn't.

I would like both cases to match, one way or the other. I kind of prefer the former I think but at this point getting them to match either way would be a great benefit.

I tried asking in IRC but the only attempt to help I got didn't know what I was talking about apparently because they suggested using wxLogNull to solve the problem.

I've looked for flags to govern this behavior both in documentation and, hoping it was an undocumented feature, in the header files. Can't find it.

Anyone know how I can make them match? Here's where I create the dialog:

Code: Select all

      boost::filesystem::path doc_path = wxFileSelector(_("Select pipe system file"), wxT(""), wxT(""), wxT(".pipe"), _("Pipe system file (*.pipe)|*.pipe"), wxFD_SAVE|wxFD_OVERWRITE_PROMPT);

protocol
Moderator
Moderator
Posts: 680
Joined: Wed Jan 18, 2006 6:13 pm
Location: Dallas, TX
Contact:

Post by protocol » Wed Jul 08, 2009 5:22 am

The error message presented by the file selector is more than likely a native error message.

For the latter, catch the exception and present your own friendly error message.

regards.
/* UIKit && wxWidgets 2.8 && Cocoa && .Net */
QuRegExmm
wxPCRE & ObjPCRE - Regex It!

nroberts
Knows some wx things
Knows some wx things
Posts: 44
Joined: Fri Aug 03, 2007 8:07 pm

Post by nroberts » Wed Jul 08, 2009 4:20 pm

protocol wrote:The error message presented by the file selector is more than likely a native error message.

For the latter, catch the exception and present your own friendly error message.

regards.
Pretty sure you are correct, but other programs are consistent here. They will perform the first dialog in both cases.

Obviously I can do what you suggest but that is also obviously not the question. In fact as I explain, that's what I'm currently doing. The question is how do I get consistency here?

I can't catch the exception until after the dialog has closed and I've attempted to open the file. I can't seem to override the "Open" button by subclassing...

Post Reply