* * *

Author Topic: [SOLVED]transparent TPanel?  (Read 5961 times)

jc99

  • Hero Member
  • *****
  • Posts: 516
    • My private Site
Re: transparent TPanel?
« Reply #15 on: May 26, 2017, 07:49:02 pm »
OS: Win XP x64, Win 7, Win 7 x64, Win 10, Win 10 x64, Suse Linux 13.2
Laz: 1.2 - 1.6.4, 1.8rc3
https://github.com/joecare99/public
'~|    /''
,_|oe \_,are

majid.ebru

  • Sr. Member
  • ****
  • Posts: 268
Re: transparent TPanel?
« Reply #16 on: May 26, 2017, 08:19:59 pm »
thank you
 :) ;) :D ;D

jc99

  • Hero Member
  • *****
  • Posts: 516
    • My private Site
Re: transparent TPanel?
« Reply #17 on: May 26, 2017, 08:30:07 pm »
Two Screenshots:
With the checkbox you switch the panel on and off.
« Last Edit: May 26, 2017, 08:57:21 pm by jc99 »
OS: Win XP x64, Win 7, Win 7 x64, Win 10, Win 10 x64, Suse Linux 13.2
Laz: 1.2 - 1.6.4, 1.8rc3
https://github.com/joecare99/public
'~|    /''
,_|oe \_,are

taazz

  • Hero Member
  • *****
  • Posts: 4415
Re: transparent TPanel?
« Reply #18 on: May 26, 2017, 10:22:24 pm »
Here is a quick and dirty implementation. Its Slow,(really slow but it shows the required steps). I wrote it to test Soner's post for transparency.
https://sourceforge.net/projects/evssimplegraph/files/Release/Samples/TranslucentPanel.rar/download

EDIT:
oh I just show jc99's "more interesting" solution. Really nice! thanks.
« Last Edit: May 26, 2017, 10:37:57 pm by taazz »
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

RAW

  • Hero Member
  • *****
  • Posts: 567
Re: transparent TPanel?
« Reply #19 on: May 26, 2017, 10:56:38 pm »
Unfortunately this is not working with a classic theme...  :'(
Funny, I can scroll a label inside the panel and it looks good... but yeah, it's too slow...  :D
Windows 7 Pro (x64 Sp1) And Windows XP Pro (x86 Sp3) - LAZARUS 1.8.0RC5 FPC 3.0.4

taazz

  • Hero Member
  • *****
  • Posts: 4415
Re: transparent TPanel?
« Reply #20 on: May 27, 2017, 01:48:11 am »
Unfortunately this is not working with a classic theme...  :'(
Oh! I'll disable the aero theming and see how it works thanks for the heads up.
Funny, I can scroll a label inside the panel and it looks good... but yeah, it's too slow...  :D
Yeah. There are a number of ways to make it faster inlcuding the alphablend function from the windows API. I'll take a closer look when I get a bit more time.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

jc99

  • Hero Member
  • *****
  • Posts: 516
    • My private Site
Re: transparent TPanel?
« Reply #21 on: May 27, 2017, 08:50:42 am »
@taazz:
Making the scrolling of the Label on the panel faster is no problem:
What needs time is the pixel-by-pixel-calculation of the background in the onPaint-method.
So: if you only do the necessary stuff at the necessary point of time. (and nowadays you have enough mem to store precalulated data) you get a BIG acceleration.
1. Calculating the darkend, or maybe somehow other transformed background of the form can be done at the very start of the program, maybe in a second task. It can be even done externaly (e.G: with Paint.net) like I did and be stored in the App. I mean the complete background of the form.
2. in the onpaint-method you "only" have to BitBlit the needed part of that precalculated background on the panel.
[edit]
2a) If you put a Timage on the panel even the redrawing when something is moving on the panel (e.G: the label, mentioned above) is done by the system, and you only have to paint on the Image when you move or resize the panel.
 
« Last Edit: May 27, 2017, 08:57:48 am by jc99 »
OS: Win XP x64, Win 7, Win 7 x64, Win 10, Win 10 x64, Suse Linux 13.2
Laz: 1.2 - 1.6.4, 1.8rc3
https://github.com/joecare99/public
'~|    /''
,_|oe \_,are

Pascal

  • Hero Member
  • *****
  • Posts: 530
Re: transparent TPanel?
« Reply #22 on: July 12, 2017, 01:52:53 pm »
This is very easy, at least on Windows:
Code: Pascal  [Select]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. begin
  3.   Panel1.ControlStyle := Panel1.ControlStyle - [csOpaque] + [csParentBackground];
  4. end;
  5.  
  6.  

Doesn't this work on other Platforms?
laz trunk - fpc trunk 32bit - Windows 10 Pro x64

wp

  • Hero Member
  • *****
  • Posts: 3896
Re: [SOLVED]transparent TPanel?
« Reply #23 on: July 12, 2017, 05:05:13 pm »
No, Windows only...
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

Pascal

  • Hero Member
  • *****
  • Posts: 530
Re: [SOLVED]transparent TPanel?
« Reply #24 on: July 12, 2017, 05:54:22 pm »
Is there a way to do it cross platform?
laz trunk - fpc trunk 32bit - Windows 10 Pro x64

wp

  • Hero Member
  • *****
  • Posts: 3896
Re: [SOLVED]transparent TPanel?
« Reply #25 on: July 12, 2017, 06:00:53 pm »
Nothing is impossible, but nobody did it so far (at least as far as I know). Even the current TPanel behaves differently on different platforms: Win: opaque, gtk2: transparent, qt: opaque. (Maybe I am confusing gtk2 and qt here, but I am sure that in my recent test one of them was transparent).
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

majid.ebru

  • Sr. Member
  • ****
  • Posts: 268
Re: [SOLVED]transparent TPanel?
« Reply #26 on: July 13, 2017, 06:49:03 am »
Is there a way to do it cross platform?

Hi

if it is possible ,use BGRA component

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus