Thread: Int from a edit box on a dialog to dialog proc

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    202

    Int from a edit box on a dialog to dialog proc

    How can I recieve the Ints in editboxes int the dialog procedure? i tried using GetDlgItemInt and I didnt get any errors. I then decided to try a watch of the variable its being stored in and it came up and un defined, not un Initiated but undefined. Which i interperted as its not recieving the data from thye edit boxes correctly. Any suggestion?
    TIA,
    Isometric

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    42
    You need to add a global member variable for the edit box as type integer


    Code:
    
      UpdateData(); //Transfer data from controls to variables
    
      
      // do something
    
       
      UpdateData(FALSE);  //Transfer data from variables to controls

    Marky_Mark
    Last edited by Marky_Mark; 11-26-2001 at 05:38 PM.

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    202
    What do you mean a "gloabal member variable"?
    This sunds like C++ in which case Im only know C. If it is C++ is there anyway I can accomplish something similar in C?

  4. #4
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Are the int's declared in the callback?

    If you are not using static int variables you will be loosing the value collected by GetDlgItemInt() the next loop of the callback.

    As each msg, including the paint msg generated by you using the watch will pass thru the callback.


    //edit
    If you are not getting errors on compile, how can you have an undefined variable?
    //
    Last edited by novacain; 11-26-2001 at 10:11 PM.
    "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

  5. #5
    Registered User
    Join Date
    Nov 2001
    Posts
    202
    I have them initiated as static int s so its not that Im losing data. Asfor the Edit question I have no Idea. That is just what the watch said.

    //Edit\\
    I dont know if it matters but I just noticed that it is replaced with "???" after the program exits.
    Last edited by Isometric; 11-27-2001 at 02:52 PM.

  6. #6
    Registered User
    Join Date
    Oct 2001
    Posts
    42
    If our not using UpdateData() you need to declare a pointer for GetDlgItem() and then access the data that way


    Marky_Mark
    Last edited by Marky_Mark; 11-27-2001 at 03:05 PM.

  7. #7
    Registered User
    Join Date
    Nov 2001
    Posts
    202
    What is this UpdateData() function? I looked in MSDN and my compilers(Borland) help files and couldnt find it.

  8. #8
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    It's a MFC function, which acts as GetDlgItem(), but for all controls that have a control variable attached to them. You won't use it with plain C, and there are arguments that you shouldn't use it for MFC code aswell.
    zen

  9. #9
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Check your variables, pointers maybe?
    Try gettting the input in another way, it might show you the error.

    Declare an int as global, init it to -1 (or some value it could not pick up).
    Watch the WM_CREATE/WM_INIT msg and look at the contents of the variable.
    Enter your int into the edit and catch with GetDlgItemText() into a string as well the global int.

    Also are you using EN_CHANGE?
    ie
    case IDC_TEST:
    if (EN_CHANGE == HIWORD(wParam))
    {
    "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

  10. #10
    Registered User
    Join Date
    Nov 2001
    Posts
    202
    I tried pointers and I still get the same problem. I cant use the -1 thing since this is a graphing program across all quadrants so I have to take negative numbers(Althogh I havent implamented this yet).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Debug Error Really Quick Question
    By GCNDoug in forum C Programming
    Replies: 1
    Last Post: 04-23-2007, 12:05 PM
  2. Game Won't Compile
    By jothesmo in forum C++ Programming
    Replies: 2
    Last Post: 04-01-2006, 04:24 PM
  3. Replies: 2
    Last Post: 03-24-2006, 08:36 PM
  4. Converted from Dev-C++ 4 to Dev-C++ 5
    By Wraithan in forum C++ Programming
    Replies: 8
    Last Post: 12-03-2005, 07:45 AM
  5. Quack! It doesn't work! >.<
    By *Michelle* in forum C++ Programming
    Replies: 8
    Last Post: 03-02-2003, 12:26 AM