From: Jez W. <je...@je...> - 2004-11-12 10:27:11
|
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 !=3D 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=3D65025; my $redbrush =3D new Win32::GUI::Brush(-color =3D> [255,0,0]); my $greenbrush =3D new Win32::GUI::Brush(-color =3D> [0,255,0]); my $WC =3D new Win32::GUI::Class( -name =3D> "redrush", -brush =3D> $redbrush, ); my $WC2 =3D new Win32::GUI::Class( -name =3D> "greenbrush", -brush =3D> $greenbrush, ); my $win =3D new Win32::GUI::Window ( -pos =3D> [100, 100], -size =3D> [400, 400], -name =3D> 'Window', -text =3D> 'Main Window', # -onTimer =3D> \&Change, ); #$win->AddTimer("Timer", 10); $win->AddButton( -name =3D> 'button', -pos =3D> [0, 0], -size =3D> [50, 20], -text =3D> 'change', -onClick =3D> \&Change, ); my $child =3D new Win32::GUI::Window ( -parent =3D> $win, -name =3D> 'ChildWin', -pos =3D> [100, 100], -size =3D> [100, 100], -popstyle =3D> WS_CAPTION | WS_SIZEBOX, -pushstyle =3D> WS_CHILD | WS_CLIPCHILDREN, -pushexstyle =3D> WS_EX_CLIENTEDGE, -class =3D> $WC2, ); my $lable=3D$child->AddLabel( -name =3D> 'Lab', -pos =3D> [20, 20], -size =3D> [50, 20], -text =3D> 'Some text', -background =3D> [255,0,0], ); $child->Show(); $win->Show(); Win32::GUI::Dialog(); sub Change() { $child->Change(-class =3D> $WC); #$lable->Change(-background =3D> $col); $child->InvalidateRect(0); #$lable->InvalidateRect(0); $col+=3D20; print $col; } |