BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

paintbox background painting issue

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics
View previous topic :: View next topic  
Author Message
Joe
Guest





PostPosted: Wed Feb 01, 2006 10:30 pm    Post subject: paintbox background painting issue Reply with quote



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





PostPosted: Thu Feb 02, 2006 12:15 am    Post subject: Re: paintbox background painting issue Reply with quote



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





PostPosted: Thu Feb 02, 2006 4:58 pm    Post subject: Re: paintbox background painting issue Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.