Edit Controls - Colors - Messages

This is a discussion on Edit Controls - Colors - Messages within the Windows Programming forums, part of the Platform Specific Boards category; Hi All, I need to know whats going on here I am working with edit controls. I have been trying ...

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    55

    Edit Controls - Colors - Messages

    Hi All,

    I need to know whats going on here I am working with edit controls. I have been trying to change the background brush on them, but cant seem to be able to access the background. I have been trying with GetClassLong and SetClassLong. This dont work, but i guess its because i havent registert the edit control and it hasnt got its on WNDCLASSEX set up. Anyway, i have managed by catching the WM_CTLCOLOREDIT and setcolor and background there. But that only works on one line of text at a time. So in the edit window procedure(subclassed), under the WM_PAINT i get the rect in the painstructure and use it in a call to FillRect to set the background color. My question is: If i take the setbk, settext..statements in the WM_CTLCOLOREDIT case and put them just before the FillRect in the subclass rutine, it dosnt work? The way i understand it is that the WM_CTLCOLOREDIT message is sent just before the paint message and would it matter where you had those statements(setbk...setText) e.g. in the WM_CTLCOLOREDIT or WM_PAINT? And is there a easier way to set the background. E.g. in a call to some function the same as GetClassLong etc....


    G'n'R

  2. #2
    Registered User
    Join Date
    Aug 2001
    Posts
    55

    Ok...

    he he, ok, i just found this code after a search on the board. This works perfectly. But whats exactly is happening. I understand the everythig expect the return statement. Is this returning to the Edit controls window procedure. Either the subclassed or default? And how is it setting the background color by returning the stockobjent ( my mind is boggling trying to figure out how this works)

    Code:
    case WM_CTLCOLOREDIT:{
       if((HWND)lparam == messageHwnd){
          SetTextColor((HDC)wparam, RGB(255,255,255));
          SetBkMode((HDC)wparam, TRANSPARENT);
          return (int)(HBRUSH)GetStockObject(BLACK_BRUSH);
      }	                
    						         
      return(0);
    }

  3. #3
    Master of the Universe! velius's Avatar
    Join Date
    Sep 2003
    Posts
    219
    From MSDN:
    If an application processes this message(WM_CTLCOLOREDIT), it must return the handle of a brush. The system uses the brush to paint the background of the edit control.
    While you're breakin' down my back n'
    I been rackin' out my brain
    It don't matter how we make it
    'Cause it always ends the same
    You can push it for more mileage
    But your flaps r' wearin' thin
    And I could sleep on it 'til mornin'
    But this nightmare never ends
    Don't forget to call my lawyers
    With ridiculous demands
    An you can take the pity so far
    But it's more than I can stand
    'Cause this couchtrip's gettin' older
    Tell me how long has it been
    'Cause 5 years is forever
    An you haven't grown up yet
    -- You Could Be Mine - Guns N' Roses

  4. #4
    Registered User
    Join Date
    Aug 2001
    Posts
    55
    hehe, ok....dosnt say that here, but then again...got old msnd documentation...

    Ta....

    G'n'R

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. edit control text buffer
    By scurvydog in forum Windows Programming
    Replies: 4
    Last Post: 12-11-2008, 09:13 AM
  2. Edit Controls Text Font
    By csonx_p in forum Windows Programming
    Replies: 7
    Last Post: 07-02-2008, 08:05 AM
  3. Any reason for Edit Controls to flicker?
    By csonx_p in forum Windows Programming
    Replies: 21
    Last Post: 06-06-2008, 02:27 AM
  4. Q's About Edit Controls
    By Tonto in forum Windows Programming
    Replies: 7
    Last Post: 08-26-2006, 03:07 PM
  5. Window closes when edit is made
    By eam in forum Windows Programming
    Replies: 7
    Last Post: 11-06-2003, 08:11 PM

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