所以我使用WxDev框架来开发我们程序的GUI。 所以它有两个按钮,"上传"和"分析"。
序列应该是用户上传图像。一旦上传,他就有能力点击"分析"按钮。现在,一旦他点击了分析,我就想禁用它。只有在需要分析的新图像时才会启用该按钮。
这里是我所拥有的按钮的代码,尽管它可能无关紧要。
UPLOAD:
void NBA_Jersey_RecognitionFrm::WxButton1Click(wxCommandEvent& event)
{
openIMGFileDialog->ShowModal();
if (openIMGFileDialog->GetPath().IsEmpty())
{
return;
}
imageopen = imgFile.LoadFile(openIMGFileDialog->GetPath(), wxBITMAP_TYPE_ANY);
int h = imgFile.GetHeight();
int w = imgFile.GetWidth();
pic.Create(w,h);
for (int x = 0; x < w; x++)
{
for (int y = 0; y < h; y++)
{
pic.SetRGB(x, y, 240, 240, 240);
}
}
if (300 >= (h*300/w))
{
displayIMG->SetBitmap(pic.Scale(300,h*300/w));
displayIMG->SetBitmap(imgFile.Scale(300,h*300/w));
}
else
{
displayIMG->SetBitmap(pic.Scale(w*300/h,300));
displayIMG->SetBitmap(imgFile.Scale(w*300/h,300));
}
}
这是我的ANALYZE按钮的摘录:
void NBA_Jersey_RecognitionFrm::WxButton1Click0(wxCommandEvent& event)
{
ofstream resultsFile;
stringstream ss;
string s;
int height = imgFile.GetHeight();
int width = imgFile.GetWidth();
RedVal = new int* [width];
GreenVal = new int* [width];
BlueVal= new int* [width];
for(int i=0; i<width; i++) {
RedVal[i] = new int[height];
GreenVal[i] = new int[height];
BlueVal[i] = new int[height];
}
//int RedVal[width][height];
//int GreenVal[width][height];
//int BlueVal[width][height];
resultsFile.open("results.txt");
//resultsFile << "x,y,Red,Green,Blue \n";
for(int h=0; h<height; h++) {
for(int w=0; w<width; w++) {
RedVal[w][h]=imgFile.GetRed(w,h);
GreenVal[w][h]=imgFile.GetGreen(w,h);
BlueVal[w][h]=imgFile.GetBlue(w,h);
//ss << h << "," << w << "," << RedVal[0][h] << "," << GreenVal[0][h] << "," << BlueVal[0][h] <<"\n";
//resultsFile << ss.str();
//resultsFile << h << "," << w << "," << RedVal[w][h] << "," << GreenVal[w][h] << "," << BlueVal[w][h] <<"\n";
}
}
WxDev C ++中是否有关于禁用按钮的内置函数?或者我应该添加到我的代码中?谢谢。
答案 0 :(得分:2)
您可以禁用按钮(和大多数控件),如下所示:
void NBA_Jersey_RecognitionFrm::WxButton1Click0(wxCommandEvent& event)
{
m_analyzeButton->Enable(false);
...
然后重新启用它:
void NBA_Jersey_RecognitionFrm::WxButton1Click(wxCommandEvent& event)
{
openIMGFileDialog->ShowModal();
if (openIMGFileDialog->GetPath().IsEmpty())
{
return;
}
m_analyzeButton->Enable(true);
...
替换&#39; m_analyzeButton&#39;用你的按钮名称。