EDIT styles

This is a discussion on EDIT styles within the Windows Programming forums, part of the Platform Specific Boards category; Does anyone know the styles I could use to create an EDIT control that the user cannot change, without greying ...

  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,701
    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, 12:56 PM
  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, 09:00 AM

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