Opening a wxFileDialog from within a wxDialog
BlitzMax Forums/Brucey's Modules/Opening a wxFileDialog from within a wxDialog
| ||
I'm trying to get a wxFileDialog to open in response to a button click within a modal wxDialog. In OSX, the code below seems to work, although the wxDialogs need to be wxSTAY_ON_TOP for some reason. But in XP and Vista, I can't get it to work at all. Any help/ideas really, really appreciated :-) Code below opens a test file dialog. Then, in response to both dialog's button clicks, another file dialog should open . |
| ||
You might find this thread quite interesting : http://groups.google.com/group/comp.soft-sys.wxwindows/browse_thread/thread/1a11027b13a41fcb/176bf086fd1ce389?lnk=raot Specifically the very long post from April 16. |
| ||
Hey Brucey :-) Mmmm thanks for this - but I'm not sure what to make of it all I confess... It seems to be saying that I can fix the wxSTAY_ON_TOP issue with OSX modal dialogs by performing the equivalent of: OSStatus err = ChangeWindowAttributes((WindowRef)m_macWindow, kWindowHideOnSuspendAttribute, 0); Trouble is a) I don't know how to do this in wxMax (I can't find a ChangeWindowAttributes() Method?) and b) My issue in this instance is actually regarding Win32 rather than OS X, which seemed to be what the linked thread was all about. Simply put - still stuck! :-) |
| ||
Hang on - this is interesting... bordering on amusing. Wrapping the wxFileDialog within a wxDialog seems to circumvent the issue! ieType TDummyFileDialog Extends wxDialog Field FileDialog:wxFileDialog Method OnInit() ' Open up a file requester FileDialog = New wxFileDialog.Create(Self, "File dialog 1: Parent is the wxFrame",Null,Null, "*.*", wxFD_OPEN|wxFD_DEFAULT_STYLE) If FileDialog.ShowModal() <> wxID_OK Then DebugLog "User selected cancel from the file dialog" End Method End Type see following code for demo: |
| ||
Surprise, surprise - the above hack is unreliable (to put it politely). |
| ||
Righty... You'll need to update to the latest wxMax for this stuff... This is your original code as posted at the top with some additions, based on the thread I linked to previously. Notably, the dialogs now override ShowModal : Method ShowModal() HIWindowChangeClass(MacGetWindowRef(), 4); Super.ShowModal() End Method "4" is kMovableModalWindowClass. And for HIWindowChange you need to add : Extern Function HIWindowChangeClass:Int(handle:Byte Ptr, style:Int) End Extern Now the windows appear to handle modality in a more expected way. However, the close/min/max buttons are now disabled. But then, a Modal dialog tends to work a bit differently to a normal document window, so this may not be a problem. (there may well be a way to re-enable those in flags). See how you get on with that... :o) |
| ||
Well here's a big yay! from me as you've managed to solve a different os x bug that's been bothering me for ages. Your new ShowModal() override means I no longer have to use wxSTAY_ON_TOP on osx wxDialogs. The sharky fin of the win32 wxFileDialog issue is however, still out there. Circling... |