 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Tom de Neef Guest
|
Posted: Wed Jan 11, 2006 10:08 pm Post subject: Two Tpaintboxes over each other |
|
|
I have two Tpaintboxes on a form. PB1 is client aligned. BP2 is a small area
somewhere over it.
In reality, PB2 is created at run-time, but that seems not to matter for the
argument.
PB2 is drawn with BrushStyle=bsClear, so that its image overlays the image
of PB1. Both are painted on demand via the OnPaint event.
On display, the picture comes out as expected. I.e. PB2 overlays PB1.
But when I programmatically repaint PB1, the image of PB2 disappears. That
must be because PB1 is repainting the whole canvas, and PB2 is not triggered
to repaint, so its image is just gone. That is not what I want. So, in the
handler for PB1.onPaint I add a call to PB2.repaint. Problem solved.
But in this approach, PB2 is painted twice if another form moves over the
paintboxes. For, PB2.onPaint will be triggered by the OS and again by PB1.
This is undesirable. Sometimes you can even see that text in PB2 is slightly
blurred - a thing I don't understand. The 'blur' (a minute raffle on the
font edge) disappears when I repaint PB2.
I can solve the problem by putting PB2 on a separate - transparent - form.
But then of course, the two paintboxes will not move together when you
scroll. Aand anyway, it sounds like a wrong approach.
Any suggestions?
Tom
|
|
| Back to top |
|
 |
Tom de Neef Guest
|
Posted: Thu Jan 12, 2006 9:46 am Post subject: Re: Two Tpaintboxes over each other |
|
|
"Bjørge" <bjorge (AT) kuttvekkitte (DOT) no> schreef in bericht
news:25ednUUzM9c6AFjeRVnzvA (AT) telenor (DOT) com...
| Quote: | Tom de Neef wrote:
I can solve the problem by putting PB2 on a separate - transparent -
form. But then of course, the two paintboxes will not move together
when you scroll. Aand anyway, it sounds like a wrong approach.
Any suggestions?
Why have two paintboxes in the first place ? Why not paint it all in one
box
?
|
The background is a picture. Paintbox2 contains user-defined labels that can
be placed over the picture, formatted and moved under user control. (Like
titles in an Excel graph.)
| Quote: |
*If* there is a reason why you should do this, when painting the first box
do a
PaintBox2.Invalidate;
|
It still vanishes when baintbox1 is repainted. But you got me thinking. I
solved this now by making paintbox1 transparent as well. Since most of its
surface is blank anyway, this works out fine. Thank you.
Tom
|
|
| Back to top |
|
 |
alanglloyd@aol.com Guest
|
Posted: Thu Jan 12, 2006 7:41 pm Post subject: Re: Two Tpaintboxes over each other |
|
|
Why not copy a certain rectangle (of the label size) of the background
to a bitmap and draw/text the label at the position. Then when the
label is moved under mouse control, copy back the saved bitmap and
resave the rectangle at the next position of the mouse/label.
I've used this quite successfully when allocating functions to a
three-pedal foot-switch.
Alan Lloyd
|
|
| Back to top |
|
 |
Tom de Neef Guest
|
Posted: Fri Jan 13, 2006 12:21 pm Post subject: Re: Two Tpaintboxes over each other |
|
|
<alanglloyd (AT) aol (DOT) com> schreef in bericht
news:1137094905.312491.104950 (AT) o13g2000cwo (DOT) googlegroups.com...
| Quote: | Why not copy a certain rectangle (of the label size) of the background
to a bitmap and draw/text the label at the position. Then when the
label is moved under mouse control, copy back the saved bitmap and
resave the rectangle at the next position of the mouse/label.
I've used this quite successfully when allocating functions to a
three-pedal foot-switch.
Alan Lloyd
|
Yes, that's how I used to do it before Delphi. But with visual controls
around I attempt to solve it with standard components.
Tom
|
|
| 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
|
|