Problem with SetDlgItemText

This is a discussion on Problem with SetDlgItemText within the Windows Programming forums, part of the Platform Specific Boards category; ok...to make this easier I downloaded a heap of SDK's from Microsoft for their documentation. I have taken the SetDlgItemText ...

  1. #1
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052

    Problem with SetDlgItemText

    ok...to make this easier I downloaded a heap of SDK's from Microsoft for their documentation. I have taken the SetDlgItemText from another post that I made and attempted to use it. I found all the information on it but I seem to be having a problem. Here is what I did with it:
    Code:
    SetDlgItemText(DLG_MAIN, IDC_STATUS, "Completed...");
    ...but I now get this error about my dialoge box:
    Code:
     error C2664: 'SetDlgItemTextA' : cannot convert parameter 1 from 'const int' to 'struct HWND__ *'
    ...I put all of the parameters in the right places just like it said here:
    Code:
    BOOL SetDlgItemText(
      HWND hDlg,         // handle to dialog box
      int nIDDlgItem,    // control identifier
      LPCTSTR lpString   // text to set
    );
    Does anybody know what's going on?

    (I hopfully wont have this many problems with windows soon becuase I'm going to buy a good windows programming book in like 2 or 3 days)

  2. #2
    Registered User
    Join Date
    Sep 2001
    Location
    England
    Posts
    121
    You're passing the dialog's ID rather than it's handle. I think that's it.

  3. #3
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    Try to typecase with (HWND).
    1978 Silver Anniversary Corvette

  4. #4
    S≠ťnior Member
    Join Date
    Jan 2002
    Posts
    982
    Get the handle to the control with GetDlgItem() and pass it as the first parameter.

  5. #5
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    Originally posted by Garfield
    Try to typecase with (HWND).
    huh?

  6. #6
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052

    another thing...

    when I pass hDlg as the first parameter, it says that it is undeclared when it is actually declared here:
    Code:
    BOOL CALLBACK APP_DlgProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)

  7. #7
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    Well, when a function is looking for a certain type (which is always the case), you must typecast so that it can do the proper conversions.
    1978 Silver Anniversary Corvette

  8. #8
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    What exactly is


    "DLG_MAIN"

    declared as?
    "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. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 04:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 10:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM

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