win32 API EDIT BOX

This is a discussion on win32 API EDIT BOX within the Windows Programming forums, part of the Platform Specific Boards category; Programming in win32 and im just kinda playing around. What i want to do is enter a number into a ...

  1. #1
    Registered User
    Join Date
    Oct 2009
    Posts
    2

    win32 API EDIT BOX

    Programming in win32 and im just kinda playing around. What i want to do is enter a number into a edit box, and i hit a button, and it calulates and the result gets put into the second edit box......mainly this is for a radius math problem program i am making.


    Code:
     case IDB_BUTTON:{
                 if(HIWORD(wParam) == BN_CLICKED){
                             
                          
    
    
                                   }
                                   }
                                   break;
    inside there is where i put my code,....GETDLGITEMTEXT maybe work....and setDLGITEMTEXT...but i dont know how to calucate something...I WANT TO enter 12 into the first edit box.....i will calculate 2*PI*12.....and it goes into the second edit box after a button click

    tankyou

  2. #2
    Registered User
    Join Date
    Aug 2006
    Posts
    99
    Well, when the button is clicked, grab the text from the first box, convert it to a value (sscanf() perhaps?), do the math, print to a buffer, and set item text.

    You listed your formula there, do you mean you can't figure out how to enter that in a program?

  3. #3
    Registered User
    Join Date
    Oct 2009
    Posts
    2
    Ok thx for that information, expespecially the SSCANF fucntion. I got it to work.

    Instead of storing it into a buffer, i made a variable of the float type and stored the getdlgitemtext API FUNCTION into the variable. then used the senddlgitemint to set the edit box to the result

  4. #4
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    Code:
    int iNumber=0;
    double dResult=0;
    char szBuffer[MAX_PATH]={0};
    
    //get the value in the first edt
    iNumber  = GetDlgItemInt(hWnd, IDC_EDIT1, NULL, TRUE);
    //do the math
    dResult = iNumber * 3.1 * 2;
    //put in a text buffer
    _snprintf(szBuffer, MAX_PATH-1, "%f", dResult);
    //set the second edit
    SetDlgItem(hWnd, IDC_EDIT2, szBuffer);
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WS_HSCROLL in ES_READONLY edit box error
    By Homunculus in forum Windows Programming
    Replies: 4
    Last Post: 02-13-2006, 07:46 AM
  2. Multiline Edit Box Parser
    By The Brain in forum Windows Programming
    Replies: 6
    Last Post: 11-01-2005, 06:15 PM
  3. setting fixed floats in edit box
    By WaterNut in forum Windows Programming
    Replies: 4
    Last Post: 08-13-2004, 09:13 AM
  4. pthread api vs win32 thread api
    By Unregistered in forum Windows Programming
    Replies: 1
    Last Post: 11-20-2001, 07:55 AM
  5. Rich edit control example Win API
    By Echidna in forum Windows Programming
    Replies: 1
    Last Post: 09-17-2001, 02:12 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21