Recent

Author Topic: How to make ATScrollbar semi transparent?  (Read 454 times)

Alextp

  • Hero Member
  • *****
  • Posts: 1229
    • UVviewsoft
How to make ATScrollbar semi transparent?
« on: January 19, 2021, 11:50:48 am »
Photoshop with the CudaText user's wish:
https://i.imgur.com/miwhc9z.gif

How to implement it? ATScrollbar (from ATFlatControls) is used yet. It cannot paint itself like this. It is filled yet.
User wants that it paints itself like transparent over the ATSynEdit text.

440bx

  • Hero Member
  • *****
  • Posts: 2174
Re: How to make ATScrollbar semi transparent?
« Reply #1 on: January 19, 2021, 02:35:46 pm »
Are you looking for a multiplatform solution or would a Windows only solution be sufficient ?
FPC v3.0.4 and Lazarus 1.8.2 on Windows 7 64bit.

Alextp

  • Hero Member
  • *****
  • Posts: 1229
    • UVviewsoft
Re: How to make ATScrollbar semi transparent?
« Reply #2 on: January 19, 2021, 03:26:25 pm »
Windows only will be sufficient.

440bx

  • Hero Member
  • *****
  • Posts: 2174
Re: How to make ATScrollbar semi transparent?
« Reply #3 on: January 19, 2021, 04:52:59 pm »
First I have to mention that I have _not_ coded anything that works exactly that way but an idea come to mind.

That scrollbar seems to use the WS_EX_LAYERED along with a NULL_BRUSH as its background, either that or a combination of WS_EX_COMPOSITED and WS_EX_TRANSPARENT.

Presuming it is using WS_EX_LAYERED (most likely), the WS_EX_LAYERED causes Windows to blend whatever is shown in the window, scrollbar in this case, to be blended with whatever is behind it.

the NULL_BRUSH causes any unpainted portions of the scrollbar to effectively be transparent. (blending a null brush with "anything that's behind it" will yield the "anything that's behind it".

The change in darkness is likely caused by simply painting a darker shade of grey.  Windows will blend it automatically with whatever is behind it.

Note that using the WS_EX_LAYERED that way is only supported on Windows 8 and above.  On previous versions of Windows that support that extended style, it can only be used on the top level windows and the scrollbar isn't one.

I don't have an example of using WS_EX_LAYERED but, there is an example for a somewhat related question on stackoverflow at https://stackoverflow.com/questions/3970066/creating-a-transparent-window-in-c-win32 the last portion of the example code applies to painting/repainting the scrollbar you want.

HTH.

FPC v3.0.4 and Lazarus 1.8.2 on Windows 7 64bit.

Alextp

  • Hero Member
  • *****
  • Posts: 1229
    • UVviewsoft
Re: How to make ATScrollbar semi transparent?
« Reply #4 on: January 19, 2021, 04:56:29 pm »
Good, thanks.
After my thinking about cross platform method:

Scrollbar can have OnGetBackground event which can request from ATSynEdit the bitmap behind. Then scrollbar can paint this bitmap + smth above it.

jamie

  • Hero Member
  • *****
  • Posts: 4199
Re: How to make ATScrollbar semi transparent?
« Reply #5 on: January 22, 2021, 01:13:13 am »
unless you custom make your own scrollbar, using the windows scrollbar control is not going to allow you to custom draw it..
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018