Einzelnen Beitrag anzeigen

Benutzerbild von thkerkmann
thkerkmann

Registriert seit: 7. Jan 2006
Ort: Pulheim Brauweiler
464 Beiträge
 
Delphi 2010 Professional
 
#2

Re: TObjectList - Sort crash (D7)

  Alt 11. Mär 2008, 14:29
Hi,
also deine compare blick ich nicht:
Zitat:
Delphi-Quellcode:
function MyListCompare(pmyItem1, pmyItem2: pointer): integer;
  begin
    Result := 0
    if TmyItem(pmyItem).V1 > TmyItem(pmyItem).V2 then Result := 1; // <<<< wo kommt denn pmyItem plötzlich her ???
    if TmyItem(pmyItem).V1 < TmyItem(pmyItem).V2 then Result := -1;
  end;
ich würde so schreiben
Delphi-Quellcode:
function MyListCompare(pmyItem1, pmyItem2: pointer): integer;
  begin
    if TmyItem(pmyItem1).V1 > TmyItem(pmyItem2).V1 then
     Result := 1
    else if TmyItem(pmyItem1).V1 < TmyItem(pmyItem2).V1 then
      Result := -1
    else
      Result := 0;
  end;
Thomas Kerkmann
Ich hab noch einen Koffer in Borland.
http://thomaskerkmann.wordpress.com/
  Mit Zitat antworten Zitat