Hi,
 
I've been trying to set/change the background color of windows. As a real world example: You want to create a child window that looks like a richtext control (white background) you also want to be able to change the background of the child window to grey (to give the illusion that it's 'disabled').
 
I don't think this scenario is possible with the current win32-gui codeline. It seems the only way to set the background of a window is by using a class, but there is no way to change the class once a window has been created. The following comments (from line 884 GUI.xs):
 
        /* TODO: change class ???
        if(perlcs.cs.iClass != NULL)
            SetWindowLong(handle, GWL_
        */
 
I had a little google on the web, and I couldn't find any examples on how to change a window class (only items within the class) - perhaps it can't be done? Surely there must be an easy way to change the background color of a window? Am I missing something?
 
The following perl code creates a (green) child window - I'm trying to change it to red:)
 
Cheers,
 
jez.
 
-------------------------
 
use Win32::GUI;
use strict;
 
my $col=65025;
 
my $redbrush = new Win32::GUI::Brush(-color => [255,0,0]);
my $greenbrush = new Win32::GUI::Brush(-color => [0,255,0]);
 
my $WC = new Win32::GUI::Class(
     -name => "redrush",
     -brush => $redbrush,
);
 
my $WC2 = new Win32::GUI::Class(
     -name => "greenbrush",
     -brush => $greenbrush,
);
 

my $win = new Win32::GUI::Window (
    -pos         => [100, 100],
    -size        => [400, 400],
    -name        => 'Window',
    -text        => 'Main Window',
   # -onTimer     => \&Change,
);
#$win->AddTimer("Timer", 10);
 
$win->AddButton(
    -name        => 'button',
    -pos         => [0, 0],
    -size        => [50, 20],
    -text        => 'change',
    -onClick     => \&Change,
);
 
my $child = new Win32::GUI::Window (
    -parent      => $win,
    -name        => 'ChildWin',
    -pos         => [100, 100],
    -size        => [100, 100],
    -popstyle    => WS_CAPTION | WS_SIZEBOX,
    -pushstyle   => WS_CHILD | WS_CLIPCHILDREN,
    -pushexstyle => WS_EX_CLIENTEDGE,
    -class       => $WC2,
);
 
my $lable=$child->AddLabel(
    -name        => 'Lab',
    -pos         => [20, 20],
    -size        => [50, 20],
    -text        => 'Some text',
    -background => [255,0,0],
);
 

$child->Show();
$win->Show();
 
Win32::GUI::Dialog();
 
sub Change() {
  $child->Change(-class => $WC);
  #$lable->Change(-background => $col);
  $child->InvalidateRect(0);
  #$lable->InvalidateRect(0);
  $col+=20;
  print $col;
}