Board index » cppbuilder » How can I make a Panel Transparent ??

How can I make a Panel Transparent ??


2008-01-15 02:30:27 PM
cppbuilder42
Hi
I have an image as a background picture and would like some transparent
boxes to groupe some edit and labels. So how can I make a Panel
Transparent ??
Christian..
 
 

Re:How can I make a Panel Transparent ??

Hi Christian..
Christian.. says:
Quote
Hi

I have an image as a background picture and would like some transparent
boxes to groupe some edit and labels. So how can I make a Panel
Transparent ??
Try this thread:
tinyurl.com/ysqu59
borland.public.cppbuilder.winapi
How to set TPanel Transparent
6 Sep. 2002
Kind regards
Asger
 

Re:How can I make a Panel Transparent ??

Hi Asger
I had hoped for something a bit easier I have to use about 10 boxes.
Maybe it is easier to draw a border in a Label I don't know.
Is there a easy way to draw a border in a Label ??
Christian..
Asger Joergensen wrote:
Quote
Hi Christian..

Christian.. says:
>Hi
>
>I have an image as a background picture and would like some transparent
>boxes to groupe some edit and labels. So how can I make a Panel
>Transparent ??

Try this thread:

tinyurl.com/ysqu59

borland.public.cppbuilder.winapi
How to set TPanel Transparent
6 Sep. 2002

Kind regards
Asger
 

{smallsort}

Re:How can I make a Panel Transparent ??

"Christian.." < XXXX@XXXXX.COM >wrote in message
Quote
I had hoped for something a bit easier I have to use about 10 boxes.
Maybe it is easier to draw a border in a Label I don't know.
Is there a easy way to draw a border in a Label ??
TLabel might not be the best option. TShape can be used for a simple flat
border. Set its brush style to bsClear. If you desire fancier drawing then
use a TPaintBox and draw your border in its OnPaint event handler. Or you
can use a TImage and let it manage the redraws for you. All of these
controls are descended from TGraphicControl so will not obscure their
parent's background.
If this doesn't help then please post a little more about what you are
trying to accomplish.
Clayton
 

Re:How can I make a Panel Transparent ??

Hi Clayton
Thanks a lot, that was just what I was looking for..
Great..!
Christian..
Clayton Arends wrote:
Quote
"Christian.." < XXXX@XXXXX.COM >wrote in message
news:478c6852$ XXXX@XXXXX.COM ...

>I had hoped for something a bit easier I have to use about 10 boxes.
>Maybe it is easier to draw a border in a Label I don't know.
>Is there a easy way to draw a border in a Label ??

TLabel might not be the best option. TShape can be used for a simple
flat border. Set its brush style to bsClear. If you desire fancier
drawing then use a TPaintBox and draw your border in its OnPaint event
handler. Or you can use a TImage and let it manage the redraws for
you. All of these controls are descended from TGraphicControl so will
not obscure their parent's background.

If this doesn't help then please post a little more about what you are
trying to accomplish.

Clayton

 

Re:How can I make a Panel Transparent ??

Is it possible i design time to lock edit/labels and other shapes to
the Shape ?
Clayton Arends wrote:
Quote
"Christian.." < XXXX@XXXXX.COM >wrote in message
news:478c6852$ XXXX@XXXXX.COM ...

>I had hoped for something a bit easier I have to use about 10 boxes.
>Maybe it is easier to draw a border in a Label I don't know.
>Is there a easy way to draw a border in a Label ??

TLabel might not be the best option. TShape can be used for a simple
flat border. Set its brush style to bsClear. If you desire fancier
drawing then use a TPaintBox and draw your border in its OnPaint event
handler. Or you can use a TImage and let it manage the redraws for
you. All of these controls are descended from TGraphicControl so will
not obscure their parent's background.

If this doesn't help then please post a little more about what you are
trying to accomplish.

Clayton

 

Re:How can I make a Panel Transparent ??

Hi Christian..
Christian.. says:
Quote
Is it possible i design time to lock edit/labels and other shapes to
the Shape ?
No, they are VCL graphic controls and they have no window
if You need the ability to parent controls You need to
derive a component from TPanel TcustomPanel or another
control that do have a window.
There is a free transparent panel at Tory but it is
kind of old so I don't know if its any good.
tinyurl.com/2fltlb
But it is easy to derive a new component from TPanel
just choose menu Component->New Component and then write
TPanel and the name os Your new component.
Here is a panel with an OnPaint event:
typedef void __fastcall (__closure *TPaintEvent)
(TObject *Sender, TCanvas* Canvas);
class TBkgPanel :public TPanel
{
TPaintEvent FOnPaint;
protected:
virtual void Paint()
{
if(FOnPaint)FOnPaint(this, Canvas);
else TPanel::Paint();
}
published:
__property TPaintEvent OnPaint = {read=FOnPaint, write=FOnPaint};
};
Boian Mitow have some free panels on his site with full c++
source where You can see how to draw the bevel and the border
www.mitov.com (Look for free Download - VCL components)
another way would be to make the panel copy the part of the
image that it covers to its own canvas.
class TBkgPanel :public TPanel
{
TImage* FImage;
protected:
virtual void Paint();
void __fastcall setImage(TImage* Val);
published:
__property TImage* Image = {read=FImage, write=setImage};
};
virtual void TBkgPanel::Paint()
{
if( ComponentState.Contains(csLoading) )return;
if( ! FImage)TPanel::Paint();
// use BitBlt to copy a part of the TImage to the Canvas
// BitBlt(Canvas->Handle, 0, 0, Width, Height,
// FImage->Canvas->Handle,FImage->Left + Left,
// FImage->Top + Top, SCRCOPY);
// and then draw the border
}
void __fastcall TBkgPanel::setImage(TImage* Val)
{
FImage = Val;
Invalidate();
}
P.s. The code is written here in my newsreader, so it
might give some errors..;-)
I don't know if You use a TImage to hold the BkgBitmap, but if
You are You will get less flicker if You make the Image invisible
and then in the Form OnPaint event use BitBlt to copy the image
to the Form Canvas
Kind regards
Asger
 

Re:How can I make a Panel Transparent ??

"Christian.." < XXXX@XXXXX.COM >wrote in message
Quote
Is it possible i design time to lock edit/labels and other shapes to the
Shape ?
You can't lock them together in the same way that you can with panels. Only
those controls descending from TWinControl can be a parent to other TControl
objects. However, you can get pretty close by using the Anchor property or
by responding to the OnResize event of the shape that you'd like to be the
logical "parent". It might take a little bit of code but you can achieve a
reasonable effect.
You might want to check out Asger's suggestions in case one of those
controls will work best for you.
Clayton
Quote


Clayton Arends wrote:
>"Christian.." < XXXX@XXXXX.COM >wrote in message
>news:478c6852$ XXXX@XXXXX.COM ...
>
>>I had hoped for something a bit easier I have to use about 10 boxes.
>>Maybe it is easier to draw a border in a Label I don't know.
>>Is there a easy way to draw a border in a Label ??
>
>TLabel might not be the best option. TShape can be used for a simple
>flat border. Set its brush style to bsClear. If you desire fancier
>drawing then use a TPaintBox and draw your border in its OnPaint event
>handler. Or you can use a TImage and let it manage the redraws for you.
>All of these controls are descended from TGraphicControl so will not
>obscure their parent's background.
>
>If this doesn't help then please post a little more about what you are
>trying to accomplish.
>
>Clayton
>
 

Re:How can I make a Panel Transparent ??

Hi Clayton
Clayton Arends says:
Quote
However, you can get pretty close by using the Anchor property
Have You tried using the anchor properties with apps that have to
scale to another PixelPerInch setting ?
In my expirience they work realy bad, setting the right and bottom
anchor can make controls apear outside the form when it scales.
Just my expirience
Kind regards
Asger
 

Re:How can I make a Panel Transparent ??

"Asger Joergensen" < XXXX@XXXXX.COM >wrote in message
Quote
Have You tried using the anchor properties with apps that have to
scale to another PixelPerInch setting ?
Yes, when the system font DPI is different the designed Anchor property does
not look correct. If you set the Anchor after the form is shown everything
works fine.
Clayton
 

Re:How can I make a Panel Transparent ??

Hi Clayton
Clayton Arends says:
Quote
"Asger Joergensen" < XXXX@XXXXX.COM >wrote in message
news: XXXX@XXXXX.COM ...

>Have You tried using the anchor properties with apps that have to
>scale to another PixelPerInch setting ?

Yes, when the system font DPI is different the designed Anchor property does
not look correct. If you set the Anchor after the form is shown everything
works fine.
Your right, I have used that a couple of times, but it kind of take
away the eas of designing.
By the way do You know if this is a VCL bug or a Windows bug ?
Kind regards
Asger
 

Re:How can I make a Panel Transparent ??

"Asger Joergensen" < XXXX@XXXXX.COM >wrote in message
Quote
By the way do You know if this is a VCL bug or a Windows bug ?
I would classify it as a VCL bug. The VCL resizes the form (not Windows)
when it notices a DPI difference. It should also change the anchored
positions after adjusting the form size. I haven't looked at the VCL code
for this so I don't even know if they made an attempt to adjust the anchors.
Clayton