Cześć, mam problem z wyświetlaniem Labela, wszystko chodzi idealnie tylko nie ta jedna linijka, Bez względu na jaki Item klikne w Listboxie wyświetla się to samo.Problem musi być w tej części z typem rekordowym, Bo jak tą procedurę poniżej zrobię przez pętle for działa i Label
LblWords.Caption := IWord.spelling +' ( ' + IWord.pronunciation + ' )';
Procedure TForm1.DisplayjALL();
var
lWord: Tword;
begin
lWord := getWordBySpelling(ListBox1.Items.Strings[ListBox1.ItemIndex], self.XMLIntf);
LblWords.Caption := IWord.spelling +' ( ' + IWord.pronunciation + ' )';
LoadImage(extractfilepath(paramstr(0)) + lWord.picture, Image1);
PlayFile (extractfilepath(paramstr(0)) + lWord.mp3, MediaPlayer1, Image2);
end;
interface
uses TRANSLATORXML, sysutils;
type
Tword = record
id: integer;
mp3: string;
spelling: string;
pronunciation: string;
categoryId: integer;
language: string;
picture: string;
end;
procedure copyWord(aFrom: IXMLWordType; var aTo: Tword);
function getWordById(aId: integer; aIXMLDictionaryType: IXMLDictionaryType): Tword;
function getWordBySpelling(aSpelling: string; aIXMLDictionaryType: IXMLDictionaryType): Tword;
implementation
procedure copyWord(aFrom: IXMLWordType; var aTo: Tword);
begin
aTo.id := aFrom.id;
aTo.mp3 := aFrom.mp3;
aTo.spelling := aFrom.spelling;
aTo.pronunciation := aFrom.pronunciation;
aTo.spelling := aFrom.spelling;
aTo.categoryId := aFrom.categoryId;
aTo.language := aFrom.language;
aTo.picture := aFrom.JPEG;
end;
function getWordBySpelling(aSpelling: string; aIXMLDictionaryType: IXMLDictionaryType): Tword;
var
I: integer;
lIWord: IXMLWordType;
begin
fillchar(result, sizeof(result), 0);
result.id := -1;
for I := 0 to aIXMLDictionaryType.words.Count - 1 do
begin
lIWord := aIXMLDictionaryType.words[I];
if uppercase(aSpelling) = uppercase(lIWord.spelling) then
begin
copyWord(lIWord, result);
end;
end;
end;
function getWordById(aId: integer; aIXMLDictionaryType: IXMLDictionaryType): Tword;
var
I: integer;
lIWord: IXMLWordType;
begin
fillchar(result, sizeof(result), 0);
result.id := -1;
for I := 0 to aIXMLDictionaryType.words.Count - 1 do
begin
lIWord := aIXMLDictionaryType.words[I];
if aId = lIWord.id then
begin
copyWord(lIWord, result);
end;
end;
end;