[perl-win32-gui-users] Help with a couple of problems
Hi, Rob and I have been trying to track down a couple of issues, and we're not sure if they are OS or Perl related. We would be greatful if you could run the two scipts below and report back your findings. When you report back could you include your OS, Perl and Win32-GUI versions. Thanks, jez. - #This crashes on exit with XP (perl 5.6.1 & perl 5.8.7) but not 98 use strict; use warnings; use Win32::GUI; # Create the main window my $mainwindow = new Win32::GUI::Window( -name => "Window", -title => "Objects and Windows", -pos=> [100,100], -size => [400,400], ); #We now create several employee selector 'controls'. my $search1=EmployeeSelector->new($mainwindow,20,20); my $search2=EmployeeSelector->new($mainwindow,20,50); my $search3=EmployeeSelector->new($mainwindow,20,80); my $search4=EmployeeSelector->new($mainwindow,20,110); my $search5=EmployeeSelector->new($mainwindow,20,140); $mainwindow->Show(); #Enter the message processing loop Win32::GUI::Dialog(); exit(0); package EmployeeSelector; use strict; use warnings; use Win32::GUI; use base qw(Win32::GUI::Window); #The constructor sub new { my ($class, $parent, $xcor, $ycor)[EMAIL PROTECTED]; #Create window my $self = $class->SUPER::new( -parent=> $parent, -pos => [$xcor,$ycor], -size => [150, 24], -popstyle => WS_CAPTION | WS_SIZEBOX, -pushstyle => WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE, ); $self->AddButton ( -text => 'Search', -pos=> [60,2], -size => [60,20], -tip=> 'Search for a Employee ID', -onClick => sub{$self}, # closure ); return $self; } - #!perl -w #This Causes an error on termination on XP perl 5.6.1 but not on perl 5.8.7 use strict; use warnings; use Win32::GUI; sub I_IMAGENONE() {-2}; sub RDW_INVALIDATE() {1}; my $mw = Win32::GUI::Window->new( -name => 'MainWindow', -text => 'CustomDraw', -pos => [ 100, 100 ], -size => [ 300, 350 ], -onActivate => sub { $_[0]->Toolbar->Redraw(RDW_INVALIDATE); return 1; }, -onDeactivate => sub { $_[0]->Toolbar->Redraw(RDW_INVALIDATE); return 1; }, -onTerminate => sub { -1 }, ); my $tb = $mw -> AddToolbar( -name => 'Toolbar', -nodivider => 1, -flat => 1, -list => 1, ); for ( 0 .. 3 ) { $tb->AddString("Test $_"); $tb->AddButtons( 1, I_IMAGENONE, 1000 + $_, TBSTATE_ENABLED, TBSTYLE_AUTOSIZE|TBSTYLE_BUTTON|BTNS_SHOWTEXT, $_ ); } $mw->Show(); Win32::GUI::Dialog(); exit(0); -
RE: [perl-win32-gui-users] Help with a couple of problems
Windows XP Professional Service Pack 2 Win32::GUI version 1.02 perl, v5.8.4 built for MSWin32-x86-multi-thread The first script exited without any problems. The second script went into a loop printing the following on exit: Use of uninitialized value in substitution (s///) at C:/Perl/lib/AutoLoader.pm line 40. Use of uninitialized value in concatenation (.) or string at C:/Perl/lib/AutoLoader.pm line 41. Steve -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jeremy White Sent: Wednesday, August 10, 2005 2:17 AM To: perl-win32-gui-users@lists.sourceforge.net Cc: [EMAIL PROTECTED] Subject: [perl-win32-gui-users] Help with a couple of problems Hi, Rob and I have been trying to track down a couple of issues, and we're not sure if they are OS or Perl related. We would be greatful if you could run the two scipts below and report back your findings. When you report back could you include your OS, Perl and Win32-GUI versions. Thanks, jez. - #This crashes on exit with XP (perl 5.6.1 & perl 5.8.7) but not 98 use strict; use warnings; use Win32::GUI; # Create the main window my $mainwindow = new Win32::GUI::Window( -name => "Window", -title => "Objects and Windows", -pos=> [100,100], -size => [400,400], ); #We now create several employee selector 'controls'. my $search1=EmployeeSelector->new($mainwindow,20,20); my $search2=EmployeeSelector->new($mainwindow,20,50); my $search3=EmployeeSelector->new($mainwindow,20,80); my $search4=EmployeeSelector->new($mainwindow,20,110); my $search5=EmployeeSelector->new($mainwindow,20,140); $mainwindow->Show(); #Enter the message processing loop Win32::GUI::Dialog(); exit(0); package EmployeeSelector; use strict; use warnings; use Win32::GUI; use base qw(Win32::GUI::Window); #The constructor sub new { my ($class, $parent, $xcor, $ycor)[EMAIL PROTECTED]; #Create window my $self = $class->SUPER::new( -parent=> $parent, -pos => [$xcor,$ycor], -size => [150, 24], -popstyle => WS_CAPTION | WS_SIZEBOX, -pushstyle => WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE, ); $self->AddButton ( -text => 'Search', -pos=> [60,2], -size => [60,20], -tip=> 'Search for a Employee ID', -onClick => sub{$self}, # closure ); return $self; } - #!perl -w #This Causes an error on termination on XP perl 5.6.1 but not on perl 5.8.7 use strict; use warnings; use Win32::GUI; sub I_IMAGENONE() {-2}; sub RDW_INVALIDATE() {1}; my $mw = Win32::GUI::Window->new( -name => 'MainWindow', -text => 'CustomDraw', -pos => [ 100, 100 ], -size => [ 300, 350 ], -onActivate => sub { $_[0]->Toolbar->Redraw(RDW_INVALIDATE); return 1; }, -onDeactivate => sub { $_[0]->Toolbar->Redraw(RDW_INVALIDATE); return 1; }, -onTerminate => sub { -1 }, ); my $tb = $mw -> AddToolbar( -name => 'Toolbar', -nodivider => 1, -flat => 1, -list => 1, ); for ( 0 .. 3 ) { $tb->AddString("Test $_"); $tb->AddButtons( 1, I_IMAGENONE, 1000 + $_, TBSTATE_ENABLED, TBSTYLE_AUTOSIZE|TBSTYLE_BUTTON|BTNS_SHOWTEXT, $_ ); } $mw->Show(); Win32::GUI::Dialog(); exit(0); - --- SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf ___ Perl-Win32-GUI-Users mailing list Perl-Win32-GUI-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users This email, and any files previous email messages included with it, may contain confidential and/or privileged material. If you are not the intended recipient please contact the sender and delete all copies.
[perl-win32-gui-users] {Spam?} Re: MDIFrame and background Image
Hi, Sorry by my last mail. I sent you a wrong script. This it's my modified MDI script with your code. The problem is that the new child window is not visualized but the activate/deactivate events works when the window is created. Is there are any wrong in my code? I'll appreciate your comments about this. Best regards. #! perl # # MDI sample # use Win32::GUI; use Win32::GUI::BitmapInline(); use strict; # My child counter for unique name. my $ChildCount = 0; my $Window; # 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 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, -class => $class, -addstyle => WS_CLIPCHILDREN, -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"; # 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 = $Window->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 main window and go to event loop $Window->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; } # 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"; }, -
[perl-win32-gui-users] Draggable 'window' [Was: MDIFrame and background Image]
Lloyd, Steve wrote: 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 Are you referring to the 'Find' window from Windows Spy++? If so, then that's not a draggable window at all: the application changes the cursor, and captures the mouse (see SetCapture()) so that it gets mouse move events for the mouse outside it's window borders. It then hit-tests on each mouse move to find the handle to any window under the mouse, gets the window co-ordinates (GetWindowRect() on the handle found), and then draws the rectangle around the window by drawing into the 'DISPLAY' DC (See CreateDC). Of course, it may do it entirely differently, but that's how I would do it. Regards, Rob.
[perl-win32-gui-users] RE: Draggable 'window' [Was: MDIFrame and background Image]
Thanks Rob, I will give it a try in Perl and Win32::GUI. Steve -Original Message- From: Robert May [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 10, 2005 4:34 PM To: Lloyd, Steve Cc: perl-win32-gui-users@lists.sourceforge.net Subject: Draggable 'window' [Was: MDIFrame and background Image] Lloyd, Steve wrote: > 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 Are you referring to the 'Find' window from Windows Spy++? If so, then that's not a draggable window at all: the application changes the cursor, and captures the mouse (see SetCapture()) so that it gets mouse move events for the mouse outside it's window borders. It then hit-tests on each mouse move to find the handle to any window under the mouse, gets the window co-ordinates (GetWindowRect() on the handle found), and then draws the rectangle around the window by drawing into the 'DISPLAY' DC (See CreateDC). Of course, it may do it entirely differently, but that's how I would do it. Regards, Rob. This email, and any files previous email messages included with it, may contain confidential and/or privileged material. If you are not the intended recipient please contact the sender and delete all copies.
[perl-win32-gui-users] Re: [win32gui] {Spam?} Re: MDIFrame and background Image
Daniel Fernandez wrote: Hi, Sorry by my last mail. I sent you a wrong script. This it's my modified MDI script with your code. The problem is that the new child window is not visualized but the activate/deactivate events works when the window is created. Is there are any wrong in my code? I'll appreciate your comments about this. Best regards. I think this is close to what you want (this is the first time I've played with the MDI classes, so there may be better ways). The tricks I used were: (1) The class needs to use the MDIFrame message loop, so I added -widget => "MDIFrame" to the class definition. (2) MDIFrame sets WM_CLIPCHILDREN by default, but as the MDIClient window fill the MDIFrame window, nothing is ever drawn; so I removed the WM_CLIPCHILDREN from the MDIFrame with -popsyle => WM_CLIPCHILDREN (3) Now that we've removed the WM_CLIPCHILDREN from the MDIFrame, when we draw on the whole of the MDIFrame's client area, we overwrite the MDIChild windows, causing very nasty flickering, so I extended the paint() function to clip the MDIChild windows from the MDIFrame's DC that we are drawing into. (4) Finally the MDIClient does not invalidate the regions exposed by an MDIChild when it moves or is terminated, as it assumes that we want it to paint the background, so I invalidate the regions in explicit handlers for termination and moving (See NewChild(), -onTerminate handler for the window and Hook(WM_MOVE ... ). Really we want to do exactly what I did with a single window in the MDIClient's WM_PAINT handler. But I can't see any way to get at that with the current Win32::GUI codebase. Regards, Rob. #!perl -w # # MDI sample # use strict; use warnings; use Win32::GUI; use Win32::GUI::BitmapInline(); # My child counter for unique name. my $ChildCount = 0; my $Window; # 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 # 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 => 100, -top=> 100, -width => 280, -height => 280, -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"; # 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 = $Window->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 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 an
[perl-win32-gui-users] Re: [win32gui] RE: Draggable 'window' [Was: MDIFrame and background Image]
Lloyd, Steve wrote: From: Robert May [mailto:[EMAIL PROTECTED] Lloyd, Steve wrote: 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 Are you referring to the 'Find' window from Windows Spy++? If so, then that's not a draggable window at all: the application changes the cursor, and captures the mouse (see SetCapture()) so that it gets mouse move events for the mouse outside it's window borders. It then hit-tests on each mouse move to find the handle to any window under the mouse, gets the window co-ordinates (GetWindowRect() on the handle found), and then draws the rectangle around the window by drawing into the 'DISPLAY' DC (See CreateDC). Of course, it may do it entirely differently, but that's how I would do it. > Thanks Rob, > I will give it a try in Perl and Win32::GUI. > > Steve That would be interesting code to share if you get it working :-) Rob.
RE: [perl-win32-gui-users] Help with a couple of problems
Hi all, My setup: Windows 2000 SP4, perl 5.8.4 build 810, Win32::GUI 1.0 The results: First script: No problem on exit Second script: Looping error message - Use of uninitialized value in substitution (s///) at c:/Perl/lib/AutoLoader.pm line 40. Use of uninitialized value in concatenation (.) or string at C:/Perl/lib/AutoLoader.pm line 41. I hope this helps! Brian Millham This message traveled at least 44,000 miles to reach you! Creator of the DW6000 Monitor http://www.millham.net/dw6000 [EMAIL PROTECTED] -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jeremy White Sent: Wednesday, August 10, 2005 4:17 AM To: perl-win32-gui-users@lists.sourceforge.net Cc: [EMAIL PROTECTED] Subject: [perl-win32-gui-users] Help with a couple of problems Hi, Rob and I have been trying to track down a couple of issues, and we're not sure if they are OS or Perl related. We would be greatful if you could run the two scipts below and report back your findings. When you report back could you include your OS, Perl and Win32-GUI versions. Thanks, jez. - #This crashes on exit with XP (perl 5.6.1 & perl 5.8.7) but not 98 use strict; use warnings; use Win32::GUI; # Create the main window my $mainwindow = new Win32::GUI::Window( -name => "Window", -title => "Objects and Windows", -pos=> [100,100], -size => [400,400], ); #We now create several employee selector 'controls'. my $search1=EmployeeSelector->new($mainwindow,20,20); my $search2=EmployeeSelector->new($mainwindow,20,50); my $search3=EmployeeSelector->new($mainwindow,20,80); my $search4=EmployeeSelector->new($mainwindow,20,110); my $search5=EmployeeSelector->new($mainwindow,20,140); $mainwindow->Show(); #Enter the message processing loop Win32::GUI::Dialog(); exit(0); package EmployeeSelector; use strict; use warnings; use Win32::GUI; use base qw(Win32::GUI::Window); #The constructor sub new { my ($class, $parent, $xcor, $ycor)[EMAIL PROTECTED]; #Create window my $self = $class->SUPER::new( -parent=> $parent, -pos => [$xcor,$ycor], -size => [150, 24], -popstyle => WS_CAPTION | WS_SIZEBOX, -pushstyle => WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE, ); $self->AddButton ( -text => 'Search', -pos=> [60,2], -size => [60,20], -tip=> 'Search for a Employee ID', -onClick => sub{$self}, # closure ); return $self; } - #!perl -w #This Causes an error on termination on XP perl 5.6.1 but not on perl 5.8.7 use strict; use warnings; use Win32::GUI; sub I_IMAGENONE() {-2}; sub RDW_INVALIDATE() {1}; my $mw = Win32::GUI::Window->new( -name => 'MainWindow', -text => 'CustomDraw', -pos => [ 100, 100 ], -size => [ 300, 350 ], -onActivate => sub { $_[0]->Toolbar->Redraw(RDW_INVALIDATE); return 1; }, -onDeactivate => sub { $_[0]->Toolbar->Redraw(RDW_INVALIDATE); return 1; }, -onTerminate => sub { -1 }, ); my $tb = $mw -> AddToolbar( -name => 'Toolbar', -nodivider => 1, -flat => 1, -list => 1, ); for ( 0 .. 3 ) { $tb->AddString("Test $_"); $tb->AddButtons( 1, I_IMAGENONE, 1000 + $_, TBSTATE_ENABLED, TBSTYLE_AUTOSIZE|TBSTYLE_BUTTON|BTNS_SHOWTEXT, $_ ); } $mw->Show(); Win32::GUI::Dialog(); exit(0); - --- SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf ___ Perl-Win32-GUI-Users mailing list Perl-Win32-GUI-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users --- avast! Antivirus: Inbound message clean. Virus Database (VPS): 0532-1, 08/09/2005 Tested on: 8/10/2005 4:30:24 AM avast! is copyright (c) 2000-2003 ALWIL Software. http://www.avast.com --- avast! Antivirus: Outbound message clean. Virus Database (VPS): 0532-2, 08/10/2005 Tested on: 8/10/2005 7:14:52 PM avast! is copyright (c) 2000-2003 ALWIL Software. http://www.avast.com