Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

how do I change window background colors in Win32::GUI?

by primus (Scribe)
on Jan 30, 2003 at 05:23 UTC ( [id://231205]=perlquestion: print w/replies, xml ) Need Help??

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


Hail Monks!

i am attempting to set the background color of my window, and it is really turning out to be a project. this is what i have so far...as an example
#!/usr/bin/perl use warnings; use strict; my $main_class = new Win32::GUI::Class( -name => "temp_Class", -color => 5, # i think 5 is the default window color, it seem +s i can only go on a scale from 1-5 ); my $main = new Win32::GUI::Window( -name => 'Main', -title => 'test', -width => '325', -height => '310', -minsize => ['300', '310'], -class => $main_class, -style => WS_OVERLAPPEDWINDOW, ); $main->Show(); Win32::GUI::Dialog();
for the class i have found that i can use a BRUSH object or COLOR value... though i seem to be restricted to 5 colors... (1-5). if you put a 0 in, the background is kinda transparent... and the others are weird shades of blue and red... i really just want to set the background to white, but i cant figure it out...

here is a mail message from the mailing list about RichEdit... not quite sure how to implement it... any help would be great.

thanks monks!
edited by boo_radley -- title change (was :another Win32::GUI question)

Replies are listed 'Best First'.
Re: another Win32::GUI question
by PodMaster (Abbot) on Jan 30, 2003 at 06:39 UTC
    I know very little about Win32::GUI, but on my win2k system, 6 is white, 7 is black, and 'red' is transparent ;D (color)


    MJD says you can't just make shit up and expect the computer to know what you mean, retardo!
    ** The Third rule of perl club is a statement of fact: pod is sexy.

Re: another Win32::GUI question
by BrowserUk (Patriarch) on Jan 30, 2003 at 07:25 UTC

    On my NT4 system, the numbers appear to relate to the currently loaded ColorScheme (PaletteScheme) as defined in Start->Settings->Control Panel->Display on the Appearance tab.

    For instance, using a value of 2 fills the window's background with the same bitmap as I have on my desktop and 3 seems to be the color selected for ActiveWindow (titlebar color).

    There is probably a set of constants define somewhere that relate the numbers to these values.

    Hope this helps.


    Examine what is said, not who speaks.

    The 7th Rule of perl club is -- pearl clubs are easily damaged. Use a diamond club instead.

Re: how do I change window background colors in Win32::GUI?
by dada (Chaplain) on Feb 11, 2003 at 14:41 UTC
    well, from the MSDN documentation:

    hbrBackground

    Handle to the class background brush. This member can be a handle to the physical brush to be used for painting the background, or it can be a color value. A color value must be one of the following standard system colors (the value 1 must be added to the chosen color) {...} When this member is NULL, an application must paint its own background whenever it is requested to paint in its client area.
    the last sentence explains the "kinda transparent" if you put a 0 (NULL) in.

    the "standard system colors" are the following ones (taken from include\winuser.h):

    #define COLOR_SCROLLBAR         0
    #define COLOR_BACKGROUND        1
    #define COLOR_ACTIVECAPTION     2
    #define COLOR_INACTIVECAPTION   3
    #define COLOR_MENU              4
    #define COLOR_WINDOW            5
    #define COLOR_WINDOWFRAME       6
    #define COLOR_MENUTEXT          7
    #define COLOR_WINDOWTEXT        8
    #define COLOR_CAPTIONTEXT       9
    #define COLOR_ACTIVEBORDER      10
    #define COLOR_INACTIVEBORDER    11
    #define COLOR_APPWORKSPACE      12
    #define COLOR_HIGHLIGHT         13
    #define COLOR_HIGHLIGHTTEXT     14
    #define COLOR_BTNFACE           15
    #define COLOR_BTNSHADOW         16
    #define COLOR_GRAYTEXT          17
    #define COLOR_BTNTEXT           18
    
    so, for example, if you want your window's background to be COLOR_APPWORKSPACE, you have to pass -color => 13 (that's 12 + 1) to your Win32::GUI::Class.

    the appearance of the colors is (should be? :-) documented by their own names. hope this helps...

    cheers,
    Aldo

    King of Laziness, Wizard of Impatience, Lord of Hubris

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://231205]
Approved by Courage
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-03-29 12:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found