Great component but I keep getting an EOutOfResources exception after it has been running for a while. I am using the OnDrawItem event to write image and text to the bitmap. I'm using D2007 running under XP.
This is the code of the event:
- Code: Select all
procedure TCarouselForm.MarqueeDrawItem(Sender: TObject; Item: TMarqueeItem; Bitmap: TBitmap);
var
R:TRect;
tm:TTextMetricW;
OldFont:HFONT;
DC:HDC;
Size:TSize;
begin
DC:=CreateCompatibleDC(0);
try
OldFont:=SelectObject(DC,Marquee.Font.Handle);
try
GetTextExtentPoint32W(DC,PWideChar(Item.Text),Length(Item.Text),Size);
GetTextMetricsW(DC,tm);
finally
SelectObject(DC,OldFont);
end;
finally
DeleteDC(DC);
end;
Inc(Size.cx,tm.tmAveCharWidth);
R.Left:=40;
R.Top:=0;
R.Right:=40+Size.cx;
R.Bottom:=32;
Bitmap.Width:=40+Size.cx;
Bitmap.Height:=32;
Bitmap.Canvas.Brush.Color:=Marquee.Color;
Bitmap.Canvas.Font:=Marquee.Font;
Bitmap.Canvas.FillRect(R);
Bitmap.Canvas.Brush.Style:=bsClear;
DrawTextW(Bitmap.Canvas.Handle,PWideChar(Item.Text), Length(Item.Text),R,
Marquee.DrawTextBiDiModeFlags(DT_CENTER or DT_NOCLIP or DT_NOPREFIX or DT_SINGLELINE));
BulletImageList.Draw(Bitmap.Canvas,Rect(0,0,32,32),Item.Tag,False);
end;
Any help would be greatly appreciated.
Ken