procedure TDupFind_Main.WritePercent(Progressbar: TProgressbar);
var
dc: HDC;
myfont: Cardinal;
rect: TRect;
Text:
string;
begin
if (ProgressBar.Max = 0)
or (ProgressBar.Position = 0)
then
Text := '
0%'
else if ProgressBar.Max = ProgressBar.Position
then
Text := '
100%'
else
Text := IntToStr(Trunc(100 / ProgressBar.Max * ProgressBar.Position)) + '
%';
dc := GetWindowDC(Progressbar.Handle);
myfont := CreateFont(-12, 0, 0, 0, 0, 0, 0, 0, ANSI_CHARSET,
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH,
'
Verdana');
SetBkMode(
dc, TRANSPARENT);
SetTextColor(
dc, clBlack);
SelectObject(
dc, myfont);
rect := ProgressBar.ClientRect;
SetBkMode(
dc, TRANSPARENT);
DrawText(
dc, PChar(Text), length(Text), rect, DT_SINGLELINE
or DT_VCENTER
or
DT_CENTER);
InvalidateRect(Progressbar.Handle, @rect, True);
end;