Thread: coloring child windows

  1. #1
    Unregistered
    Guest

    Angry coloring child windows

    i'm trying to change the color of buttons, listboxes, edit controls, etc. i can change the colors of the listboxes and edit controls but it doesn't seem to be working correctly, and i can't seem to change the color of my button at all. here's my code for the listbox:

    [global]
    HBRUSH br = CreateSolidBrush(RGB(255,255,255));

    case WM_CTLCOLORLISTBOX:
    SetBkColor((HDC)wParam, RGB(0,74,128));
    SetTextColor((HDC)wParam, RGB(255,255,255));
    return ((LRESULT)br);
    break;

    the listbox shows up with white text, but the background of the box isn't totally colored dark blue, instead it looks like the text is "highlighted" with dark blue, but it's only like this is one of my listboxes. my other listbox has the LBS_EXTENDEDSEL style, and it is fully colored in. it's the same way when i use this code for edit controls also; the area behind the text is dark blue. am i doing something wrong?
    any idea as to why i can't get my button to be a different color? is there some style that i need? i tried it with just the WS_CHILDWINDOW and WS_VISIBLE styles, then i added BS_PUSHBUTTON and BS_NOTIFY, but nothing changed.
    extra info: i'm using Bloodshed's DevC++ compiler.
    thanks for the help.

    alandrums

  2. #2
    Registered User Esss's Avatar
    Join Date
    Aug 2001
    Posts
    133
    HBRUSH br = CreateSolidBrush(RGB(255,255,255));
    (...)
    return ((LRESULT)br);

    You are returning a white brush, so you would expect the background to be coloured white.

    > any idea as to why i can't get my button to be a different color?

    Read the description for WM_CTLCOLORBTN:

    "Buttons with the BS_PUSHBUTTON, BS_DEFPUSHBUTTON, or BS_PUSHLIKE styles do not use the returned brush. Buttons with these styles are always drawn with the default system colors. Drawing push buttons requires several different brushes-face, highlight and shadow-but the WM_CTLCOLORBTN message allows only one brush to be returned. To provide a custom appearance for push buttons, use an owner-drawn button."
    Ess
    Like a rat in a maze who says,
    "Watch me choose my own direction"
    Are you under the illusion
    The path is winding your way?
    - Rush

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can't create child windows
    By OnionKnight in forum Windows Programming
    Replies: 4
    Last Post: 04-10-2011, 04:13 PM
  2. Child windows
    By Gordon in forum Windows Programming
    Replies: 1
    Last Post: 04-25-2008, 12:53 PM
  3. Child windows
    By beene in forum Windows Programming
    Replies: 2
    Last Post: 12-13-2006, 04:22 AM
  4. Keeping child windows in their place
    By Smallz in forum Windows Programming
    Replies: 1
    Last Post: 08-27-2006, 06:22 AM
  5. child windows
    By face_master in forum Windows Programming
    Replies: 14
    Last Post: 03-01-2002, 07:08 AM