我正在开发一个mp3发送程序。我使用列表框显示mp3文件名(1.mp3、2.mp3、3.mp3等)的简单列表,以及连接( ip adress1、ip adress2)所在的复选框。我想知道如何将具有复选列表框选中项的列表框项保存为(链接)?例如,如果我想将1.mp3发送到ipadress1和ipadress2,则2.mp3、3.mp3仅用于ipadress2等。)我想使用“文件发送”按钮将其保存为一些txt文件。有什么想法吗?我不想知道答案!
procedure TForm1.ListBox1Click(Sender: TObject);
var
Item : TStringList;
I: Integer;
begin
if ListBox1.ItemIndex = -1 then
Exit ;
if Assigned(ListBox1.Items.Objects[ListBox1.ItemIndex]) then
Item := ListBox1.Items.Objects[ListBox1.ItemIndex] as TStringList
else
begin
Item := TStringList.Create ;
ListBox1.Items.Objects[ListBox1.ItemIndex] := Item;
end ;
for I := 0 to CheckListBox1.Items.Count - 1 do
CheckListBox1.Checked[I] := False;
for I := 0 to Item.Count - 1 do
CheckListBox1.Checked[CheckListBox1.Items.IndexOf(Item[I])] := True;
end;
procedure TForm1.CheckListBox1ClickCheck(Sender: TObject);
var
Item : TStringList;
I : Integer;
begin
if ListBox1.ItemIndex = -1 then
begin
ShowMessage('Select the mp3 first!');
Exit ;
end ;
if Assigned(ListBox1.Items.Objects[ListBox1.ItemIndex]) then
Item := ListBox1.Items.Objects[ListBox1.ItemIndex] as TStringList
else
begin
Item := TStringList.Create;
ListBox1.Items.Objects[ListBox1.ItemIndex] := Item;
end;
Item.Clear;
for I := 0 to CheckListBox1.Items.Count - 1 do
if CheckListBox1.Checked[I] then
Item.Add(CheckListBox1.Items[I]);
end;发布于 2012-10-30 17:44:30
您可以将其保存到ini文件中。我认为它符合你的要求。
使用mp3文件名作为节名,使用ip作为name=value对
[1.mp3]
ip1=1
ip2=1
[2.mp3]
ip2=1
ip4=1发布于 2012-10-30 19:35:26
如果您有其他选择,可以使用xml文件。您可以随心所欲地添加属性。
<Body>
<F1.mp3 ipaddress1="True" ipaddress2="False"/>
<F2.mp3 ipaddress1="False" ipaddress2="True"/>
</Body>https://stackoverflow.com/questions/13135259
复制相似问题