+#if wxUSE_FINDREPLDLG
+
+void MyFrame::ShowReplaceDialog( wxCommandEvent& WXUNUSED(event) )
+{
+ wxFindReplaceDialog *dialog = new wxFindReplaceDialog
+ (
+ this,
+ &m_findData,
+ "Find and replace dialog",
+ wxFR_REPLACEDIALOG
+ );
+ dialog->Show(TRUE);
+}
+
+void MyFrame::ShowFindDialog( wxCommandEvent& WXUNUSED(event) )
+{
+ wxFindReplaceDialog *dialog = new wxFindReplaceDialog
+ (
+ this,
+ &m_findData,
+ "Find dialog",
+ // just for testing
+ wxFR_NOWHOLEWORD
+ );
+ dialog->Show(TRUE);
+}
+
+static wxString DecodeFindDialogEventFlags(int flags)
+{
+ wxString str;
+ str << (flags & wxFR_DOWN ? "down" : "up") << ", "
+ << (flags & wxFR_WHOLEWORD ? "whole words only, " : "")
+ << (flags & wxFR_MATCHCASE ? "" : "not ")
+ << "case sensitive";
+
+ return str;
+}
+
+void MyFrame::OnFindDialog(wxFindDialogEvent& event)
+{
+ wxEventType type = event.GetEventType();
+
+ if ( type == wxEVT_COMMAND_FIND || type == wxEVT_COMMAND_FIND_NEXT )
+ {
+ wxLogMessage(wxT("Find %s'%s' (flags: %s)"),
+ type == wxEVT_COMMAND_FIND_NEXT ? "next " : "",
+ event.GetFindString().c_str(),
+ DecodeFindDialogEventFlags(event.GetFlags()).c_str());
+ }
+ else if ( type == wxEVT_COMMAND_FIND_REPLACE ||
+ type == wxEVT_COMMAND_FIND_REPLACE_ALL )
+ {
+ wxLogMessage(wxT("Replace %s'%s' with '%s' (flags: %s)"),
+ type == wxEVT_COMMAND_FIND_REPLACE_ALL ? "all " : "",
+ event.GetFindString().c_str(),
+ event.GetReplaceString().c_str(),
+ DecodeFindDialogEventFlags(event.GetFlags()).c_str());
+ }
+ else if ( type == wxEVT_COMMAND_FIND_CLOSE )
+ {
+ wxLogMessage(wxT("Find dialog is being closed."));
+
+ event.GetDialog()->Destroy();
+ }
+ else
+ {
+ wxLogError(wxT("Unknown find dialog event!"));
+ }
+}
+
+#endif // wxUSE_FINDREPLDLG
+