RE: [perl-win32-gui-users] {Spam?} MDIFrame and background Image

2005-08-07 Thread Kind, Uwe
> Hello, perl-win32-gui-users, 
> 
> Anybody knows if it's possible  to display a background bitmap image  in a

> MDIFrame? If it's possible, I will appreciate a short example .
> 
> I'm using de MDI.pl example (Win32-GUI examples) for test. 
> 
> Thanks!

One possibility is to add a Label with a bitmap to the MDIFrame:

 $Window = new Win32::GUI::MDIFrame (
 ...
 -onResize => sub { $Window->{BGImg}->Resize($Window->ScaleWidth(),
$Window->ScaleHeight())
  },
 ) or die "Window";

 my $bgimg = new Win32::GUI::Label (
 -parent  => $Window,
 -name=> 'BGImg',
 -bitmap  => my $bitmap = new Win32::GUI::BitmapInline(q( ... )),
 ) or die "BGImg";

The problem is, that you will have to catch quite a lot of messages/events
because the repainting of the Label and sometimes even the MDIChilds isn't
done in the way one would expect and so you'll have to take care of it on
your own.

Regards,
Uwe.



[perl-win32-gui-users] DC used for customdrawn Toolbar

2005-08-07 Thread Kind, Uwe
Hello perl-win32-gui-users,

I'm trying to change the TextColor of a Coolmenu on _Deactivate and
_Activate of the parent-window to emulate the original IE behaviour.
In my understanding of the MSDN-documentation a Toolbar-Control,
receiving a NM_CUSTOMDRAW-notification, should behave in exactly the
same way as a Header does. But in contrast to a Header the DC, supplied
in the NMTBCUSTOMDRAW-structure, seems not to be the one being used to
paint the control (see example below).
On the other hand, when returning CDRF_SKIPDEFAULT, the DC you get can
be used to draw the ToolbarItems on your own (but I'm definitely too
lazy to do so).

Any suggestions?

TIA
Uwe

#!perl -w

use strict;
use Win32::GUI;

my $mw = new Win32::GUI::Window
 (  -name   =>  'MainWindow',
-text   =>  'CustomDraw',
-pos=>  [ 100, 100 ],
-size   =>  [ 300, 350 ],

-onTerminate=>  sub { -1 },
-onDeactivate   =>  sub { $_ [ 0 ] -> InvalidateRect ( 0 ) },
-onActivate =>  sub { $_ [ 0 ] -> InvalidateRect ( 0 ) },
 );

my $ft = new Win32::GUI::Font
 (  -name   =>  'Font',
-size   =>  8,
-face   =>  'Tahoma',
);

my $tb = $mw -> AddToolbar
 (  -name   =>  'Toolbar',
-pos=>  [ 0, 0 ],
-size   =>  [ $mw -> ScaleWidth (), 23 ],
-font   =>  $ft,
-nodivider  =>  1,
-flat   =>  1,
-list   =>  1,
-pushstyle  =>  12,

-onButtonClick  =>  sub { $mw-> { 'ListBox' } -> ResetContent () },
 );

for ( 0 .. 3 )
{
$tb -> AddString  ( "Test $_" );
$tb -> AddButtons ( 1, -2, 1000 + $_, 4,  88, $_ );
}

my $hd = $mw -> AddHeader
 (  -name   =>  'Header',
-pos=>  [ 0, $tb -> Height () ],
-size   =>  [ $mw -> ScaleWidth (),
  20
],
-font   =>  $ft,
-buttons=>  1,
 );

for ( 0 .. 2 )
{
$hd -> InsertItem
 (  -index  =>  $_ ,
-text   =>  "Test $_",
-width  =>  $hd -> ScaleWidth () / 3,
 );
}

my $lb = $mw-> AddListbox
(   -name   =>  'ListBox',
-pos=>  [ 0, $tb -> Height () + $hd -> Height () ],
-size   =>  [ $mw -> ScaleWidth (),
  $mw -> ScaleHeight () - $tb -> Height ()
- $hd -> Height ()
],
);

$hd -> Hook ( -12, \&onCustumDraw );
$tb -> Hook ( -12, \&onCustumDraw );

$mw -> Show ();
Win32::GUI::Dialog ();

sub onCustumDraw
{
my ($object, $wparam, $lparam, $message_type, $message_code ) = @_;

( return () ) unless ( $message_type == 78 );
( return () ) unless ( $message_code == -12 );

my $pNMTBCD = pack (  'L!', $lparam );
my $sNMTBCD = unpack( 'P20', $pNMTBCD );
my ($dwDrawStage, $dc ) = unpack ( 'x12IL', $sNMTBCD );

if ( $dwDrawStage == 1 )
{
$object -> Result ( 32 );
}
elsif ( $dwDrawStage == 65537 )
{
$lb -> Add ( ref ( $object ) . '  ' . $dc . '  ' .
 Win32::GUI::DC::GetTextFace ( $dc )
   );
$lb -> FirstVisibleItem ( $lb -> Count () - 20 );

( $mw -> { '-handle' } == Win32::GUI::GetActiveWindow () )
?   ( Win32::GUI::DC::TextColor ( $dc, 0x ) )
:  ( Win32::GUI::DC::TextColor ( $dc, 0x00808080 ) );
}

return ( 0 );
}
__END__