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

Thread: Edit Box

  1. #1
    Join Date
    Mar 2004
    Posts
    40

    Edit Box

    hi guys,
    need help...

    I would like to type a string of data in edit box1.
    and display in edit box2 after i press a "button".
    how do i code it?

  2. #2
    Join Date
    Mar 2004
    Location
    pathankot,punjab, india
    Posts
    57
    write this in OnButton1Click()
    {
    CString str;
    edit1.GetWindowText(str);
    edit2.SetWindowText(str);
    }
    NULL Pointer to intelligence

  3. #3
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652
    Add a message handler for the button 'OnClick' message. Inside it, get the data from the first edit control and put it into the second one...

  4. #4
    Join Date
    Mar 2004
    Posts
    40
    u mean like this

    void CSerialcommDlg::Onsend()
    {
    CString str;
    EDIT1.GetWindowText(str);
    edit2.SetWindowText(str);

    }

    but i got this error:
    C:\Testing Area\serialcomm\serialcommDlg.cpp(190) : error C2065: 'EDIT1' : undeclared identifier
    C:\Testing Area\serialcomm\serialcommDlg.cpp(190) : error C2228: left of '.GetWindowTextA' must have class/struct/union type
    C:\Testing Area\serialcomm\serialcommDlg.cpp(191) : error C2065: 'edit2' : undeclared identifier
    C:\Testing Area\serialcomm\serialcommDlg.cpp(191) : error C2228: left of '.SetWindowTextA' must have class/struct/union type

  5. #5
    Join Date
    Mar 2004
    Posts
    40
    Originally posted by Andreas Masur
    Add a message handler for the button 'OnClick' message. Inside it, get the data from the first edit control and put it into the second one...
    wat u mean by adding a message handler for the button??
    i dun really get it ..
    can u pls teach me how to do it. thanks

  6. #6
    Join Date
    Jan 2004
    Location
    Punjab, India
    Posts
    113
    You must associate your edit controls with variables edit1 and edit2. Use classwizard for this.

  7. #7
    Join Date
    May 2004
    Location
    Germany
    Posts
    655
    take this approach:

    open your Dialog template, CTRL+W, tab member variables and add member vars (category value, type CString) for your edit boxes

    lets say m_ctrlEdit1 and m_ctrlEdit2

    in OnSend:
    Code:
    UpdateData(true); //writes text in editboxes to memebr vars
    m_ctrlEdit2 = m_ctrlEdit1;
    UpdateData(false); //write text in member vars to edit boxes
    there are 10 kinds of people. those who understand binary and those who don't...

    rate a post if you find it usefull, thx
    check out my Firefox/Mozilla Extension: http://urlparams.blogwart.com/

  8. #8
    Join Date
    Mar 2004
    Posts
    40
    Originally posted by bigBA
    take this approach:

    open your Dialog template, CTRL+W, tab member variables and add member vars (category value, type CString) for your edit boxes

    lets say m_ctrlEdit1 and m_ctrlEdit2

    in OnSend:
    Code:
    UpdateData(true); //writes text in editboxes to memebr vars
    m_ctrlEdit2 = m_ctrlEdit1;
    UpdateData(false); //write text in member vars to edit boxes
    thanks!! I got it ...
    really indeed a great help.

  9. #9
    Join Date
    May 2004
    Location
    Germany
    Posts
    655
    Originally posted by larry77
    u mean like this

    void CSerialcommDlg::Onsend()
    {
    CString str;
    EDIT1.GetWindowText(str);
    edit2.SetWindowText(str);

    }

    but i got this error:
    C:\Testing Area\serialcomm\serialcommDlg.cpp(190) : error C2065: 'EDIT1' : undeclared identifier
    C:\Testing Area\serialcomm\serialcommDlg.cpp(190) : error C2228: left of '.GetWindowTextA' must have class/struct/union type
    C:\Testing Area\serialcomm\serialcommDlg.cpp(191) : error C2065: 'edit2' : undeclared identifier
    C:\Testing Area\serialcomm\serialcommDlg.cpp(191) : error C2228: left of '.SetWindowTextA' must have class/struct/union type
    if you want to use this code
    EDIT1 and edit2 have to be member variables of category control type CEdit
    there are 10 kinds of people. those who understand binary and those who don't...

    rate a post if you find it usefull, thx
    check out my Firefox/Mozilla Extension: http://urlparams.blogwart.com/

  10. #10
    Join Date
    Mar 2004
    Posts
    40
    so if i wan to vice-verse sending to each other ie: edit1 and edit2
    so how do i code it??

  11. #11
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652
    Originally posted by bigBA
    in OnSend:
    Code:
    UpdateData(true); //writes text in editboxes to memebr vars
    m_ctrlEdit2 = m_ctrlEdit1;
    UpdateData(false); //write text in member vars to edit boxes
    Well...one correction...never mix the standard type 'bool' with the Microsoft define 'BOOL'...thus...
    Code:
    UpdateData(TRUE); //writes text in editboxes to memebr vars
    m_ctrlEdit2 = m_ctrlEdit1;
    UpdateData(FALSE); //write text in member vars to edit boxes

  12. #12
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637
    Originally posted by larry77
    wat u mean by adding a message handler for the button??
    i dun really get it ..
    can u pls teach me how to do it. thanks
    My suggestion to you if you have to ask this question, is to get a good tutorial book on programming with MFC and work through it. I don't mean to this sound condecending, but What you're asking is rudimentary MFC coding. It sound like you may be a little ahead of yourself at this point. Work through a tutorial to get a handle on the basics, then some of this stuff will make sense. Untill you do that, I'm not sure any answers you recieve here will make sense to you.

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