학교에서 수업을위한 스도쿠 게임을 만들고 있고 C++에서 wxWidgets를 사용하고 있다고 생각할 수도 있습니다.wxWidgets, C++에서 새로 고침하는 방법
내 문제는 사각형에 다른 값으로 새 보드를 만들 때 프로그램을 새로 고치는 방법을 모르겠다는 것입니다.
은 내가 createBoard 기능으로 보드를 생성합니다
//Storing a random-generated sudokuboard into "board".
setBoard(board);
// sizers for the layout of bricks and buttons
wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL); // overall layout
// 9 rows and 9 columns with fixed height and width
wxGridSizer *gs = new wxGridSizer(9, 9, 1, 1);
wxBoxSizer *hbox2 = new wxBoxSizer(wxHORIZONTAL); // button commands
// Define font and font size for the text in the squares
// Define valid input values for the text in the squares
csCharCtrl::Initialize(wxT("123456789"), sz);
// Create the squares
for (int i = 0; i < 81; i++) {
m_square[i] = CreateSquare(this, i+1, i/9, i%9);
// install an event handler for Set Focus event for the square
gs->Add(m_square[i], 0, wxEXPAND);
}
Bind(wxEVT_CHILD_FOCUS, &BoardPanel::OnChildFocus, this);
// buttons commands
// Check command
wxButton *btnnew = new wxButton(this, ID_New, wxT("New board"));
btnnew->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &BoardPanel::OnNew, this);
hbox2->Add(btnnew, 2, wxEXPAND);
vbox->Add(gs, 1, wxALIGN_CENTER | wxALL, 20);
vbox->Add(hbox2, 0, wxALIGN_CENTER | wxALL, 20);
SetSizer(vbox);
}
setBoard는 multidimentional 벡터 안에 새로운 스도쿠 게임을 생성합니다.
클릭을 듣고있는 버튼이 있는데 setBoard를 다시 호출하고 클릭시 보드를 새로 고침하여 새 보드를 만들고 싶습니다.
어떻게하면됩니까? 내 버튼
코드는 간단하다
여기void BoardPanel::OnClick(wxCommandEvent& WXUNUSED(event)){
//CODE onClick
}
프로그램의 사진입니다 :
고마워요! 그것은 많은 도움이되었습니다. –