Thread: getting a Double with GetDlgItemInt

  1. #1
    Wen Resu
    Join Date
    May 2003
    Posts
    219

    getting a Double with GetDlgItemInt

    My problem is pretty simple
    have an app when i need to be able to get Decimel number from an edit control, i am trying to do this using the GetDlgItemInt function, which by itsn ame and by testing seems to only work for ints.
    Process would be
    User enters number hits button IE 4.23->
    Code:
    i do  
    double ViNum = GetDlgItemInt(hwnd, IDC_VI, &ViSuccess, FALSE); 
    then i do
    if (ViSuccess  && TSuccess  && !DSuccess && !DFound) {
       stevenfritz("Use 1 to find D", "Notice"); // debug code
       DNum = Dis1(ViNum, TNum, ANum);
       DFound = TRUE;
       SetDlgItemInt(hwnd, IDC_D, DNum, TRUE );
    
          }
    Despite my Searching with google and MSDN i can't find a suitable function to do this for me, and i hope to be able to do this without doign it by hand
    Any help is much appreceated
    Last edited by Iamien; 09-16-2003 at 05:15 PM.

  2. #2
    Wen Resu
    Join Date
    May 2003
    Posts
    219
    good old atof()
    Code:
     char* ViStr;
     int len = GetWindowTextLength(GetDlgItem(hwnd, IDC_VI));
     ViStr = (char*)GlobalAlloc(GPTR, len + 1);
     GetDlgItemText(hwnd, IDC_VI, ViStr, len + 1);
     ViNum = atof(ViStr);

  3. #3
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    sscanf is better.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  4. #4
    Wen Resu
    Join Date
    May 2003
    Posts
    219
    aaah stop making me rewrite code with faster stuff you evil man! :P
    ah well smal lrewrite of couple functions

  5. #5
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    GetDlgItemText(hwnd, IDC_VI, ViStr, len + 1);

    I think you ment

    GetDlgItemText(hwnd, IDC_VI, ViStr, len);
    "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. Copying 2-d arrays
    By Holtzy in forum C++ Programming
    Replies: 11
    Last Post: 03-14-2008, 03:44 PM
  2. Conversion From C++ To C
    By dicon in forum C++ Programming
    Replies: 2
    Last Post: 06-10-2007, 02:54 PM
  3. need some help with last part of arrays
    By Lince in forum C Programming
    Replies: 3
    Last Post: 11-18-2006, 09:13 AM
  4. newbie needs help with code
    By compudude86 in forum C Programming
    Replies: 6
    Last Post: 07-23-2006, 08:54 PM
  5. Unknown Math Issues.
    By Sir Andus in forum C++ Programming
    Replies: 1
    Last Post: 03-06-2006, 06:54 PM