Thread: GetDlgItemInt not working

  1. #1
    Registered User
    Join Date
    Mar 2005

    GetDlgItemInt not working

    I have a Dialog window and on it I have an edit box. I want to retrieve the integer value in the edit box and point it to a variable. However the following code does not work:

    int Pval1 = GetDlgItemInt(IDD_DLGPie, txtVal1, 0, FALSE);
    where IDD_DLGPie is my dialogue window and txtVal1 is the edit box.

    I place the code in the WM_COMMAND: case.

    Any thoughts?

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    For future reference, "does not work" doesn't tell me anything at all. What exactly happens, or doesn't, as the case may be. Does it compile? Does it run? Does it crash? Does it give you a value you don't expect? What is "does not work"?

    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Mar 2005
    Gives a warning:
    [Warning] passing arg 1 of `GetDlgItemInt' makes pointer from integer without a cast

    and returns a value of 0 when it's suppose to be something else.

  4. #4
    Join Date
    Jan 2002
    The return value of zero indicates the function has failed and the warning message you're getting is telling you why: it requires the dialog(window) handle as the first parameter and not the id.

    See msdn: GetDlgItemInt for clarification.

    In future, please direct your windows specific questions to the windows board.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Function not working
    By sloopy in forum C Programming
    Replies: 31
    Last Post: 11-12-2005, 08:08 PM
  2. Program Not working Right
    By raven420smoke in forum C++ Programming
    Replies: 2
    Last Post: 09-16-2005, 03:21 AM
  3. Trying to eject D drive using code, but not working... :(
    By snowfrog in forum C++ Programming
    Replies: 3
    Last Post: 05-07-2005, 07:47 PM
  4. x on upper right corner not working
    By caduardo21 in forum Windows Programming
    Replies: 1
    Last Post: 02-20-2005, 08:35 PM
  5. cygwin -> unix , my code not working properly ;(
    By CyC|OpS in forum C Programming
    Replies: 4
    Last Post: 05-18-2002, 04:08 AM