 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Tomasz Piasecki Guest
|
Posted: Wed Oct 08, 2003 6:45 pm Post subject: TImageList::Draw changes TCanvas properties |
|
|
Hi,
I have a problem with TImageList. Drawing image from image list on PaintBox
canvas using Draw method with Enabled=false, such as:
MyImageList->Draw(MyPaintBox->Canvas, xpos, ypos, imageindex, false);
causes chage to canvas state. For example text painted by TextOut on this
canvas after that has different background or is inverted. To make things
worse, even setting again Canvas->Pen->Color, Canvas->Brush->Color,
Canvas->TextMode, Canvas->CopyMode doesn't help much.
There's no problem with drawing enabled images from TImageList.
Any ideas?
TP.
|
|
| Back to top |
|
 |
Damon Chandler (TeamB) Guest
|
Posted: Sun Oct 12, 2003 2:26 am Post subject: Re: TImageList::Draw changes TCanvas properties |
|
|
Tomasz,
| Quote: | MyImageList->Draw(MyPaintBox->Canvas, xpos, ypos, imageindex, false);
causes chage to canvas state. [snip]
|
You're right. Unfortunately, the TImageList::Draw() method [specifically,
the virtual TCustomImageList::DoDraw() method] does change various
state-properties of the Canvas without restoring them. Try wrapping the
call to Draw() with the SaveDC() and RestoreDC() GDI functions...
HDC const hDC = PaintBox1->Canvas->Handle;
SaveDC(hDC);
ImageList1->Draw(PaintBox1->Canvas, 0, 0, 0, false);
RestoreDC(hDC, -1);
HTH,
Damon (TeamB)
|
|
| Back to top |
|
 |
Tomasz Piasecki Guest
|
Posted: Sun Oct 12, 2003 10:30 am Post subject: Re: TImageList::Draw changes TCanvas properties |
|
|
Damon Chandler (TeamB) wrote:
| Quote: | You're right. Unfortunately, the TImageList::Draw() method [specifically,
the virtual TCustomImageList::DoDraw() method] does change various
state-properties of the Canvas without restoring them. Try wrapping the
call to Draw() with the SaveDC() and RestoreDC() GDI functions...
Thanks, this workaround works fine. |
TP.
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|