Hi,

I think you are mixing drawing styles - try the below:

cheers,

jez.

use strict;
use warnings;
use Win32::GUI();
use Win32::GUI::DIBitmap;

use FindBin();

$|++;

my $interval = 1000;

my $dib = newFromFile Win32::GUI::DIBitmap("Zapotec.bmp")
or die "newFromFile";

my $main = Win32::GUI::Window->new(
-name => 'Main',
-width => 150,
-height => 100,
-onTimer => \&redraw_Timer,
-onPaint => \&Main_Paint,
-text => 'Transparent Label',
);

$main->AddTimer( "redraw_Timer", $interval );

my $label = $main->AddLabel(
-text => scalar(localtime),
-addstyle => 11, # TRANSPARENT
);

#-------------------------------------------------------------------------------
$main->Show();
Win32::GUI::Dialog();
$main->Hide();
exit(0);

#-------------------------------------------------------------------------------

sub Main_Paint {
printf( "[%s] Main Paint Event Fired.\n", scalar(localtime) );
my $self = shift;
my $dc = shift;
my ( $width, $height ) = ( $self->GetClientRect )[ 2 .. 3 ];
$dib->StretchToDC( $dc, 0, 0, $width, $height );
$dc->BkMode(1);
$dc->TextOut(4,14,scalar(localtime));
$dc->Validate();
return 1;
}

sub Main_Terminate {
-1;
}

sub redraw_Timer {
my $temp = localtime;
$main->InvalidateRect(1); # Forces Redraw
select( undef, undef, undef, 1 / 4 );
$label->Text($temp);
}

> From: msjuniorc@hotmail.com
> To: perl-win32-gui-users@lists.sourceforge.net
> Date: Fri, 12 Dec 2008 08:56:27 -0800
> Subject: [perl-win32-gui-users] Drawing transparently.
>
> Hi all,
> I put together a smaller example to better show my issue.
>
> <code>
> #!/C/Perl/bin/perl.exe
> use strict;
> use warnings;
> use Win32::GUI();
> use Win32::GUI::DIBitmap;
>
> $|++;
>
> my $interval = 1000;
>
> my $dib = newFromFile Win32::GUI::DIBitmap("Zapotec.bmp")
> or die "newFromFile";
>
> my $main = Win32::GUI::Window->new(
> -name => 'Main',
> -width => 150,
> -height => 100,
> -onTimer => \&redraw_Timer,
> -onPaint => \&Main_Paint,
> -text => 'Transparent Label',
> );
>
> $main->AddTimer( "redraw_Timer", $interval );
>
> my $label = $main->AddLabel(
> -text => scalar(localtime),
> -addstyle => 11, # TRANSPARENT
> );
>
> #-------------------------------------------------------------------------------
> $main->Show();
> Win32::GUI::Dialog();
> $main->Hide();
> exit(0);
>
> #-------------------------------------------------------------------------------
>
> sub Main_Paint {
> printf( "[%s] Main Paint Event Fired.\n", scalar(localtime) );
> my $self = shift;
> my $dc = shift;
> my ( $width, $height ) = ( $self->GetClientRect )[ 2 .. 3 ];
> $dib->StretchToDC( $dc, 0, 0, $width, $height );
> $dc->Validate();
> return 1;
> }
>
> sub Main_Terminate {
> -1;
> }
>
> sub redraw_Timer {
> my $temp = localtime;
> $main->InvalidateRect(1); # Forces Redraw
> select( undef, undef, undef, 1 / 4 );
> $label->Text($temp);
> }
> </code>
>
> If I remove the bitmap background (onPaint) and add a "-background => [0,255,0]," to the Main window I obtain the desired result. Unfortunately in my case I am dealing with a background obtained via DC cals.
>
> Again, thank you in advance for any help.
>
> Giuseppe
>
>
> ------------------------------------------------------------------------------
> SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
> The future of the web can't happen without you. Join us at MIX09 to help
> pave the way to the Next Web now. Learn more and register at
> http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
> _______________________________________________
> 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/


Take your friends with you with Mobile Messenger. Click Here!