 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Guthrie Ward Guest
|
Posted: Sat Nov 18, 2006 7:21 pm Post subject: Help with Paint procedure! |
|
|
I'm looking for help with the Paint procedure of my TGraphicControl
descendant, TNimbusButton. A transparent button-like control who's bitmap
changes to what state the mouse is in (Normal, Over, Pressed). What I'm
getting at the moment is what looks like the bitmaps are painted over each
other. How do I buffer the control so that it will return to the Normal
bitmap (FBitmap), no matter what the other bitmaps look like? Here's my
current code, and thanks in advance.
Gus
procedure TNimbusButton.Paint;
var
CurrentBmp: TBitmap;
begin
if csDesigning in ComponentState then
with Canvas do
begin
Pen.Style := psDash;
Brush.Style := bsClear;
Rectangle(0, 0, Width, Height);
end;
CurrentBmp := FBitmap;
if FMouseDown then
begin
if not FBitmapPressed.Empty then CurrentBmp := FBitmapPressed;
end else
if FMouseOver then
begin
if not FBitmapOver.Empty then CurrentBmp := FBitmapOver;
end;
CurrentBmp.TransparentColor := FTransparentColor;
CurrentBmp.Transparent := True;
Canvas.Draw(0, 0, CurrentBmp);
end; |
|
| Back to top |
|
 |
Peter Below (TeamB) Guest
|
Posted: Sun Nov 19, 2006 2:25 pm Post subject: Re: Help with Paint procedure! |
|
|
Guthrie Ward wrote:
| Quote: | I'm looking for help with the Paint procedure of my TGraphicControl
descendant, TNimbusButton. A transparent button-like control who's
bitmap changes to what state the mouse is in (Normal, Over, Pressed).
What I'm getting at the moment is what looks like the bitmaps are
painted over each other. How do I buffer the control so that it will
return to the Normal bitmap (FBitmap), no matter what the other
bitmaps look like? Here's my current code, and thanks in advance.
Gus
procedure TNimbusButton.Paint;
var
CurrentBmp: TBitmap;
begin
if csDesigning in ComponentState then
with Canvas do
begin
Pen.Style := psDash;
Brush.Style := bsClear;
Rectangle(0, 0, Width, Height);
end;
CurrentBmp := FBitmap;
|
You need to start by filling the buttons background with the buttons
Color, that will erase whatever bitmap you have displayed last.
--
Peter Below (TeamB)
Don't be a vampire (http://slash7.com/pages/vampires),
use the newsgroup archives :
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be |
|
| Back to top |
|
 |
Guthrie Ward Guest
|
Posted: Mon Nov 20, 2006 4:33 pm Post subject: Re: Help with Paint procedure! |
|
|
The button is transparent, that "takes the shape of the main bitmap" and the
other bmps are just eye candy. The problem I have is that the OnMouseOver
bmp is a different shape to the normal bmp, as it's used to add information
to the button. So I need to get rid (repaint) it without loosing the
transparency.
"Peter Below (TeamB)" <none> wrote in message
news:xn0etwg7nohts001 (AT) newsgroups (DOT) borland.com...
| Quote: | Guthrie Ward wrote:
I'm looking for help with the Paint procedure of my TGraphicControl
descendant, TNimbusButton. A transparent button-like control who's
bitmap changes to what state the mouse is in (Normal, Over, Pressed).
What I'm getting at the moment is what looks like the bitmaps are
painted over each other. How do I buffer the control so that it will
return to the Normal bitmap (FBitmap), no matter what the other
bitmaps look like? Here's my current code, and thanks in advance.
Gus
procedure TNimbusButton.Paint;
var
CurrentBmp: TBitmap;
begin
if csDesigning in ComponentState then
with Canvas do
begin
Pen.Style := psDash;
Brush.Style := bsClear;
Rectangle(0, 0, Width, Height);
end;
CurrentBmp := FBitmap;
You need to start by filling the buttons background with the buttons
Color, that will erase whatever bitmap you have displayed last.
--
Peter Below (TeamB)
Don't be a vampire (http://slash7.com/pages/vampires),
use the newsgroup archives :
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be |
|
|
| Back to top |
|
 |
Peter Below (TeamB) Guest
|
Posted: Mon Nov 20, 2006 11:42 pm Post subject: Re: Help with Paint procedure! |
|
|
Guthrie Ward wrote:
| Quote: | The button is transparent, that "takes the shape of the main bitmap"
and the other bmps are just eye candy. The problem I have is that
the OnMouseOver bmp is a different shape to the normal bmp, as it's
used to add information to the button. So I need to get rid
(repaint) it without loosing the transparency.
|
Invalidate the button when the mouse goes down or up. If you set the
ControlStyle of the button to exclude the csOpaque flag (that should be
done in the constructor) the controls parent will paint the area
underneath before the buttons Paint method is called. Do not try to
directly call Paint from the mouse event handlers or corresponding
mouse methods.
--
Peter Below (TeamB)
Don't be a vampire (http://slash7.com/pages/vampires),
use the newsgroup archives :
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be |
|
| Back to top |
|
 |
Guthrie Ward Guest
|
Posted: Sat Nov 25, 2006 9:11 am Post subject: Re: Help with Paint procedure! |
|
|
Sorted thank. I didin't inlclude the ControlStyle in the create procedure.
:D
"Peter Below (TeamB)" <none> wrote in message
news:xn0ety8osg4yl000 (AT) newsgroups (DOT) borland.com...
| Quote: | Guthrie Ward wrote:
The button is transparent, that "takes the shape of the main bitmap"
and the other bmps are just eye candy. The problem I have is that
the OnMouseOver bmp is a different shape to the normal bmp, as it's
used to add information to the button. So I need to get rid
(repaint) it without loosing the transparency.
Invalidate the button when the mouse goes down or up. If you set the
ControlStyle of the button to exclude the csOpaque flag (that should be
done in the constructor) the controls parent will paint the area
underneath before the buttons Paint method is called. Do not try to
directly call Paint from the mouse event handlers or corresponding
mouse methods.
--
Peter Below (TeamB)
Don't be a vampire (http://slash7.com/pages/vampires),
use the newsgroup archives :
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be |
|
|
| 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
|
|