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

Thread: Edit box

  1. #1
    Join Date
    Jul 2009
    Location
    Houston TX
    Posts
    46

    Edit box

    how do i get content into a edit box
    I have a button and when i press it, i want to calulate 5 + 5, and it 10 goes into the edit box.


    in MVC++, I would use UPDATEDATE(FALSE), UPDATEDATA();


    .....
    if(HIWORD(wParam) == BN_CLICKED) <---under that code.....is where the code i need help with


    thank you

  2. #2
    Join Date
    Jul 2009
    Location
    Houston TX
    Posts
    46

    Re: Edit box

    Ok

    i got this code so far
    Code:
    case IDB_BUTTON:{
                 if(HIWORD(wParam) == BN_CLICKED){
                                   SetWindowText(hEdit, "MyTExt"); 
                                   }
                                   }
                                   break;
    when i click the button, it sets the edit box to MYTEXT...but how do i calculate something ..
    say i have to edit boxes. i put 2 in the first edit box, and i add the value 10 to it in the code..and it comes out to the second edit box as 12..

    thank you

  3. #3
    Join Date
    Apr 2005
    Posts
    32

    Re: Edit box

    Quote Originally Posted by acce55 View Post
    when i click the button, it sets the edit box to MYTEXT...but how do i calculate something ..
    say i have to edit boxes. i put 2 in the first edit box, and i add the value 10 to it in the code..and it comes out to the second edit box as 12..

    thank you
    This isn't really WinAPI specific (except the edit boxes).

    To get information out of an edit control, look at GetWindowText() on MSDN. If it's in a dialog, you can also look at GetDlgItemText()/GetDlgItemInt().

    If you need to perform operations on the variables (like adding, etc.), do that in your program with variables.

  4. #4
    Join Date
    Nov 2009
    Posts
    15

    Re: Edit box

    Use n= atof (MyText);

    to convert MyText into an integer

    n=n+10;

    then
    sprintf (MyText, "%.2f", n);

    or whatever format you like
    then
    SetWindowText(hEdit, "MyTExt");
    hope this helps

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