Back to topic: There is a bug in the function "DrawBitmap" in the unit "frxUtils.pas" (version 4.9). The created dc (with "CreateCompatibleDC") will never be freed by call "DeleteDC".
Original code:
CODE
procedure DrawBitmap(aHandle: HDC; Dest: TRect; Bitmap: TBitmap);
var
hMemDC: HDC;
PrevStretchBltMode: Integer;
begin
hMemDC := CreateCompatibleDC(aHandle);
SelectObject(hMemDC, Bitmap.Handle);
PrevStretchBltMode := SetStretchBltMode(aHandle, STRETCH_HALFTONE);
with Dest do
StretchBlt(aHandle, Left, Top, Right - Left, Bottom - Top, hMemDC,
0, 0, Bitmap.Width, Bitmap.Height, SRCCOPY);
SetStretchBltMode(aHandle, PrevStretchBltMode);
end;
var
hMemDC: HDC;
PrevStretchBltMode: Integer;
begin
hMemDC := CreateCompatibleDC(aHandle);
SelectObject(hMemDC, Bitmap.Handle);
PrevStretchBltMode := SetStretchBltMode(aHandle, STRETCH_HALFTONE);
with Dest do
StretchBlt(aHandle, Left, Top, Right - Left, Bottom - Top, hMemDC,
0, 0, Bitmap.Width, Bitmap.Height, SRCCOPY);
SetStretchBltMode(aHandle, PrevStretchBltMode);
end;
Fixed code:
CODE
procedure DrawBitmap(aHandle: HDC; Dest: TRect; Bitmap: TBitmap);
var
hMemDC: HDC;
PrevStretchBltMode: Integer;
begin
hMemDC := CreateCompatibleDC(aHandle);
try
SelectObject(hMemDC, Bitmap.Handle);
PrevStretchBltMode := SetStretchBltMode(aHandle, STRETCH_HALFTONE);
with Dest do
StretchBlt(aHandle, Left, Top, Right - Left, Bottom - Top, hMemDC,
0, 0, Bitmap.Width, Bitmap.Height, SRCCOPY);
SetStretchBltMode(aHandle, PrevStretchBltMode);
finally
DeleteDC(hMemDC);
end;
end;
var
hMemDC: HDC;
PrevStretchBltMode: Integer;
begin
hMemDC := CreateCompatibleDC(aHandle);
try
SelectObject(hMemDC, Bitmap.Handle);
PrevStretchBltMode := SetStretchBltMode(aHandle, STRETCH_HALFTONE);
with Dest do
StretchBlt(aHandle, Left, Top, Right - Left, Bottom - Top, hMemDC,
0, 0, Bitmap.Width, Bitmap.Height, SRCCOPY);
SetStretchBltMode(aHandle, PrevStretchBltMode);
finally
DeleteDC(hMemDC);
end;
end;
When many pictures will be (re)painted, the application crashed with out-of-resources exceptions.
(Is it possible that this kind of bugs are also in other functions?