[perl-win32-gui-users] Trapping ctl-<> and function keys and invalidating windows

2005-08-09 Thread aschwarz1309
Any way to trap control key and function key entries without a dialog window? 
I'd like to be able to associate functions to keys so that someone can invoke a 
function by pressing a key, primariliy for debugging. I don't want a submenu.

Any way of detecting when a window needs to be invalidated? 

art



Re: [perl-win32-gui-users] Trapping ctl-<> and function keys and invalidating windows

2005-08-09 Thread Robert May

[EMAIL PROTECTED] wrote:

Any way to trap control key and function key entries without a dialog window? 
I'd like to be able to associate functions to keys so that someone can invoke a 
function by pressing a key, primariliy for debugging. I don't want a submenu.


You should investigate Win32::GUI::AcceleratorTable class or look at 
using the Win32::GUI::Hook() function to catch WM_KEYDOWN


Any way of detecting when a window needs to be invalidated? 


Not sure I understand you.  The system automatically invalidates parts 
of the client window that need redrawing, or your program can invalidate 
parts that it knows need redrawing.  Invalidated regions are re-drawn 
the next time the window processes a WM_PAINT message - but all this 
happens in the background.  If you can provide a better idea of what you 
are trying to do (and what doesn't work for you) then we may be able to 
point you in the right direction.


Regards,
Rob.



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

2005-08-09 Thread Robert May
Apologies if this is a repeat post, but I did not see the first one come 
back from the reflector.  I've made the included image a whole lot 
smaller in case that was the problem.


Rob.

Robert May wrote:

Daniel Fernandez wrote:


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 .



Here's one way of doing it with a regular window.  You should be able to 
adjust this to work with an MDI frame. (Sorry about the big image)


Regards,
Rob.


#!perl -w
use strict;
use warnings;

use Win32::GUI;
use Win32::GUI::BitmapInline();

# Load our bitmap
#my $bm = Win32::GUI::Bitmap->new("sail.bmp") or die "Creating Bitmap";
my $bm = get_bitmap();
# Store the width and height, as we'll use them a lot
my($bmw, $bmh) = ($bm->Info())[0..1];

# create a class without a background brush: this prevents
# defWindowProc erasing the window background, as we want to
# paint it ourselves to avoid flicker
my $class = Win32::GUI::Class->new(
-name => 'noflicker',
-brush => 0,
);

# create a window, using our class. Add style WS_CLIPCHILDEN
# so that any child windows are automatically masked out of
# our window's DC, and then we don't need to worry about drawing
# over them
my $mw = Win32::GUI::Window->new(
-name => "ImgWindow",
-title => "Background Image",
-pos => [100,100],
-size => [300,200],
-class => $class,
-addstyle => WS_CLIPCHILDREN,
-onPaint => \&paint,
-onTerminate => sub {-1},
);

$mw->AddButton(
-name => "Button",
-pos => [20,20],
-text => "Example Child Window",
);

# Create a memory DC, compatible with our window's
# DC, containing our bitmap.  Do this once, here, to speed
# up the painting routine.  Use a local block, so that $dc
# goes out of scope, and $dc gets released (could call
# $dc->ReleaseDC() instead).
my $memDC;
{
my $dc = $mw->GetDC();
$memDC = $dc->CreateCompatibleDC();
$memDC->SelectObject($bm);
}

# We need a brush to paint the window background
# with, select a grey one.  We don't need to worry
# about freeing stock objects when we're done with them
my $bkBrush = Win32::GUI::GetStockObject(1);

# Show the window and enter the dialog phase.
$mw->Show();
Win32::GUI::Dialog();
exit(0);

# Our window painting routine.  To avoid flicker we will
# paint the whole of the window, taking care not to draw any
# pixel more than once.
sub paint
{
my($window, $dc) = @_;

# I will add StretchBlt to the next release so that we can stretch the
# image to fit the window, but it's not there right now.
	#$dc->StretchBlt(0, 0, ($window->GetClientRect())[2..3], $memDC, 0, 0, 
$bmw, $bmh);

#calculate the image position to center it in the window
my ($ww, $wh) = ($window->GetClientRect())[2..3];

my $l = ($ww - $bmw)/2;
my $t = ($wh - $bmh)/2;
my $r = $l + $bmw;
my $b = $t + $bmh;

# copy the image from the memory DC to the window's DC
$dc->BitBlt($l, $t, $bmw, $bmh, $memDC, 0, 0);

# fill the spaces around the image with our background brush.
# We should probably not draw when it is not necessary (i.e. when
# the image meets the side(s), but we can get away with not checking,
# as the DC is always clipped to the window's client rect.
$dc->FillRect(0,  0,  $ww, $t,  $bkBrush);
$dc->FillRect(0,  $b, $ww, $wh, $bkBrush);
$dc->FillRect(0,  $t, $l,  $b,  $bkBrush);
$dc->FillRect($r, $t, $ww, $b,  $bkBrush);

# We've drawn the background, so inform windows that there is nothing 
left
# to draw.
$dc->Validate();

# we've processed the message, so return 0.
return 0;
}


sub get_bitmap
{
return Win32::GUI::BitmapInline->new( q(
Qk1gMQAAADYEAAAooG4BAAgAAQAAACotAAATCwAAEwsBAQAAADEx
AAA5OQAhOTkAKTk5ADk5OQAAQkIAGEJCACFCQgApQkIAMUJCADlCQgBCQkIAAEpKAAhKSgAQSkoA
GEpKACFKSgApSkoAMUpKADlKSgBCSkoAAFJSAAhSUgAQUlIAGFJSACFSUgApUlIAMVJSADlSUgBC
UlIASlJSAABaWgAIWloAEFpaABhaWgAhWloAKVpaADFaWgA5WloAQlpaAEpaWgBSWloAAGNjAAhj
YwAQY2MAGGNjACFjYwApY2MAMWNjADljYwBCY2MASmNjAFJjYwBaY2MAAGtrAAhrawAQa2sAGGtr
ACFrawApa2sAMWtrADlrawBCa2sASmtrAFJrawBaa2sAY2trAABzcwAIc3MAEHNzABhzcwAxc3MA
OXNzAEJzcwBKc3MAUnNzAFpzcwBjc3MAa3NzAAB7ewAIe3sAEHt7ADl7ewBCe3sASnt7AFJ7ewBa
e3sAY3t7AGt7ewBze3sAe3t7AACEhAAIhIQASoSEAFKEhABahIQAY4SEAGuEhABzhIQAe4SEAISE
hAAAjIwAY4yMAGuMjABzjIwAe4yMAISMjACMjIwAe5SUAISUlACMlJQAlJSUAHucnACEnJwAjJyc
AJScnACcnJwAjKWlAJSlpQCcpaUApaWlAJytrQClra0Ara2tAKW1tQCttbUAtbW1AK29vQC1vb0A
vb29ALXGxgC9xsYAxs7OAMbW1gDO1tYAc97eAHve3gCE3t4Azt7eAHPn5wB75+cAhOfnAIzn5wCU
5+cAnOfnAKXn5wBK7+8AUu/vAFrv7wBj7+8Aa+/vAHPv7wB77+8AhO/vAIzv7wCU7+8AnO/vAKXv
7wCt7+8AY/f3AGv39wBz9/cAe/f3AIT39wCM9/cAlPf3AJz39wCl9/cArff3ALX39wC99/cAY///
AGv//wBz//8Ae///AIT//wCM//8AlP//AJz//wCl//8Arf//ALX//wC9//8Axv//AM7//wDW//8A
3v//AOf//wD

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

2005-08-09 Thread Lloyd, Steve
Is there a way using Win32::GUI to create a dragable child window that
can be dragged and dropped onto another window like winspy does?

Steve

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Robert May
Sent: Tuesday, August 09, 2005 1:08 PM
To: Daniel Fernandez
Cc: perl-win32-gui-users@lists.sourceforge.net
Subject: Re: [win32gui] [perl-win32-gui-users] {Spam?} MDIFrame and
background Image


Apologies if this is a repeat post, but I did not see the first one come

back from the reflector.  I've made the included image a whole lot 
smaller in case that was the problem.

Rob.

Robert May wrote:
> Daniel Fernandez wrote:
> 
>> 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 .
> 
> 
> Here's one way of doing it with a regular window.  You should be able 
> to
> adjust this to work with an MDI frame. (Sorry about the big image)
> 
> Regards,
> Rob.

#!perl -w
use strict;
use warnings;

use Win32::GUI;
use Win32::GUI::BitmapInline();

# Load our bitmap
#my $bm = Win32::GUI::Bitmap->new("sail.bmp") or die "Creating Bitmap";
my $bm = get_bitmap(); # Store the width and height, as we'll use them a
lot my($bmw, $bmh) = ($bm->Info())[0..1];

# create a class without a background brush: this prevents
# defWindowProc erasing the window background, as we want to
# paint it ourselves to avoid flicker
my $class = Win32::GUI::Class->new(
-name => 'noflicker',
-brush => 0,
);

# create a window, using our class. Add style WS_CLIPCHILDEN
# so that any child windows are automatically masked out of
# our window's DC, and then we don't need to worry about drawing # over
them my $mw = Win32::GUI::Window->new(
-name => "ImgWindow",
-title => "Background Image",
-pos => [100,100],
-size => [300,200],
-class => $class,
-addstyle => WS_CLIPCHILDREN,
-onPaint => \&paint,
-onTerminate => sub {-1},
);

$mw->AddButton(
-name => "Button",
-pos => [20,20],
-text => "Example Child Window",
);

# Create a memory DC, compatible with our window's
# DC, containing our bitmap.  Do this once, here, to speed
# up the painting routine.  Use a local block, so that $dc
# goes out of scope, and $dc gets released (could call
# $dc->ReleaseDC() instead).
my $memDC;
{
my $dc = $mw->GetDC();
$memDC = $dc->CreateCompatibleDC();
$memDC->SelectObject($bm);
}

# We need a brush to paint the window background
# with, select a grey one.  We don't need to worry
# about freeing stock objects when we're done with them
my $bkBrush = Win32::GUI::GetStockObject(1);

# Show the window and enter the dialog phase.
$mw->Show();
Win32::GUI::Dialog();
exit(0);

# Our window painting routine.  To avoid flicker we will
# paint the whole of the window, taking care not to draw any
# pixel more than once.
sub paint
{
my($window, $dc) = @_;

# I will add StretchBlt to the next release so that we can
stretch the
# image to fit the window, but it's not there right now.
#$dc->StretchBlt(0, 0, ($window->GetClientRect())[2..3], $memDC,
0, 0, 
$bmw, $bmh);
#calculate the image position to center it in the window
my ($ww, $wh) = ($window->GetClientRect())[2..3];

my $l = ($ww - $bmw)/2;
my $t = ($wh - $bmh)/2;
my $r = $l + $bmw;
my $b = $t + $bmh;

# copy the image from the memory DC to the window's DC
$dc->BitBlt($l, $t, $bmw, $bmh, $memDC, 0, 0);

# fill the spaces around the image with our background brush.
# We should probably not draw when it is not necessary (i.e.
when
# the image meets the side(s), but we can get away with not
checking,
# as the DC is always clipped to the window's client rect.
$dc->FillRect(0,  0,  $ww, $t,  $bkBrush);
$dc->FillRect(0,  $b, $ww, $wh, $bkBrush);
$dc->FillRect(0,  $t, $l,  $b,  $bkBrush);
$dc->FillRect($r, $t, $ww, $b,  $bkBrush);

# We've drawn the background, so inform windows that there is
nothing left
# to draw.
$dc->Validate();

# we've processed the message, so return 0.
return 0;
}


sub get_bitmap
{
return Win32::GUI::BitmapInline->new( q(
Qk1gMQAAADYEAAAooG4BAAgAAQAAACotAAATCwAAEwsBAQAA
ADEx
AAA5OQAhOTkAKTk5ADk5OQAAQkIAGEJCACFCQgApQkIAMUJCADlCQgBCQkIAAEpKAAhKSgAQ
SkoA
GEpKACFKSgApSkoAMUpKADlKSgBCSkoAAFJSAAhSUgAQUlIAGFJSACFSUgApUlIAMVJSADlS
UgBC
UlIASlJSAABaWgAIWloAEFpaABhaWgAhWloAKVpaADFaWgA5WloAQlpaAEpaWgBSWloAAGNj
AAhj
YwAQY2MAGGNjACFjYwApY2MAMWNjADljYwBCY2MASmNjAFJjYwBaY2MAAGtrAAhrawAQa2sA
GGtr
ACFrawApa2sAMWtrADlrawBCa2sASmtrAFJrawBaa2sAY2trAABzcwAIc3MAEHNzABhzcwAx
c3MA
OXNzAEJzcwBKc3MAUnNzAFpzcwBjc3MAa3NzAAB7ewAIe3sAEHt7ADl7ewBCe3sASnt7AFJ7
ewBa
e3sAY3t7AGt7ewBze3sAe3t7AACEhAAIhIQASoSEAFKEhABahIQAY4SEAGuEhABzhIQAe4SE
AISE

Re: [perl-win32-gui-users] Trapping ctl-<> and function keys and invalidating windows

2005-08-09 Thread aschwarz1309
Rob;

Accelerator works just fine. Can't find a description of Hook(). Hook() isn't 
needed and if  you're otherwise occupied, ignore the question. But I am curious.

art

 -- Original message --
From: Robert May <[EMAIL PROTECTED]>
> [EMAIL PROTECTED] wrote:
> > Any way to trap control key and function key entries without a dialog 
> > window? 
> I'd like to be able to associate functions to keys so that someone can invoke 
> a 
> function by pressing a key, primariliy for debugging. I don't want a submenu.
> 
> You should investigate Win32::GUI::AcceleratorTable class or look at 
> using the Win32::GUI::Hook() function to catch WM_KEYDOWN
> 
> > Any way of detecting when a window needs to be invalidated? 
> 
> Not sure I understand you.  The system automatically invalidates parts 
> of the client window that need redrawing, or your program can invalidate 
> parts that it knows need redrawing.  Invalidated regions are re-drawn 
> the next time the window processes a WM_PAINT message - but all this 
> happens in the background.  If you can provide a better idea of what you 
> are trying to do (and what doesn't work for you) then we may be able to 
> point you in the right direction.
> 
> Regards,
> Rob.





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

2005-08-09 Thread Jeremy White

I've tucked this code away to add to Coolbar.pm when I next get back to it.


For both of your examples I was getting an error on exit - invalid methods 
on global destruction. Both were failing in onDeactivate event - to get 
round it I had to add the following:


return unless $_[0];

to the first line of the event handler. I'm on 5.6.1, latest code line.

Cheers,

jez.





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

2005-08-09 Thread Robert May

Daniel Fernandez wrote:

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 .


Here's one way of doing it with a regular window.  You should be able to 
adjust this to work with an MDI frame. (Sorry about the big image)


Regards,
Rob.

#!perl -w
use strict;
use warnings;

use Win32::GUI;
use Win32::GUI::BitmapInline();

# Load our bitmap
#my $bm = Win32::GUI::Bitmap->new("sail.bmp") or die "Creating Bitmap";
my $bm = get_bitmap();
# Store the width and height, as we'll use them a lot
my($bmw, $bmh) = ($bm->Info())[0..1];

# create a class without a background brush: this prevents
# defWindowProc erasing the window background, as we want to
# paint it ourselves to avoid flicker
my $class = Win32::GUI::Class->new(
-name => 'noflicker',
-brush => 0,
);

# create a window, using our class. Add style WS_CLIPCHILDEN
# so that any child windows are automatically masked out of
# our window's DC, and then we don't need to worry about drawing
# over them
my $mw = Win32::GUI::Window->new(
-name => "ImgWindow",
-title => "Background Image",
-pos => [100,100],
-size => [550,450],
-class => $class,
-addstyle => WS_CLIPCHILDREN,
-onPaint => \&paint,
-onTerminate => sub {-1},
);

$mw->AddButton(
-name => "Button",
-pos => [100,100],
-text => "Example Child Window",
);

# Create a memory DC, compatible with our window's
# DC, containing our bitmap.  Do this once, here, to speed
# up the painting routine.  Use a local block, so that $dc
# goes out of scope, and $dc gets released (could call
# $dc->ReleaseDC() instead).
my $memDC;
{
my $dc = $mw->GetDC();
$memDC = $dc->CreateCompatibleDC();
$memDC->SelectObject($bm);
}

# We need a brush to paint the window background
# with, select a grey one.  We don't need to worry
# about freeing stock objects when we're done with them
my $bkBrush = Win32::GUI::GetStockObject(1);

# Show the window and enter the dialog phase.
$mw->Show();
Win32::GUI::Dialog();
exit(0);

# Our window painting routine.  To avoid flicker we will
# paint the whole of the window, taking care not to draw any
# pixel more than once.
sub paint
{
my($window, $dc) = @_;

# I will add StretchBlt to the next release so that we can stretch the
# image to fit the window, but it's not there right now.
	#$dc->StretchBlt(0, 0, ($window->GetClientRect())[2..3], $memDC, 0, 0, 
$bmw, $bmh);


#calculate the image position to center it in the window
my ($ww, $wh) = ($window->GetClientRect())[2..3];

my $l = ($ww - $bmw)/2;
my $t = ($wh - $bmh)/2;
my $r = $l + $bmw;
my $b = $t + $bmh;

# copy the image from the memory DC to the window's DC
$dc->BitBlt($l, $t, $bmw, $bmh, $memDC, 0, 0);

# fill the spaces around the image with our background brush.
# We should probably not draw when it is not necessary (i.e. when
# the image meets the side(s), but we can get away with not checking,
# as the DC is always clipped to the window's client rect.
$dc->FillRect(0,  0,  $ww, $t,  $bkBrush);
$dc->FillRect(0,  $b, $ww, $wh, $bkBrush);
$dc->FillRect(0,  $t, $l,  $b,  $bkBrush);
$dc->FillRect($r, $t, $ww, $b,  $bkBrush);

# We've drawn the background, so inform windows that there is nothing 
left
# to draw.
$dc->Validate();

# we've processed the message, so return 0.
return 0;
}


sub get_bitmap
{
return Win32::GUI::BitmapInline->new( q(
Qk1mpgIAADYEAAAo4AEAAJQBAAABAAgAAQAAADCiAgATCwAAEwsBAQAA
AAEBAQACAgIAAwMDAAQEBAAFBQUABgYGAAcHBwAICAgACQkJAAoKCgALCwsADAwMAA0NDQAODg4A
Dw8PABAQEAAREREAEhISABMTEwAUFBQAFRUVABYWFgAXFxcAGBgYABkZGQAaGhoAGxsbABwcHAAd
HR0AHh4eAB8fHwAgICAAISEhACIiIgAjIyMAJCQkACUlJQAmJiYAJycnACgoKAApKSkAKioqACsr
KwAsLCwALS0tAC4uLgAvLy8AMDAwADExMQAyMjIAMzMzADQ0NAA1NTUANjY2ADc3NwA4ODgAOTk5
ADo6OgA7OzsAPDw8AD09PQA+Pj4APz8/AEBAQABBQUEAQkJCAENDQwBEREQARUVFAEZGRgBHR0cA
SEhIAElJSQBKSkoAS0tLAExMTABNTU0ATk5OAE9PTwBQUFAAUVFRAFJSUgBTU1MAVFRUAFVVVQBW
VlYAV1dXAFhYWABZWVkAWlpaAFtbWwBcXFwAXV1dAF5eXgBfX18AYGBgAGFhYQBiYmIAY2NjAGRk
ZABlZWUAZmZmAGdnZwBoaGgAaWlpAGpqagBra2sAbGxsAG1tbQBubm4Ab29vAHBwcABxcXEAcnJy
AHNzcwB0dHQAdXV1AHZ2dgB3d3cAeHh4AHl5eQB6enoAe3t7AHx8fAB9fX0Afn5+AH9/fwCAgIAA
gYGBAIKCggCDg4MAhISEAIWFhQCGhoYAh4eHAIiIiACJiYkAioqKAIuLiwCMjIwAjY2NAI6OjgCP
j48AkJCQAJGRkQCSkpIAk5OTAJSUlACVlZUAlpaWAJeXlwCYmJgAmZmZAJqamgCbm5sAnJycAJ2d
nQCenp4An5+fAKCgoAChoaEAoqKiAKOjowCkpKQApaWlAKampgCnp6cAqKioAKmpqQCqqqoAq6ur
AKysrACtra0Arq6uAK+vrwCwsLAAsbGxALKysgCzs7MAtLS0ALW1tQC2trYAt7e3ALi4uAC5ubkA
urq6ALu7uwC8vLwAvb29AL6+vgC/v78AwMDAAMHBwQDCwsIAw8PDAMTExADFxcUAxsbGAMfHxwDI
yMgAycnJAMrKygDLy8sAzMzMAM3NzQDOzs4Az8/PANDQ0ADR0dEA0tLSANPT0wDU1NQA1dXVANbW
1gDX19cA2NjYANnZ2QDa2toA29vbANzc3ADd3d0A3t7eAN/f3wDg4OAA4eHhAOL

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

2005-08-09 Thread Daniel Fernandez

Hi,

Thank you very much for your answer. 
I have been studying your code and  I arrived to the conclusion that  
is  very difficult  to  track all the child windows.  Is easy with one  
object  like a button, but too difficult with many child windows (I'm 
not a windows expert), like in the following example.



Thanks and regards



#! perl
#
#  MDI sample
#
use Win32::GUI;
use strict;

# My child counter for unique name.
my $ChildCount = 0;

my $Window;

# Create Main menu.
my $Menu = Win32::GUI::MakeMenu(
   "&File"   => "File",
   "   > &New"   => { -name => "File_New",  -onClick => 
\&NewChild },

   "   > -"  => 0,
   "   > E&xit"  => { -name => "File_Exit", -onClick => 
sub { -1; } },

   "&Window" => "Window",
   "   > &Next"  => { -name => "Next",-onClick => 
sub { $Window->{Client}->Next; } },
   "   > &Previous"  => { -name => "Prev",-onClick => 
sub { $Window->{Client}->Previous; } },

   "   > -"  => 0,
   "   > &Cascade"   => { -name => "Cascade", -onClick => 
sub { $Window->{Client}->Cascade(); 0; } },
   "   > Tile &Horizontally" => { -name => "TileH",   -onClick => 
sub { $Window->{Client}->Tile(1);  } },
   "   > Tile &Vertically"   => { -name => "TileV",   -onClick => 
sub { $Window->{Client}->Tile(0);  } },

   "&Help"   => "Help",
   "   > &About "=> { -name => "About", -onClick => sub 
{ 1; } },

);

# First we create an MDIFrame window.
$Window = new Win32::GUI::MDIFrame (
   -title  => "Win32::GUI MDI Sample",
   -left   => 100,
   -top=> 100,
   -width  => 280,
   -height => 280,
   -name   => "Window",
   -menu   => $Menu,
) or die "Window";

# We add an MDIClient window, This window manage Child Window.
$Window->AddMDIClient(
 -name   => "Client",
 -firstchild => 100, # Define Child ID for 
menu item
 -windowmenu => $Menu->{Window}->{-handle},  # Define Menu Handle 
where Add Window Child name

 ) or die "Client";

# Show main window and go to event loop
$Window->Show;
Win32::GUI::Dialog();

# This function create a new child window.
sub NewChild {
  
   # Create a child window.

   my $Child = $Window->{Client}->AddMDIChild (
 -name => "Child".$ChildCount++,
 -onActivate   => sub { print "Activate\n"; },
 -onDeactivate => sub { print "Deactivate\n"; },
 -onTerminate  => sub { print "Terminate\n";},
 -onResize => \&ChildSize,
   ) or die "Child";

   # Add a text filed into child window.
   $Child->AddTextfield (
   -name => "Edit",
   -multiline => 1,
   -pos => [0,0],
   -size => [100,100], 
   );


   # Force a resize.
   ChildSize($Child);
}

# This function manage child window resize.
sub ChildSize {
my $self = shift;
my ($width, $height) = ($self->GetClientRect())[2..3];
# TextField take all client aera
$self->{Edit}->Resize($width, $height) if exists $self->{Edit};
}


Robert May escribió:


Daniel Fernandez wrote:


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 .



Here's one way of doing it with a regular window.  You should be able 
to adjust this to work with an MDI frame. (Sorry about the big image)


Regards,
Rob.

#!perl -w
use strict;
use warnings;

use Win32::GUI;
use Win32::GUI::BitmapInline();

# Load our bitmap
#my $bm = Win32::GUI::Bitmap->new("sail.bmp") or die "Creating Bitmap";
my $bm = get_bitmap();
# Store the width and height, as we'll use them a lot
my($bmw, $bmh) = ($bm->Info())[0..1];

# create a class without a background brush: this prevents
# defWindowProc erasing the window background, as we want to
# paint it ourselves to avoid flicker
my $class = Win32::GUI::Class->new(
-name => 'noflicker',
-brush => 0,
);

# create a window, using our class. Add style WS_CLIPCHILDEN
# so that any child windows are automatically masked out of
# our window's DC, and then we don't need to worry about drawing
# over them
my $mw = Win32::GUI::Window->new(
-name => "ImgWindow",
-title => "Background Image",
-pos => [100,100],
-size => [550,450],
-class => $class,
-addstyle => WS_CLIPCHILDREN,
-onPaint => \&paint,
-onTerminate => sub {-1},
);

$mw->AddButton(
-name => "Button",
-pos => [100,100],
-text => "Example Child Window",
);

# Create a memory DC, compatible with our window's
# DC, containing our bitmap.  Do this once, here, to speed
# up the painting routine.  Use a local block, so that $dc
# goes out of scope, and $dc gets released (could call
# $dc->ReleaseDC() instead).
my $memDC;
{
my $dc = $mw->GetDC();
$memDC = $dc->CreateCompatibleDC();
$memDC->SelectObject($bm);
}

# We need a brush to paint the window background
# with, select a grey one.  We don't need to