WxWidgets 簡單加數?


方法一 :

1
2
3
4
5
6
7
8
void AddNumberFrm::btnGetTotalClick(wxCommandEvent& event)
{
wxString number_1 = this->txtFirstNumber->GetValue().Trim(true);
wxString number_2 = this->txtSecondNumber->GetValue().Trim(true);
int total = wxAtoi(number_1) + wxAtoi(number_2);

this->txtTotal->SetValue(wxString::Format(wxT("%d"), total));
}

方法二 :

1
2
3
4
5
6
7
8
9
10
11
void Project1Frm::WxButton1Click(wxCommandEvent& event)
{
wxString str1 = this->WxEdit1->GetValue();
wxString str2 = this->WxEdit2->GetValue();
wxString tmp = "";

int num1 = wxAtoi(str1) + wxAtoi(str2);
tmp.sprintf("Number : %d", num1);

wxMessageBox(tmp , "Tips");
}

參考 :
http://wiki.wxwindows.org/Converting_everything_to_and_from_wxString
http://wiki.wxwidgets.org/WxString
http://www-128.ibm.com/developerworks/cn/linux/sdk/python/wxwin/