简单wxWidgets问题,如何程序控制wxComboBox弹出列表框;
代码如下:
#include "wx/wx.h"class GUIFrame : public wxFrame{public: wxButton* m_button; // Virtual event handlers, overide them in your derived class wxComboBox* m_comboBox1; GUIFrame(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("wxWidgets Application Template"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(485, 244), long style = wxDEFAULT_FRAME_STYLE | wxTAB_TRAVERSAL); virtual void OnButton(wxCommandEvent& event); ~GUIFrame() {}};void GUIFrame::OnButton(wxCommandEvent& event){ m_comboBox1->SetFocus();}GUIFrame::GUIFrame(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) : wxFrame(parent, id, title, pos, size, style){ wxBoxSizer* bSizer1 = new wxBoxSizer(wxHORIZONTAL); bSizer1->Add(0, 0, 1, wxEXPAND, 5); //space const int wxID_BUTTON = 65530; const int wxID_COMBOBOX = 65531; m_button = new wxButton(this, wxID_BUTTON, wxT("Press Me...")); bSizer1->Add(m_button, 2, wxALL | wxALIGN_CENTER_VERTICAL, 5); m_comboBox1 = new wxComboBox(this, wxID_COMBOBOX); m_comboBox1->Append(wxT("1->Item1")); m_comboBox1->Append(wxT("2->Item2")); m_comboBox1->Append(wxT("3->Item3")); m_comboBox1->SetSelection(0); bSizer1->Add(m_comboBox1, 2, wxALL | wxALIGN_CENTER_VERTICAL, 5); bSizer1->Add(0, 0, 1, wxEXPAND, 5); //space this->SetSizer(bSizer1); this->Layout(); // Connect Events this->Connect(wxID_BUTTON, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(GUIFrame::OnButton));}class comboBoxApp : public wxApp{public: virtual bool OnInit();};bool comboBoxApp::OnInit(){ wxFrame* frame = new GUIFrame(0L); frame->Show(); return true;}IMPLEMENT_APP(comboBoxApp);