Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Background transparency (developer question)
01-17-2010, 04:19 AM
Post: #1
Background transparency (developer question)
Hi,

At first I want to compliment you for great software. I find batterybar very useful.

As a developer I'm working on the project where I want to display information to the user through a Deskband, similar to your batterybar deskband (taksbar button). I have spent weeks on searching for a way to make the deskband background transparent. I have tried dozens of functions and Windows API calls, so I'm kind of desperate. I would be just great if you could give me a code snippet or any helpful information on how to make deskband have a transparent background.

I am using Delphi to develop, but if you are using another dev. environment it could be the same API call or I could try to translate the code. Please help.

Thank you.

Slava
Quote this message in a reply
01-18-2010, 09:58 AM (This post was last modified: 01-18-2010 09:59 AM by Chris.)
Post: #2
RE: Background transparency (developer question)
The code is C#.

In my IDeskBand implementation, I override the PaintBackground event:

Code:
protected override void OnPaintBackground(PaintEventArgs e)
        {
            // _canPaintThemeBackground should only be true on Windows 5.1 or greater
            if (_canPaintThemeBackground && this.BackColor == Color.Transparent)
            {
                IntPtr hdc = e.Graphics.GetHdc();
                Win32.API.DrawThemeParentBackground(this.Handle, hdc, 0);
                e.Graphics.ReleaseHdc(hdc);
            }
            else
            {
                base.OnPaintBackground(e);
            }
        }

I have the band's BackColor set to Transparent.

When I actually draw on the IDeskBand, I draw 32-bit ARGB graphics.

One caveat I haven't worked around yet: When drawing text on my ARGB graphic, I cannot use ClearType if the Alpha is less than 255 because ClearType isn't compatible with semi-transparent backgrounds. There are methods specific to Vista/7 which allow for drawing glowing text on glass effects, but I wasn't able to get those to do what I wanted. So, instead I used a drawing path to draw the text.
Visit this user's website Find all posts by this user
Quote this message in a reply
01-20-2010, 03:43 AM
Post: #3
RE: Background transparency (developer question)
Thank you very very much!

I haven't get it working yet but the information you provided gets me forward. At least I know that I'll have to override the OnPaintBackground event to achieve this. With some more research on this part I will surely be able to implement it.

Kind regards,
Slava
Quote this message in a reply
Post Reply 




Real Time Web Analytics