Hi,

Ok I understand a little more of what you are trying to do.

Windows has two main drawing modes: One mode windows draws the windows itself, 
the other is where you draw the window (ie, supply the paint event). You can 
mix styles, but it gets very complicated as you have to treat the window in 
certain ways depending on what controls are present. Googling with "owner drawn 
windows" should give you more examples. If you dont need windows controls, then 
things will become easyer.

For performance reasons you need to use an off screen DC to keep updated (I 
think one of the examples does this) and then only update the the main window 
when necessary (blitting to an offscreen DC is much faster). Both the offscreen 
DC and the window would be blitted to so you should have no problem maintain 30 
frames a second. 

Cheers,

jeremy.

From: msjuni...@hotmail.com
To: jez_wh...@hotmail.com; perl-win32-gui-users@lists.sourceforge.net
Date: Sat, 13 Dec 2008 16:51:16 -0500
Subject: Re: [perl-win32-gui-users] Drawing transparently.








Jeremy,
first off thank you for the reply.

The example you've given works visually, but it is not what I intended to do 
obtain. :-)
I think I should have given more details at the beginning. :-)

The project I am currently working on will "repaint" ca 30 times per second.
It will be a full-screen application with some data overlayed at the 
aforementioned sample rate.
The intention is/was to use a series of labels to transparently display the 
information. I say labels but it could be any other object/container that can 
be used within the main window and that supports transparency.
Why? The original intention was to minimize the amount of "blitting" (for 
performance and appearance reasons) as much as possible by using "containers" 
which size is limited to the changed area.
Hope this is a bit clearer and thank you again for the help.

Giuseppe   

From: jez_wh...@hotmail.com
To: msjuni...@hotmail.com; perl-win32-gui-users@lists.sourceforge.net
Subject: RE: [perl-win32-gui-users] Drawing transparently.
Date: Sat, 13 Dec 2008 18:03:18 +0000








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: msjuni...@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!
Send e-mail faster without improving your typing skills. Get your HotmailĀ® 
account.
_________________________________________________________________
Imagine a life without walls.Ā  See the possibilities. 
http://clk.atdmt.com/UKM/go/122465943/direct/01/
------------------------------------------------------------------------------
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/

Reply via email to