procedure TFormMain.TreeView_ChannelClick(Sender: TObject);
var
TreeNode: TTreeNode;
begin
Screen.Cursor := StartCursor;
if (Sender as TTreeView).Selected <> nil then
begin
TreeNode := (Sender as TTreeView).Selected;
if PointTypeAndID(TreeNode.Data)^.TypeType = 'CHANNEL_ALL' then
begin
with DataModule1.ClientDataSet1 do
begin
Close;
CommandText := 'Select ' + Field_Channel + ', Channel_ID From CHANNEL_CODE, CHANNEL_CATEGORY WHERE CHANNEL_CODE.CATEGORY_ID = CHANNEL_CATEGORY.CATEGORY_ID ORDER BY CHANNEL_NAME';
Open;
end;
ShowListView_Channel(DataModule1.ClientDataSet1, ListView_Channel, ICO_CHANNEL_CODE);
StatusBar_Main.Panels[0].Text := '频道信息';
NoteBook_ListView.ActivePage := 'Channel';
end;
if PointTypeAndID(TreeNode.Data)^.TypeType = 'CHANNEL_CATEGORY' then
begin
with DataModule1.ClientDataSet1 do
begin
Close;
CommandText := Format('Select ' + Field_Channel + ', Channel_ID From CHANNEL_CODE, CHANNEL_CATEGORY WHERE CHANNEL_CODE.CATEGORY_ID = CHANNEL_CATEGORY.CATEGORY_ID AND CHANNEL_CODE.CATEGORY_ID = ''%s'' ORDER BY CHANNEL_NAME', [PointTypeAndID(TreeNode.Data)^.TypeID]);
Open;
end;
ShowListView_Channel(DataModule1.ClientDataSet1, ListView_Channel, ICO_CHANNEL_CODE);
StatusBar_Main.Panels[0].Text := '频道信息';
NoteBook_ListView.ActivePage := 'Channel';
end;
end;
Screen.Cursor := EndCursor;
end;
Field_Channel : String;
Field_Channel := GetFieldString(ContentPath + ListView_Channel_File);
function GetFieldString(FileName: String): String;
var
StringList, StringList1: TStringList;
S: String;
i: Integer;
begin
S := '';
StringList := TStringList.Create;
StringList1 := TStringList.Create;
StringList.LoadFromFile(FileName);
for i := 0 to StringList.Count - 1 do
begin
SeparateString(StringList, '^', StringList1);
if StringList1[3] = 'Y' then
S := S + StringList1[1] + ', ';
end;
S := Copy(S, 1, Length(S) - 2) + ' ';
StringList.Free;
StringList1.Free;
Result := S;
end;
procedure SeparateString(S, Sign: String; StringList: TStringList);
var
Count: Integer;
begin
StringList.Clear;
repeat
Count := Pos(Sign, S);
StringList.Add(Copy(S, 1, Count -1));
S := Copy(S, Count + 1, Length(S) - Count);
until StrPos(PChar(S), PChar(Sign)) = nil;
StringList.Add(S);
end;