 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Joe Guest
|
Posted: Wed Feb 01, 2006 5:30 pm Post subject: paintbox background painting issue |
|
|
Hello everybody
I have derived a custom paintobx from TPaintbox.
now i wish to paint a background bitmap so i have added a Background
(TPicture) property (linked with a fBackground private member) and put the
paint stuff into the Paint procedure (see below) and trying 2 solutions.
It seemed to works but in the test application i put a MyPaintbox object
inside a scrollbox and although the background is correctly displayed at
first, as soon as i scroll down or upwards the scrollbox's scrollbars the
background gets temporarily messed up until i call again the paint routine
(for example with Invalidate).
How could I solve in order to keep the bitmap, say, always perfecty
stretched inside the whole paintbox boundsrect even when scrolling down/up
the scrollbox's scrollbars?
thanks in advance for any help/tip about the above
Joe
---
procedure TMyPaintBox.Paint;
var Graphic: TGraphic;
R: TRect;
begin
Canvas.Lock;
try
{ draw background image }
if Background.Graphic <> nil then
begin
Graphic := Background.Graphic;
R := Canvas.ClipRect;
// solution 1
// Canvas.StretchDraw(R, Graphic);
// solution 2
Canvas.StretchDraw(BoundsRect, Graphic);
end;
{ do other paint stuff }
.....
finally
Canvas.UnLock;
end;
inherited;
end;
|
|
| Back to top |
|
 |
Peter Below (TeamB) Guest
|
Posted: Wed Feb 01, 2006 7:15 pm Post subject: Re: paintbox background painting issue |
|
|
In article <43e0ef77 (AT) newsgroups (DOT) borland.com>, Joe wrote:
| Quote: | I have derived a custom paintobx from TPaintbox.
now i wish to paint a background bitmap so i have added a Background
(TPicture) property (linked with a fBackground private member) and put the
paint stuff into the Paint procedure (see below) and trying 2 solutions.
It seemed to works but in the test application i put a MyPaintbox object
inside a scrollbox and although the background is correctly displayed at
first, as soon as i scroll down or upwards the scrollbox's scrollbars the
background gets temporarily messed up until i call again the paint routine
(for example with Invalidate).
How could I solve in order to keep the bitmap, say, always perfecty
stretched inside the whole paintbox boundsrect even when scrolling down/up
the scrollbox's scrollbars?
if Background.Graphic <> nil then
begin
Graphic := Background.Graphic;
R := Canvas.ClipRect;
// solution 1
// Canvas.StretchDraw(R, Graphic);
// solution 2
Canvas.StretchDraw(BoundsRect, Graphic);
|
You are making a faulty assumption here: that the Canvas.Cliprect will be
the area of the paintbox (it's clientrect). That is not the case, if the
scrollbox is scrolled the cliprect of the next paint request will just be the
area uncovered by the scrolling. That is why your first approach fails. Using
Boundsrect is also not correct, you should use Clientrect.
Have you set the Align property of the paintbox instance you dropped on the
scrollbox to anything other than alNone, by the way?
--
Peter Below (TeamB)
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be
|
|
| Back to top |
|
 |
Joe Guest
|
Posted: Thu Feb 02, 2006 11:58 am Post subject: Re: paintbox background painting issue |
|
|
Thank you Peter
yes i agree, solution 1 was just a test
using your suggestion, ClientRect in place of BoundsRect works fine
yes the Align property is alNone
thanks again
Joe
"Peter Below (TeamB)" <100113.1101 (AT) compuXXserve (DOT) com> wrote:
| Quote: | You are making a faulty assumption here: that the Canvas.Cliprect will be
the area of the paintbox (it's clientrect). That is not the case, if the
scrollbox is scrolled the cliprect of the next paint request will just be
the
area uncovered by the scrolling. That is why your first approach fails.
Using
Boundsrect is also not correct, you should use Clientrect.
Have you set the Align property of the paintbox instance you dropped on
the
scrollbox to anything other than alNone, by the way?
|
|
|
| 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
|
|