RE: [perl-win32-gui-users] GUI_Constants / GUI.pm error

2005-08-15 Thread Jeremy White
In particular, there are 366 entries in the search space. A binary search 
requires (at most) 9 probes for success and 10 probes for failure. This 
seems better than the existing algorithm. What do you think?




I like the idea - in practise does this mean that win32-gui is noticeably 
faster?


The only thing that could be faster is a hash table. If you think it 
worthwhile I'll try to generate one.




I guess it would depend on the reward "V" effort?


I'm trying to find:
  "-addstyle", and
  "-onTerminate".

As a general answer, where should I look to find what these are?


For -addstyle have a look in GUI_Options.cpp, in the function 
ParseWindowOptions.


For -onTerminate have a look in Window.cpp, in the function Window_onEvent.

Cheers,

jez.





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

2005-08-15 Thread Jeremy White
I'm trying to implement the StretchBlt function using  a call to gdi32.dll 
in order to fill the window with the image.


I've just added a feature request for this function to be supported natively 
within Win32-GUI.


As a side note, many functions are straightforward to add (including this 
one), so if you find a function missing, create a tracker for it:)


Cheers,

jez.





[perl-win32-gui-users] (no subject)

2005-08-15 Thread Sergey Cherniyenko
Hello, perl-win32-gui-users,

  How can I turn on debugging in Win32::GUI to get some descriptive
  output to console. In modules I've seen that can be done. How?
  

-- 
Best regards,
 Sergey  mailto:[EMAIL PROTECTED]





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

2005-08-15 Thread Daniel Fernandez
Thanks to all for your help. 
During this weekend I made several tests, investigate a little and 
finally I be able to expand the image inside a MDI Frame without using 
calls to the APIS (gdi32.dll). 
I use the functions 


# Load our bitmap
my $bm = newFromFile Win32::GUI::DIBitmap ('backgound.bmp') or die 
"newFromFile";
... 

#Store the width and height, ace we'll uses them to lot 
my($bmw, $bmh) = ($bm->GetWidth (), $bm->GetHeight ()); 


 ...

   #stretch the image to fit the window 
   $bm->StretchToDC ($dc, 0, 0, $ww, $wh, 0, 0, $bmw, $bmh, 13369376); 

If somebody are interested one, here I send them the code that I uses in 
my tests.


Best Regards



#!perl -w
#
#  MDI sample
#

use strict;
use warnings;




use Win32::GUI;
use Win32::GUI::DIBitmap;



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



# Obtine las dimensiones fisicas de la pantalla
my ($dw, $dh) = GetDW();

# Load our bitmap
my $bm = newFromFile Win32::GUI::DIBitmap ('backgound.bmp') or die 
"newFromFile";





# Store the width and height, as we'll use them a lot
my($bmw, $bmh) = ($bm->GetWidth(), $bm->GetHeight());



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


# 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   => 0,
   -top=> 0,
   -width  => $dw,
   -height => $dh,
   -minsize => [600,450],
  -name   => "Window",
  -menu   => $Menu,
  -class => $class,
  -popstyle => WS_CLIPCHILDREN,   # So that the MDIClient's window is 
not clipped

  -onPaint => \&paint,
  -onTerminate => sub {print "Terminate\n"; -1},   ) 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";




# do some other stuff
sleep(1);

# show the main window and enter the dialog phase
# splash screen taken down after (default) 3 seconds
$Window->Center();




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

# We've got some closures on $Window in the
# functions below, which appear to be the cause of
# a 'Can't call Delete .. in global clean up' warning,
# udefining $Window here stops that.
undef $Window;
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
{
  print "Painting...\n";
  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);


  # clip each of the MDIChild windows, to avoid us drawing over them
  # and so removing flicker
  # $clip_rgn is the rgion into which we can draw, initialise
  # it to the client window
  my $clip_rgn = 
Win32::GUI::Region->CreateRectRgn($window->GetClientRect());

  while (my ($name, $value) = each %{$window->{Client}}) {
   next unless $name =~ /^Child\d+/;
   my($l, $t, $r, $b) = $value->GetWindowRect();
   # $child_rgn is the MDI child's region in our window's client
   # co-ordinates
   my $child_rgn = Win32::GUI::Region->CreateRectRgn(
   $Window->ScreenToClient($l, $t), $Window->ScreenToClient($r, $b));
   # remove $child_rgn from the area we can draw
   $clip_rgn->CombineRgn($clip_rgn, $child_rgn, 4);
  }
  # selct the clip region into our DC.
  $dc->SelectClipRgn($clip_rgn) if $clip_rgn;

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

   # stretch the image to fit the window
   $bm->StretchToDC ($dc, 0, 0, $ww, $wh, 0, 0, $

RE: [perl-win32-gui-users] GUI_Constants / GUI.pm error

2005-08-15 Thread aschwarz1309
 -- Original message --
From: "Jeremy White" <[EMAIL PROTECTED]>
> 
> >In particular, there are 366 entries in the search space. A binary search 
> >requires (at most) 9 probes for success and 10 probes for failure. This 
> >seems better than the existing algorithm. What do you think?
> >
> 
> I like the idea - in practise does this mean that win32-gui is noticeably 
> faster?
> 

I doubt that there would be any appreciable speedup since GUI_Constants is only 
called occassionally when GUI objects are created. However, my own personal 
feeling is that it is always a good idea to use the best code possible giving 
the best performance possible. The reason is that the converse leads to the 
development of many instances of poorly performing code. Although not one of 
them might be seen as causing a system performance issue, collectively  they 
might have a different profile. So I dogmatically insist that nothing is too 
good for my friends. (Sorry for the digression. It's a sticky point with me.)

Bye the bye, The algorithm was copied from Niklaus Wirth's book, Algorithms + 
Data Structures = Programs. I seem to recall that it might not work correctly 
and that at some poipnt I fixed it. I had trouble compiling in VC++ yesterday 
and (so) did not validate the code by calling it with each of the 366 entries. 
I'll try to do that this week.

art



[perl-win32-gui-users] Re: Draggable 'window' [Was: MDIFrame and background Image]

2005-08-15 Thread Steven Lloyd
Well, I have got close but I am not sure how to make the Drawn rectangle 
transparent or how to dispose of the DC after I am through..  Any help would 
be greatly appreciated.



#!perl -w
# Left-Click on the target image, and drag
use warnings;
use strict;

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

my $mw = Win32::GUI::Window->new(
 -name => "MainWindow",
 -title => "Win32::GUI Spy++",
 -pos => [100,100],
 -size => [100,100],
 );

my $cursor = get_cursor();
$mw->AddLabel(
 -name => "Target",
 -icon => $cursor,
 -notify => 1,
 -onMouseDown => \&mouseDown,
 -onMouseUp => \&mouseUp,
 -onMouseMove => \&mouseMove,
 );

$mw->Show();
Win32::GUI::Dialog();
exit(0);
###
###
sub mouseDown{
 my $label = shift;
 Win32::GUI::SetCursor($cursor);
 $label->SetCapture();
 return;
 }

sub mouseUp{
 my $label = shift;
 $label->ReleaseCapture();
 return;
 }
#
sub mouseMove{
 my ($label, $x, $y) = @_; # x,y in client co-ordinates
 return unless Win32::GUI::GetCapture();
 Win32::GUI::SetCursor($cursor);
 my $hwnd=getWindowXY($x,$y);
 my $class=getWindowClass($hwnd) || '';
 my $text=getWindowText($hwnd) || '';
 $text=substr($text,0,30) if length($text) > 30;
 my $exe=getWindowExe($hwnd) || '';
 my ($left,$top,$right,$bottom)=getWindowRect($hwnd);
 my $hdc=getWindowDC(getDesktopWindow());
 my $ok=drawRectangle($hdc,$left,$top,$right,$bottom);
 #print qq|$hwnd\ ($x,$y) [$exe] {$class} "$text"\n|;
 return;
 }
###
sub getWindowDC{
 #usage: my $hwnd=getWindowDC($hwnd);
 #info: returns the handle of a device context for the specified window.
 my $hwnd=shift || return;
 my $GetWindowDC = new Win32::API("user32", "GetWindowDC", ['N'], 'N') || 
return $^E;

 my $hdc=$GetWindowDC->Call($hwnd);
 return $hdc;
 }
###
sub getDesktopWindow{
 #usage: my $hwnd=getWindowDC($hwnd);
 #info: returns the handle of a device context for the specified window.
 my $GetDesktopWindow = new Win32::API("user32", "GetDesktopWindow", [], 
'N') || return $^E;

 my $hwnd=$GetDesktopWindow->Call();
 return $hwnd;
 }
###
sub drawRectangle{
 #usage: my $ok=drawRectangle($hdc,$left,$top,$right,$bottom);
 #info: returns the handle of a device context for the specified window.
 my $hdc=shift || return;
 my $left=shift || 0;
 my $top=shift || 0;
 my $right=shift || 0;
 my $bottom=shift || 0;
 my $Rectangle = new Win32::API("gdi32", "Rectangle", 
['N','I','I','I','I'], 'N') || return $^E;

 my $ok=$Rectangle->Call($hdc,$left,$top,$right,$bottom);
 return $hdc;
 }
###
sub getWindowXY{
 #usage: my $hwnd=getWindowXY($x,$y);
 #info: returns the window handle of window at x,y
 my $x=shift || return;
 my $y=shift || return;
 my $WindowFromPoint = new Win32::API("user32", "WindowFromPoint", 
['N','N'], 'N') || return $^E;

 my $POINT = pack("LL", $x, $y);
 return $WindowFromPoint->Call($x,$y);
 }
###
sub getWindowClass{
 my $hwnd = shift || return;
 my $GetClassName = new Win32::API("user32", "GetClassName", ['N', 'P', 
'N'], 'N') || return $^E;

 my $name = " " x 1024;
 my $nameLen = 1024;
 my $result = $GetClassName->Call($hwnd, $name, $nameLen);
 if($result){return substr($name, 0, $result);}
 }
###
sub getWindowExe {
 #GetModuleFileName
 my $hwnd = shift || return;
 my $GetModuleFileName = new Win32::API("kernel32", "GetModuleFileName", 
['N', 'P', 'N'], 'N') || return "unable to create new API";

 my $name = " " x 1024;
 my $Len = 1024;
 my $result = $GetModuleFileName->Call($hwnd, $name, $Len);
 if($result) {return substr($name, 0, $result);}
 return "unknown";
 }
###
sub getWindowRect {
 my $hwnd = shift || return;
 my $GetWindowRect = new Win32::API("user32", "GetWindowRect", ['N', 'P'], 
'N') || return $^E;

 my $RECT = pack("", 0, 0);
 $GetWindowRect->Call($hwnd, $RECT);
 return wantarray ? unpack("", $RECT) : $RECT;
 }
###
sub getWindowText{
 my $hwnd = shift || return;
 my $GetWindowText = new Win32::API("user32", "GetWindowText", ['N', 'P', 
'N'], 'N') || return $^E;

 my $title = " " x 1024;
 my $titleLen = 1024;
 my $result = $GetWindowText->Call($hwnd, $title, $titleLen);
 my $text=substr($title, 0, $result);
 if($text){return $text;}
 #if no result send a WM_GetText message to the window
 my $WmSendMessage = new Win32::API("user32", "SendMessageA", 
['N','N','N','P'],'N') || return $^E;

 my $WM_GETTEXT=13;
 my $txt = " " x 2048;
 my $textLen = 2048;
 $result = $WmSendMessage->Call($hwnd,$WM_GETTEXT, $textLen, $txt);
 $text= substr($txt, 0, $result);
 return $text;
 }
#
sub get_cursor{
return Win32::GUI::BitmapInline->newCursor( q(
AAACAAEAIC8AEAAwAQAAFgAAACggQAEAAQEA
AAAHwAAAGDAAACbIAABQFAAApsoA
AUAFAAECgQACoAqAAqgqgAIBAIACqCqAAqAKgAECgQABQAUAAKbKAABQFAAAJsgAABgwAAAHwAAA
AAA

[perl-win32-gui-users] Re: MDIFrame and background Image

2005-08-15 Thread May, Robert
Jez,

Before anyone runs off and implements this (stretchBlt), I already did it (last 
week) - it's just not checked in yet, and won't be until I'm back in the UK 
next week.

Regards,
Rob.

-Original Message-
From: Jeremy White [mailto:[EMAIL PROTECTED]
Sent: 15 August 2005 09:15
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Cc: perl-win32-gui-users@lists.sourceforge.net
Subject: [Popes Lane] RE: [perl-win32-gui-users] Re: [win32gui] {Spam?}
Re: MDIFrame and background Image



>>I'm trying to implement the StretchBlt function using  a call to gdi32.dll
>>in order to fill the window with the image.

I've just added a feature request for this function to be supported natively
within Win32-GUI.

As a side note, many functions are straightforward to add (including this
one), so if you find a function missing, create a tracker for it:)

Cheers,

jez.



===
 Information contained in this email message is intended only for use of the 
individual or entity named above. If the reader of this message is not the 
intended recipient, or the employee or agent responsible to deliver it to the 
intended recipient, you are hereby notified that any dissemination, 
distribution or copying of this communication is strictly prohibited. If you 
have received this communication in error, please immediately notify us by 
email to [EMAIL PROTECTED] and destroy the original message.