In addition to Thaddy's answer about the FormatDateTime function, you must also convert your numbers given in milliseconds to the units used by FormatDateTime which is days. So, you must divide the milliseconds by the number of milliseconds per day, i.e. by 24*60*60*1000 (or you use the constant MSecsPerDay definded in SysUtils).
And another remark for FormatDateTime: The usual symbol "h" limits the hour value to 23. If your time span is longer than one day you must put the "h" in square brackets (like in Excel), and add the parameter [fdoInterval]:
function msToHourMinSec(AMilliseconds: Integer): String;
var
t: Double;
begin
t := AMilliseconds/ MSecsPerDay;
Result := FormatDateTime('[h]:nn:ss.zzz', t, [fdoInterval]);
{
// or: if you want to split off full days
if t < 1 then
Result := FormatDateTime('h:nn:ss.zzz', t)
else
Result := IntToStr(trunc(t)) + ' days ' + FormatDateTime('h:nn:ss.zzz', t);
}
end;