Showing posts with label function. Show all posts
Showing posts with label function. Show all posts

Thursday, 7 March 2013

Time to string function

Here is a very simple time to string function.


function TimeToStr(dTime: Double): string;
begin
  Result := Format('%4.2f', [dTime]);
end;

Tuesday, 11 December 2012

Determine if a colour light

Below is a Delphi function to determine whether a colour is light, this is useful if a user can for example change the background colour of a control, you will need then to set the font colour correctly.


function ColourIsLight(Colour: TColor): boolean;
begin
    Colour := ColorToRGB(Colour);
    Result := ((Colour and $FF) + (Colour shr 8 and $FF) + (Colour shr 16 and    $FF)) >= $180;
end;