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 .
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 .
SuperStrict Framework wx.wxApp Import wx.wxFrame Import wx.wxDialog Import wx.wxButton Import wx.wxFileDialog New MyApp.run() Type MyApp Extends wxApp Field Window:TTestWindow Method OnInit:Int() Window = New TTestWindow Window.Create(, , "Window", -1, -1, 550, 550) Window.Center() Window.Show() Window.Refresh(True) Return True End Method End Type Type TTestWindow Extends wxFrame Field Dialog:TTestDialog Method OnInit() ' Open up a file requester Local file_dialog:wxFileDialog = New wxFileDialog.Create(Self, "File dialog 1: Parent is the wxFrame",Null,Null, "*.*", wxFD_OPEN|wxFD_DEFAULT_STYLE) If file_dialog.ShowModal() <> wxID_OK Then DebugLog "User selected cancel from the file dialog" Dialog = TTestDialog(New TTestDialog.Create_(Self, wxID_ANY,"1st dialog"))',,,,, wxDEFAULT_DIALOG_STYLE | wxSTAY_ON_TOP)) Dialog.ShowModal() End Method End Type Type TTestDialog Extends wxDialog Field Button:TTestButton Field Dialog2:TTestDialog2 Method OnInit() Button = TTestButton(New TTestButton.Create(Self, wxID_OK, "OK")) Button.ConnectAny(wxEVT_COMMAND_BUTTON_CLICKED, _OnClick, Null, Self) End Method Method OnClick(_event:wxCommandEvent) DebugLog "Dialog 1 Clicked! - attempting to open a dialog" ' Open up a file requester Local file_dialog:wxFileDialog = New wxFileDialog.Create(Self, "File dialog 2: Parent is Dialog 1",Null,Null, "*.*", wxFD_OPEN|wxFD_DEFAULT_STYLE) If file_dialog.ShowModal() <> wxID_OK Then DebugLog "User selected cancel from the file dialog" Dialog2 =TTestDialog2( New TTestDialog2.Create_(Self, wxID_ANY,"2nd dialog"))',,,,, wxDEFAULT_DIALOG_STYLE | wxSTAY_ON_TOP) ) Dialog2.ShowModal() End Method Function _OnClick(_event:wxEvent) ' parent is the Object of the click, sink is the Object that handles the event. TTestDialog(_event.sink).OnClick(wxCommandEvent(_event)) End Function End Type Type TTestDialog2 Extends wxDialog Field Button:TTestButton Method OnInit() Button = TTestButton(New TTestButton.Create(Self, wxID_OK, "2nd OK")) Button.ConnectAny(wxEVT_COMMAND_BUTTON_CLICKED, _OnClick, Null, Self) End Method Method OnClick(_event:wxCommandEvent) DebugLog "Clicked! Dialog 2 - attempting to open a file dialog" ' Open up a file requester Local file_dialog:wxFileDialog = New wxFileDialog.Create(Self, "File dialog 3: Choose a file",Null,Null, "*.*", wxFD_OPEN|wxFD_DEFAULT_STYLE) If file_dialog.ShowModal() <> wxID_OK Then DebugLog "User selected cancel from the file dialog" End Method Function _OnClick(_event:wxEvent) ' parent is the Object of the click, sink is the Object that handles the event. TTestDialog2(_event.sink).OnClick(wxCommandEvent(_event)) End Function End Type Type TTestButton Extends wxButton End Type