User forums > General (but related to Code::Blocks)
Why my wxListCtrl code could not work??
(1/1)
dbtsai:
Dear all,
The following are my code.
and I have an wxTextCtrl in my driven class from wxListCtrl.
And I want when I change wxTextCtrl, and event will generate,
and call a member function in my MyPanel_file_text_list.
But the following code seem does not call the member function.
What wrong with it??
Thanks..
--- Code: ---class MyPanel_file_text_list : public wxListCtrl
{
public:
MyPanel_file_text_list(wxWindow* parent,
wxWindowID id,
const wxPoint& pos,
const wxSize& size,long style);
void SetDir(wxCommandEvent& event);
private:
wxTextCtrl* g_dir_text;
wxString g_path;
protected:
DECLARE_EVENT_TABLE()
};
--- End code ---
--- Code: ---BEGIN_EVENT_TABLE(MyPanel_file_text_list, wxListCtrl)
EVT_TEXT_ENTER(ID_MyPanel_file_text_enter_path, MyPanel_file_text_list::SetDir)
END_EVENT_TABLE()
--- End code ---
--- Code: ---MyPanel_file_text_list::MyPanel_file_text_list
(wxWindow* parent, wxWindowID id, const wxPoint& pos,
const wxSize& size,long style)
: wxListCtrl( parent, id, pos+wxPoint(0,30), size, style)
{
wxListItem itemCol; itemCol.SetText(wxT("檔名"));
this->InsertColumn(0, itemCol);
this->SetColumnWidth(0, 200);
this->g_dir_text = new wxTextCtrl(parent, ID_MyPanel_file_text_enter_path,
wxEmptyString,
pos,wxDefaultSize,
wxTE_PROCESS_ENTER);
}
void MyPanel_file_text_list::SetDir(wxCommandEvent& event)
{ cout << "test";
}
--- End code ---
MortenMacFly:
May I ask how this is related to C::B?
Please, don't get me wrong, but if you have questions about wxWidgets programming you might better ask in a "true" wxWidgets forum, such as http://wxforum.shadonet.com.
Hence there might still be somebody around here that can answer your question...
With regards, Morten.
takeshimiya:
MortenMacFly is right. But could you replace the
--- Code: (cpp) ---cout << "test";
--- End code ---
with
--- Code: (cpp) ---wxMessageBox(wxT("test"));
--- End code ---
?
Navigation
[0] Message Index
Go to full version