Thread: Making Controls Editable/UnEditable

  1. #1
    Registered User
    Join Date
    May 2004
    Posts
    215

    Making Controls Editable/UnEditable

    Im working on a Win32 program in C, and I don't know how to set this check box I have as unedit/editable. I want it to start about being uneditable, and then when the user clicks certain buttons, I want it to become editable. THis is how my check box is defined when the program starts.

    hWndButton = CreateWindowEx(
    0,
    "BUTTON",
    "Swap Byte Order",
    WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX,
    10,
    80,
    130,
    20,
    hwnd,
    (HMENU)ID_CHECK_BOX1,
    hInstance,
    NULL);


    If someone can help, i would really appreciate it.

    Thanks

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    I'm not clear about what you're asking but there seem to be two possibilities.

    If you're looking just to set the check state of the checkbox then BM_GETCHECK and BM_SETCHECK are the messages you'll be interested in.

    If, on the other hand, you're attempting to change the checkbox caption then just use SetWindowText as required.

    If none of that seems relevant to your query then you'll have elaborate.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    Registered User
    Join Date
    May 2004
    Posts
    215
    Well lets say the user clicked the check box, if it were uneditable, it would do nothing, the user would not be able to do anything with it. it would be greyed out basically. thats what i mean

  4. #4
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,273
    Use the EnableWindow function to set whether it's enabled or grayed, then.

  5. #5
    Registered User
    Join Date
    May 2004
    Posts
    215
    Can you give me an example of how to use the enable window function

  6. #6
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,273
    Aiight. If you wanna start that thing you posted above as grayed, then you declare it as:-
    Code:
    hWndButton = CreateWindowEx(
    						0,
    						"BUTTON",
    						"Swap Byte Order",
    						WS_VISIBLE | WS_CHILD |  WS_DISABLED | BS_AUTOCHECKBOX, // note new style entry
    						10,
    						80,
    						130,
    						20,
    						hwnd,
    						(HMENU)ID_CHECK_BOX1,
    						hInstance,
    						NULL);
    Then, when you want to enable it, just call:-
    Code:
    EnableWindow(hWndButton, TRUE);
    To disable it, change TRUE to FALSE.

  7. #7
    Registered User
    Join Date
    May 2004
    Posts
    215
    Nevermind, i figured it out. thanks a lot!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Controls
    By osal in forum Windows Programming
    Replies: 7
    Last Post: 06-11-2004, 10:38 AM
  2. Subclassing controls
    By filler_bunny in forum Windows Programming
    Replies: 3
    Last Post: 04-28-2004, 05:43 PM
  3. I need help disabling Keyboard and Mouse input on Edit controls
    By Templario in forum Windows Programming
    Replies: 4
    Last Post: 01-07-2003, 12:59 AM
  4. MFC Controls and Thread Safety :: MFC
    By kuphryn in forum Windows Programming
    Replies: 0
    Last Post: 12-06-2002, 11:36 AM
  5. Site on Making Common Controls like BUttons
    By knight543 in forum Windows Programming
    Replies: 3
    Last Post: 03-02-2002, 06:10 PM