SetDlgItemText not working

This is a discussion on SetDlgItemText not working within the Windows Programming forums, part of the Platform Specific Boards category; hi i have this code: Code: ... case ID_O_NAM: DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_NAM), hwnd, PProc); break; ... //then in PProc BOOL CALLBACK ...

  1. #1
    ~viaxd() viaxd's Avatar
    Join Date
    Aug 2003
    Posts
    246

    SetDlgItemText not working

    hi i have this code:

    Code:
    ...
              case ID_O_NAM:
                DialogBox(GetModuleHandle(NULL), 
                          MAKEINTRESOURCE(IDD_NAM), hwnd, PProc);
                  break;   
    ...
    //then in PProc
    
    BOOL CALLBACK PProc(HWND hdlg, UINT Message, WPARAM wParam, LPARAM lParam)
    {
      static HWND box;
        switch(Message)
        {
            case WM_INITDIALOG:
                box = GetDlgItem(hdlg, IDC_ED1);  
                SetDlgItemText(hdlg, IDC_ED1, "me");
            return true;
    ...
    it's not working. it does not set the text. also if i add a check, box is NULL. but everything displayes ok, just no default text. what's wrong?
    :wq

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    If box is NULL, then you have either the wrong control ID, or the wrong dialog HWND value.

  3. #3
    ~viaxd() viaxd's Avatar
    Join Date
    Aug 2003
    Posts
    246
    the control id is correct, i've checked it.
    How do i get a correct HWND value if it's wrong?
    :wq

  4. #4
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    Why not place a call to GetLastError after SetDlgItemText too see what the error code is.

  5. #5
    ~viaxd() viaxd's Avatar
    Join Date
    Aug 2003
    Posts
    246
    strange, GetLastError() says 1421: Control ID not found

    [edit]
    Ahhh, never mind. It appears there was an error in my .rc file...
    [/edit]
    Last edited by viaxd; 01-14-2006 at 02:58 AM.
    :wq

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, 04: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, 08: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, 05:08 AM

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