我也不知道是怎么回事,希望大家帮帮忙,下面是这一段功能的代码,用途是先产生一个随机数,然后根据随机数显示与之相对应的名称和图片,代码如下,出错提示在代码下面,希望知道的人们能帮下忙啊,谢谢了
void CXingyun52Dlg::OnButton1()
{
// TODO: Add your control notification handler code here
m_EDIT1=0; //清空EDIT1
stand(time (NULL));
CurrentCommodityIndex=rand()%10;//产生一个0到9的随机数
m_STATIC1.Format("%s",cmmdty[CurrentCommodityIndex]);
UpdateData(FALSE);
if (CurrentCommodityIndex==0)
((CStatic *)GetDlgItem(IDC_PICTURE))->SetBitmap(HBITMAP(Bitmap[0]));
else if (CurrentCommodityIndex==1)
((CStatic *)GetDlgItem(IDC_PICTURE))->SetBitmap(HBITMAP(Bitmap[1]));
else if (CurrentCommodityIndex==2)
((CStatic *)GetDlgItem(IDC_PICTURE))->SetBitmap(HBITMAP(Bitmap[2]));
else if (CurrentCommodityIndex==3)
((CStatic *)GetDlgItem(IDC_PICTURE))->SetBitmap(HBITMAP(Bitmap[3]));
else if (CurrentCommodityIndex==4)
((CStatic *)GetDlgItem(IDC_PICTURE))->SetBitmap(HBITMAP(Bitmap[4]));
else if (CurrentCommodityIndex==5)
((CStatic *)GetDlgItem(IDC_PICTURE))->SetBitmap(HBITMAP(Bitmap[5]));
else if (CurrentCommodityIndex==6)
((CStatic *)GetDlgItem(IDC_PICTURE))->SetBitmap(HBITMAP(Bitmap[6]));
else if (CurrentCommodityIndex==7)
((CStatic *)GetDlgItem(IDC_PICTURE))->SetBitmap(HBITMAP(Bitmap[7]));
else if (CurrentCommodityIndex==8)
((CStatic *)GetDlgItem(IDC_PICTURE))->SetBitmap(HBITMAP(Bitmap[8]));
else if (CurrentCommodityIndex==9)
((CStatic *)GetDlgItem(IDC_PICTURE))->SetBitmap(HBITMAP(Bitmap[9]));
}
出现的错误提示是:
Compiling...
xingyun52Dlg.cpp
\xingyun52\xingyun52Dlg.cpp(218) : error C2065: 'stand' : undeclared identifier
\xingyun52\xingyun52Dlg.cpp(226) : error C2065: 'IDC_PICTURE' : undeclared identifier
\xingyun52\xingyun52Dlg.cpp(226) : error C2227: left of '->SetBitmap' must point to class/struct/union
\xingyun52\xingyun52Dlg.cpp(230) : error C2227: left of '->SetBitmap' must point to class/struct/union
\xingyun52\xingyun52Dlg.cpp(234) : error C2227: left of '->SetBitmap' must point to class/struct/union
\xingyun52\xingyun52Dlg.cpp(237) : error C2227: left of '->SetBitmap' must point to class/struct/union
\xingyun52\xingyun52Dlg.cpp(240) : error C2227: left of '->SetBitmap' must point to class/struct/union
\xingyun52Dlg.cpp(243) : error C2227: left of '->SetBitmap' must point to class/struct/union
\xingyun52Dlg.cpp(246) : error C2227: left of '->SetBitmap' must point to class/struct/union
\xingyun52\xingyun52Dlg.cpp(249) : error C2227: left of '->SetBitmap' must point to class/struct/union
\xingyun52\xingyun52Dlg.cpp(253) : error C2227: left of '->SetBitmap' must point to class/struct/union
\xingyun52\xingyun52Dlg.cpp(257) : error C2227: left of '->SetBitmap' must point to class/struct/union
执行 cl.exe 时出错.