problems with CTLCOLOR's

This is a discussion on problems with CTLCOLOR's within the Windows Programming forums, part of the Platform Specific Boards category; i have WM_CTLCOLORLISTBOX and WM_CTLCOLOREDIT Code: HBRUSH lbColor = CreateSolidBrush(RGB(0,0,0)); HBRUSH editColor = CreateSolidBrush(RGB(0,0,0)); Code: case WM_CTLCOLORLISTBOX: SetBkColor((HDC)wParam, RGB(0,0,0)); SetTextColor((HDC)wParam, ...

  1. #1
    Registered User Rare177's Avatar
    Join Date
    May 2004
    Posts
    214

    problems with CTLCOLOR's

    i have WM_CTLCOLORLISTBOX and WM_CTLCOLOREDIT

    Code:
    	HBRUSH lbColor = CreateSolidBrush(RGB(0,0,0)); 
    	HBRUSH editColor = CreateSolidBrush(RGB(0,0,0));
    Code:
    		case WM_CTLCOLORLISTBOX: 
    			SetBkColor((HDC)wParam, RGB(0,0,0)); 
    			SetTextColor((HDC)wParam, RGB(255,255,255));
    
    			return ((LRESULT)lbColor);
    
    		case WM_CTLCOLOREDIT:
    			SetBkColor((HDC)wParam, RGB(0,0,0));
    			SetTextColor((HDC)wParam , RGB(255,255,255));
    
    			return ((LRESULT)editColor);
    the problem is when i resize the window, after doing this a few times it paints the controls back to there standard color(white back black font)

    does any one know a solution to this, thanks

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Very possibly with the way you're creating those brush handles but without more information it's hard to say - where in your program are they declared and what scope do they have, for example.

    Still, if all you want is a black background then just use the stock black brush, ie.
    Code:
    case WM_CTLCOLORLISTBOX: 
      SetBkColor((HDC)wParam, RGB(0,0,0)); 
      SetTextColor((HDC)wParam, RGB(255,255,255));
    
    return ((LRESULT)GetStockObject(BLACK_BRUSH));
    
    case WM_CTLCOLOREDIT:
      SetBkColor((HDC)wParam, RGB(0,0,0));
      SetTextColor((HDC)wParam , RGB(255,255,255));
    
      return ((LRESULT)GetStockObject(BLACK_BRUSH));
    At least this will give you a result and you won't have to worry about gdi resource leaks. See GetStockObject for more details.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. No clue how to make a code to solve problems!
    By ctnzn in forum C Programming
    Replies: 8
    Last Post: 10-16-2008, 03:59 AM
  2. C Pointers Problems
    By mhelal in forum C Programming
    Replies: 8
    Last Post: 01-10-2007, 06:35 AM
  3. String Manipulation problems -_-
    By Astra in forum C Programming
    Replies: 5
    Last Post: 12-13-2006, 05:48 PM
  4. Rendering problems (DirectX?)
    By OnionKnight in forum Tech Board
    Replies: 0
    Last Post: 08-17-2006, 01:17 PM
  5. contest problems on my site
    By DavidP in forum Contests Board
    Replies: 4
    Last Post: 01-10-2004, 09:19 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21