OK, that will teach me to post code before I run into head-scratching
problems :)
You can set the color-key area to be totally transparent, or you can set
the window to be a variable level of translucent, or both... but it
appears you cannot set a color-key area to be partially transparent, its
all or nothing.... unless someone can show me how
Steve
Steve Loughran wrote:
here we go, a very rough idea of how I managed to get it to work. (Am
doing a reinstall at the moment on the other machine, so things are a
bit of a mess here right now)
You will need to cut-n-paste the relevant pieces into your code, but I
hope its clear enough. I haven't managed to get translucency and
transparency to work on the same window at the same time, but I haven't
actually tried all that hard :)
Original Visual Basic info found here:
http://www.codeguru.com/vb/gen/vb_graphics/transparency/article.php/c6979__1
and
http://www.codeguru.com/vb/gen/vb_graphics/transparency/article.php/c6981/
#==============================
#for the "SetLayeredWindowAttributes" call import
use Win32::API;
use constant WS_EX_LAYERED => 0x00080000;
use constant LWA_COLORKEY => 0x00000001;
use constant LWA_ALPHA => 0x00000002;
use constant GWL_EXSTYLE => -20;
my $SetLayeredWindowAttributes =
Win32::API->new("user32","SetLayeredWindowAttributes", "LLIN", "I")
or die "Failed to load SetLayeredWindowAttributes: $!";
#============
# For Translucency
#
# This affects the entire window and contents
#
# where $value is between 255 (solid) and 0 (invisible)
#============
my $winstyle = $window->GetWindowLong(GWL_EXSTYLE);
$winstyle = $winstyle | WS_EX_LAYERED;
$window->SetWindowLong(GWL_EXSTYLE, $winstyle || WS_EX_LAYERED);
$SetLayeredWindowAttributes->Call($window->{-handle}, 0, $value,
LWA_ALPHA);
#============
# For Transparency
#
# This makes color-keyed areas transparent, so any area of the window
# or any item within it that has the exact RGB color match will be
# affected by any applied transparency. The rest of the window and items
# within it will be unaffected by this.
#
# where $value is a 0x00bbggrr color value
# where $alpha is from 255 (solid) to 0 (completely transparent)
#
# NOTE: where the $alpha is 0, you can click-through the window into
# windows behind it through those transparent areas!! Seriously!
#============
my $winstyle = $window->GetWindowLong(GWL_EXSTYLE);
$winstyle = $winstyle | WS_EX_LAYERED;
$window->SetWindowLong(GWL_EXSTYLE, $winstyle || WS_EX_LAYERED);
$SetLayeredWindowAttributes->Call($window->{-handle}, $value, $alpha,
LWA_COLORKEY);
#==============================
I hope that is helpful to someone.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
http://perl-win32-gui.sourceforge.net/