Rob,
 
Thanks for the quick answer.  I don't know how I missed the "SetIcon" method.  Thanks also for the info on subclassing. 
 
Chris
 
 

 
On 12/16/05, Robert May <[EMAIL PROTECTED]> wrote:
Chris Rogers wrote:
> I have been trying to set an icon for an MDIFrame.  I also need to set
> different icons for the Child windows.  I am using Win32::GUI 1.03 with
> Activestate 5.8.7 along with Komodo and Perlapp.  In the past, I could
> never get the "-icon=>$icon" to work

There is, as far as I can see from the documentation and the source code
no such '-icon' option for windows.

> so I had to use Win32::GUI::Class
> to set the window icon and that seemed to work just fine.

That's one way to do it.  $window->SetIcon($icon) is another (and in
this case probably simpler).

[snip]

>     *my $icon = new Win32::GUI::Icon("c:\\JS1G.ICO");
>     my $WC = new Win32::GUI::Class(-name => "mywindowclass", -icon =>
>     $icon,);*

You need to subclass the relevant widget class.  This would work:

my $WC = WIn32::GUI::Class->new(
  -name => "MyMDIFrameSubClass",
  -icon => $icon
  -widget => 'MDIFrame',
);

[ snip ]

> In short: How do I set one icon for an MDIFrame and different icons for
> MDIChild windows??

Here's the 2 ways to do it:

#!perl -w
use strict;
use warnings;

use Win32::GUI;

my $icon = new Win32::GUI::Icon("c:\\JS1G.ICO");

my $mw = Win32::GUI::MDIFrame->new(
       -text   => 'Main Window',
       -width  => 1024,
       -height => 768,
) or die "frame creation failed: [EMAIL PROTECTED]";
$mw->SetIcon($icon);

my $mc = $mw->AddMDIClient(
       -firstchild => 100,
) or die "client creation failed: [EMAIL PROTECTED]";

my $cw = $mc->AddMDIChild(
       -name => 'window1',
       -text => 'Window1',
       -pos  => [100, 100],
       -size => [810, 610],
) or die "child creation failed: [EMAIL PROTECTED]";
$cw->SetIcon($icon);

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

#!perl -w
use strict;
use warnings;

use Win32::GUI;

my $icon = new Win32::GUI::Icon("c:\\JS1G.ICO");
my $frame_class = new Win32::GUI::Class(
       -name   => "mywindowclass",
               -icon   => $icon,
       -widget => "MDIFrame",   # use the MDIFrame windowproc
);
my $child_class = new Win32::GUI::Class(
       -name   => "mychildwindowclass",
               -icon   => $icon,
       -widget => "MDIChild",   # use the MDIChild windowproc
);

my $mw = Win32::GUI::MDIFrame->new(
       -text  => 'Main Window',
       -size  => [1024,768],
       -class => $frame_class,
) or die "frame creation failed: [EMAIL PROTECTED]";

my $mc = $mw->AddMDIClient(
       -firstchild => 100,
) or die "client creation failed: [EMAIL PROTECTED]";

my $cw = $mc->AddMDIChild(
       -name  => 'window1',
       -text  => 'Window1',
       -pos   => [100, 100],
       -size  => [810, 610],
       -class => $child_class,
) or die "child creation failed: [EMAIL PROTECTED]";

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

As an aside a complete but minimal example showing your problem is
preferable so that it's quick and easy to run it, and so that we don't
have to work out what else we need to add in order to get your code to run.

Regards,
Rob.
--
Robert May
Win32::GUI, a perl extension for native Win32 applications
http://perl-win32-gui.sourceforge.net/

_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to