CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Easy question!

  1. #1
    Join Date
    Apr 1999
    Posts
    79

    Easy question!

    Hello:
    I use vc++6.0 MFC.Built A Dialog class .
    Now I add a CEdit.I want change the value
    in CEdit .Which function can do it?
    Welcome any advice!
    Thanks!


  2. #2
    Join Date
    May 1999
    Posts
    667

    Re: Easy question!

    There are a couple of ways to accomplish this.

    1) Add a member variable of type CString to your dialog for the CEdit you just added. (with Classwizard). Then just set the text you want and call UpdateData(FALSE); FALSE - updates the controls TRUE get values from controls

    2) Add a member variable of type CEdit with Classwizrd and use m_myEdit.SetWindowText("TEXT");

    3) use GetDlgItem(IDC_YOUREDIT_ID)->SetWindowText("TEXT");

    HTH,
    Chris


  3. #3
    Join Date
    Apr 1999
    Posts
    79

    Re: Easy question!

    Thank you:
    Like your advice.(I created Dialog-base application)
    (1)I added a member variable of CString is m_name.(Use it change value)
    (2)I Add CEdit m_Edit.Add m_Edit.SetWindowText("TEXT")
    and GetdlgItem(IDC_my)->SetWindowText("TEXT") in OnInitDialog()
    When I run the result:First display "TEXT" in CEdit.
    But When I change the value use m_name.But the display
    not change.I add UpdataData(TRUE);The run is error(UpdataData no define);

    Could you help me?
    Thanks!


  4. #4
    Join Date
    Jul 1999
    Location
    Romania - Iasi
    Posts
    558

    Re: Easy question!

    If you defined a variable associated with your edit is not necessary to use GetDlgItem or a variable of type CEdit.
    If you need to take text from edit ctrl and put hem in your variable do this:

    UpdateData();



    If you need to take text from your variable and put him in your edit ctrl do this:

    m_name = "New value you want";
    UpdateData( FALSE );





    That's all.
    Let me know if this help u
    Regards,
    Ovidiu






  5. #5
    Join Date
    Apr 1999
    Posts
    79

    Re: Easy question!

    Thank you very much!
    That's very good like you advice!



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