TRealTimeMarquee v2.3 Problem

Please post bug reports, feature requests, or any question regarding the DELPHI AREA products here.

TRealTimeMarquee v2.3 Problem

Postby KenR » December 15th, 2009, 10:05 am

Hi,

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
KenR
Member
Member
 
Posts: 2
Joined: December 15th, 2009, 9:50 am

Re: TRealTimeMarquee v2.3 Problem

Postby Kambiz » December 15th, 2009, 1:42 pm

Seems your code is not thread safe. Seeing your code of OnDrawItem handler will be a great help to find out the problem.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

Re: TRealTimeMarquee v2.3 Problem

Postby KenR » December 15th, 2009, 10:11 pm

I'm sorry, but that was the code of my OnDrawItem event!

Ken
KenR
Member
Member
 
Posts: 2
Joined: December 15th, 2009, 9:50 am


Return to DELPHI AREA Products

Who is online

Users browsing this forum: No registered users and 3 guests

cron