Thread: EDIT styles

  1. #1
    Mmm. Purple.
    Join Date
    May 2002
    Posts
    154

    EDIT styles

    Does anyone know the styles I could use to create an EDIT control that the user cannot change, without greying it out like ES_READONLY does?

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    I would use ES_READONLY. Then handle the WM_CTLCOLORSTATIC message to give the control "normal" colors.

    gg

  3. #3
    Mmm. Purple.
    Join Date
    May 2002
    Posts
    154
    wParam
    Handle to the device context for the static control window.
    lParam
    Handle to the static control.

    Could you explain what that acctualy means? It's going straight over my head (code is helpful! )

  4. #4
    uh oh
    Join Date
    Jan 2005
    Location
    Ontario, CA
    Posts
    66
    Basically in your windows procedure function have the following:

    Code:
    WM_CTLCOLORSTATIC:
             if( (HWND)lParam == hMyEdit ) return(GetStockObject(WHITE_BRUSH));
             break;
    The if should be pretty self-explanitory. However, I will explain just incase. Basically you check the lParam value against the HWND returned when you used CreateWindow or CreateWindowEx in order to create your edit control. If these both equal the same (thus your read-only editbox is the control receiving this message), then you would return a handle to the brush color you want your background of the control to be. I used GetStockObject which would return a handle to the brush color, in this case WHITE_BRUSH. Which turns the background white.

    Hope this helps,
    cyreon

  5. #5
    Mmm. Purple.
    Join Date
    May 2002
    Posts
    154
    Cheers that worked, i just tried like 4 pieces of example code i found on google with no success.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. (Multiline) Edit Control Limit
    By P4R4N01D in forum Windows Programming
    Replies: 9
    Last Post: 05-17-2008, 11:56 AM
  2. line number on a rich edit control
    By rakan in forum Windows Programming
    Replies: 1
    Last Post: 02-18-2008, 07:58 AM
  3. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 06:23 AM
  4. WS_HSCROLL in ES_READONLY edit box error
    By Homunculus in forum Windows Programming
    Replies: 4
    Last Post: 02-13-2006, 08:46 AM
  5. Replies: 3
    Last Post: 07-23-2005, 08:00 AM