CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2002
    Posts
    34

    Simple question, but need you help

    I have a edit box. The variable associated with the edit box is "CString m_edit1". I want to know how to disable the edit box or enable the edit box.

    please advice.


  2. #2
    Join Date
    Mar 2000
    Location
    Bangalore,India
    Posts
    776

    Re: Simple question, but need you help

    Hi
    Use the Resource ID attached to that edit box for enabling or disabling the edit box.
    EX: say IDC_EDIT1 is your resource Id for that edit box then,
    //to disable
    GetDlgItem(IDC_EDIT1)->EnableWindow(FALSE);

    //to enable
    GetDlgItem(IDC_EDIT1)->EnableWindow(TRUE);

    Regards
    SKP

    Be sure to rate answers if it helped, to encourage them.

  3. #3
    Join Date
    Mar 2001
    Location
    Manila,Philippines
    Posts
    116

    Re: Simple question, but need you help

    you can use two ways:
    1. Create a variable control for your edit box
    ex: CEdit m_cedit1
    then type this code:
    m_cedit1.EnableWindow(0):To disable
    m_cedit1.EnableWindow(1):To enable

    2. get the control id of the control edit box(see in properties of edit box)
    Then type this code:
    GetDlgItem(control_id)::EnableWindow(0): To disable
    GetDlgItem(control_id)::EnableWindow(1): To enable.


    Hope it helps you...

    Please rate if this one answers your problem


  4. #4
    Join Date
    Jun 1999
    Location
    Singapore
    Posts
    1,304

    Re: Simple question, but need you help

    You need to create a CEdit for your edit box, just like how you create the variable except in this case you select 'Control' instead of 'Value' from the Category combo. Then you can use// m_ctrlEdit is the CEdit object that you have created for your edit box
    m_ctrlEdit.EnableWindow(/* TRUE or FALSE */);



    Chen Weiye
    --------------------------------------------------------------------------------------------
    When pursuing your dream, don't forget to enjoy your life...
    --------------------------------------------------------------------------------------------
    Chen Weiye
    -----------------------------------------------------------------------------
    When pursuing your dream, don't forget to enjoy your life
    -----------------------------------------------------------------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured