如何动态改变speedbutton的图片??

talkingmute 2005-03-25 10:22:13
定义了imagelist控件,并加了几副图片,想实现点击一次speedbutton按纽时,改变它的图片,我这样写错在哪里?为何实现不了我想要的功能!
int imageindex;
__fastcall TMainForm::TMainForm(TComponent* Owner)
: TForm(Owner)
{

ImageList1->GetBitmap(0,SpeedButton1->Glyph);
imageindex=0;

}
void __fastcall TMainForm::SpeedButton1Click(TObject *Sender)
{
if(imageindex==0)
{
ImageList1->GetBitmap(1,SpeedButton1->Glyph);
imageindex=1;
}
else
{
ImageList1->GetBitmap(0,SpeedButton1->Glyph);
imageindex=0;
}
}
...全文
267 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
icwin 2005-03-30
  • 打赏
  • 举报
回复
for(i=0;i<ImageList1->Count;i++)
{
ImageList1->GetBitmap(i,SpeedButton1->Glyph);
}
icwin 2005-03-30
  • 打赏
  • 举报
回复
ImageList1->GetBitmap(i,SpeedButton1->Glyph);
你改变i的值阿
talkingmute 2005-03-25
  • 打赏
  • 举报
回复
哦,谢谢,那请问如何取ImageList中的某一个图片呢?是哪个函数?我忘记了...
cczlp 2005-03-25
  • 打赏
  • 举报
回复
void __fastcall TMainForm::SpeedButton1Click(TObject *Sender)
{
SpeedButton1->Glyph = NULL;//加入这句,先清空位图
if(imageindex==0)
{
ImageList1->GetBitmap(1,SpeedButton1->Glyph);
imageindex=1;
}
else
{
ImageList1->GetBitmap(0,SpeedButton1->Glyph);
imageindex=0;
}
}
totti1976 2005-03-25
  • 打赏
  • 举报
回复
这样只能显示两张图片吧,没有循环.
cczlp 2005-03-25
  • 打赏
  • 举报
回复
ImageList1->GetBitmap(1,SpeedButton1->Glyph);不就是取图片吗?另外还有一个Draw()函数

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧