Hi
Given the granularity of ttimer is 1 millisecond...
Maybe these two methods can be of use to you:
{ first from milliseconds to datetime }
procedure TIsoTime.set_AsInteger(const aValue: ptrint); //bm
var
H,M,S,MSec: word;
L: cardinal; // leftover can be a pretty high number :-)
begin
// 14.08.2022 new implementation, stored as milliseconds per day
// formula: fIntTime = ((H*3600000) + (M*60000) + (S*1000) + MSec
// H = fIntTime div 3600000; L = fIntTime mod 3600000
// M = L div 60000; L = L mod 60000
// S = L div 1000
// MSec = L mod 1000
if aValue <> fIntTime then begin
fIntTime:= aValue;
H:= fIntTime div 3600000; L:= fIntTime mod 3600000;
M:= L div 60000; L:= L mod 60000;
S:= L div 1000;
MSec:= L mod 1000;
fTime:= EncodeTime(H,M,S,MSec);
end;
end;
And from datetime to milliseconds:
procedure TIsoTime.set_AsTime(const aValue: TDateTime);
var
H,M,S,MSec: word;
begin
if aValue <> fTime then begin
H:= 0; M:= 0; S:= 0; MSec:= 0;
DecodeTime(aValue,H,M,S,MSec);
fIntTime:= ((H*3600000)+(M*60000)+(S*1000)+MSec); { changed to include msecs //bm }
fTime:= EncodeTime(H,M,S,MSec);
end;
end;
So, get the hours, minutes, seconds & milliseconds from your user and calculate the "fIntTime" above and use that in your timer value...
The procedures should be turned into functions for ease of use in your case.
Hth - Regards Benny