http://www.perlmonks.org?node_id=370447

flippy has asked for the wisdom of the Perl Monks concerning the following question:

Hi, This is my first question posted here - apologies if I've missed anything obvious...

I've just started using Win32::GUI in order to simplify user interaction with my programme.

To seamlessly integrate my code with that of other applications, I'd like to assign a colour to my main window's background. Either I'm having an off day, or it's non-trivial. Can anyone help?

Replies are listed 'Best First'.
Re: Win32::GUI frustration
by jplindstrom (Monsignor) on Jun 29, 2004 at 12:20 UTC
    It's actually non-trivial :) You need to define your own "class" (not an OO class) and assign the color to it, then assign the "class" to your window. This is roughly how to do it:

    my $clsColor = Win32::GUI::Class->new( -name => "classColor", -color => 2, ) or die("Could not create Class\n");

    And when you create the window, add the option

    -class => $clsColor,

    If you happen to use The GUI Loft, I stole this snippet from the demo program FetchURL. It's a bit different, so copy the demo program and go from there.

    /J

      That's ace - thanks!

      Although if you can tell me how '2' is 'pale blue', that'd be ace, too..

      I tried the following, as I need a specific colour, having read the faq, to no avail.. 'Could not create class'

      #Brush to define the colour my $brush = new Win32::GUI::Brush(-color=>[198, 223, 198])or die("Coul +d not create Brush\n"); #Class for the colour my $clsColour = Win32::GUI::Class->new( -name => "classColour", -color => $brush, ) or die("Could not create Class +\n");
      Above was me -- sorry, forgot to log in!
Re: Win32::GUI frustration
by gellyfish (Monsignor) on Jun 29, 2004 at 12:22 UTC