+void MyFrame::DoCreateInputWindow(bool text)
+{
+ wxWindow* const oldWin = m_inputWin;
+
+ m_inputWin = text ? new wxTextCtrl(this, wxID_ANY, "Press keys here",
+ wxDefaultPosition, wxSize(-1, 50),
+ wxTE_MULTILINE)
+ : new wxWindow(this, wxID_ANY,
+ wxDefaultPosition, wxSize(-1, 50),
+ wxRAISED_BORDER);
+ m_inputWin->SetBackgroundColour(*wxBLUE);
+ m_inputWin->SetForegroundColour(*wxWHITE);
+
+ // connect event handlers for the blue input window
+ m_inputWin->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(MyFrame::OnKeyDown),
+ NULL, this);
+ m_inputWin->Connect(wxEVT_KEY_UP, wxKeyEventHandler(MyFrame::OnKeyUp),
+ NULL, this);
+ m_inputWin->Connect(wxEVT_CHAR, wxKeyEventHandler(MyFrame::OnChar),
+ NULL, this);
+
+ if ( !text )
+ {
+ m_inputWin->Connect(wxEVT_PAINT,
+ wxPaintEventHandler(MyFrame::OnPaintInputWin),
+ NULL, this);
+ }
+
+ if ( oldWin )
+ {
+ GetSizer()->Replace(oldWin, m_inputWin);
+ Layout();
+ delete oldWin;
+ }
+}
+
+void MyFrame::OnUseTextCtrl(wxCommandEvent& event)
+{
+ DoCreateInputWindow(event.IsChecked());
+}
+