+#if wxUSE_FINDREPLDLG
+
+void MyFrame::ShowReplaceDialog( wxCommandEvent& WXUNUSED(event) )
+{
+ wxFindReplaceDialog *dialog = new wxFindReplaceDialog
+ (
+ this,
+ &m_findData,
+ "Find and replace dialog",
+ wxFR_REPLACEDIALOG
+ );
+ dialog->Show();
+}
+
+void MyFrame::ShowFindDialog( wxCommandEvent& WXUNUSED(event) )
+{
+ wxFindReplaceDialog *dialog = new wxFindReplaceDialog
+ (
+ this,
+ &m_findData,
+ "Find dialog",
+ // just for testing
+ wxFR_NOWHOLEWORD
+ );
+ dialog->Show();
+}
+
+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("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("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("Find dialog is being closed.");
+
+ event.GetDialog()->Destroy();
+ }
+ else
+ {
+ wxLogError("Unknown find dialog event!");
+ }
+}
+
+#endif // wxUSE_FINDREPLDLG
+