listbox中的问题
我使用listbox作我的播放列表,但是我想在我双击的时候里面的文件名时就可以播放相应的文件名。这样怎么做啊! 问题点数:20、回复次数:9Top
1 楼seabright2002()回复于 2002-05-19 17:55:56 得分 1
在listbox双击事件里写代码Top
2 楼mygodness(狂风)回复于 2002-05-19 18:52:00 得分 0
listbox是不行,但combobox是可以的,它有一个seltext属性Top
3 楼newpowersky(菜鸟)回复于 2002-05-19 18:56:32 得分 0
可以写出一段代码来看看吗?我真的 需要啊!Top
4 楼blankman(菜鸟)回复于 2002-05-19 18:59:02 得分 0
在onselectitem事件中有这样一个参数 TListItem *Item,Item->Index就是你选择的条目的索引号,你可以定义一个变量index,将index=Item->Index;写在这个事件中,当双击的时候就可以用ListView1->Items[index]....(后面我记不请了)来得到你想要的条目,之后在双击的事件中播放,我没试过,有问题的话给我写信,yyqemails@163.com
Top
5 楼invalid(空心菜(Python是个好东东,大家多用用!))回复于 2002-05-19 19:04:38 得分 10
从下面的代码找找吧
for (int i = 0; i < FileListBox1->Items->Count; i++)
{
if (FileListBox1->Selected[i])
{
if (!FileExists(FileListBox1->Items->Strings[i]))
{
MessageBeep(0);
if (Application->MessageBox(AnsiString("File ") + FileListBox1->Items->Strings[i] + " not found",NULL, MB_OKCANCEL | MB_DEFBUTTON1) == IDCANCEL)
break;
else
continue;
}
FILE *F = fopen(FileListBox1->Items->Strings[i].c_str(),"r");
struct stat statbuf;
fstat(fileno(F), &statbuf);
ListBox1->Items->Add(IntToStr(statbuf.st_size));
fclose(F);
}
}Top
6 楼newpowersky(菜鸟)回复于 2002-05-19 19:09:48 得分 0
一点办法也没有啊!!那个combobox的样子真的不好看啊!!Top
7 楼newpowersky(菜鸟)回复于 2002-05-19 20:14:44 得分 0
对了上面的那位啊!你的代码加在什么地方啊!
还有楼楼上的楼上啊!你说的意思是不是这段代码意思就是(listbox获得当前用户的选择是不是可以用)
listbox->Items->Srtings[Listbox->ItemIndex]这段代码啊!
Top
8 楼codecb(阿星)回复于 2002-05-19 21:03:25 得分 9
try{
MediaPlayer1->FileName=ListBox1->Items->Strings[ListBox1->ItemIndex];
MediaPlayer1->Open();
MediaPlayer1->Play();
Label1->Caption=ExtractFileName(Form1->MediaPlayer1->FileName);
Timer1->Enabled=true;
Label5->Visible=false;
Form1->MediaPlayer1->Display=Form7->Panel1;
Form7->BorderStyle=bsSingle;
Form7->WindowState=wsNormal;
Form7->Height=(Screen->Height)/2.25;
Form7->Width=(Screen->Width)/2.25;
Form1->MediaPlayer1->DisplayRect=Rect(0,0,Form7->Panel1->Width,Form7->Panel1->Height);
Form8->Hide();
TrayIcon1->Animate=true;
TrayIcon1->IconIndex=0;
}
catch(...)
{
MediaPlayer1->Close();
ShowMessage("未知的文件格式");
TrayIcon1->Animate=false;
}
上面是我写的播放软件的代码!
可以的试试!
不要忘了给分!
Top
9 楼homer_lv(homer)回复于 2002-05-19 21:12:38 得分 0
简单呀,用两个全局变量,TListItem *p;bool IsSelect,在ListBox的点击函数里面将IsSelect=IsSelect,p=Items;然后再在双击事件里面作处理不就成了吗Top




