SetDlgItemText()

This is a discussion on SetDlgItemText() within the Windows Programming forums, part of the Platform Specific Boards category; I have this code in my dialog box function: Code: case WM_INITDIALOG: SendDlgItemMessage(hdwnd, IDD_LB1, LB_ADDSTRING, 0, (LPARAM)books[0]); SendDlgItemMessage(hdwnd, IDD_LB1, LB_ADDSTRING, ...

  1. #1
    Registered User C_Coder's Avatar
    Join Date
    Oct 2001
    Posts
    523

    SetDlgItemText()

    I have this code in my dialog box function:
    Code:
    case WM_INITDIALOG:
    			SendDlgItemMessage(hdwnd, IDD_LB1, LB_ADDSTRING, 0, (LPARAM)books[0]);
    			SendDlgItemMessage(hdwnd, IDD_LB1, LB_ADDSTRING, 0, (LPARAM)books[1]);
    			SendDlgItemMessage(hdwnd, IDD_LB1, LB_SETCURSEL, 0, 0);
    			SetDlgItemText(hdwnd, IDD_EB1, books[0]);
    			return 1;
    the dialog box contains a list box and an edit box(plus some push buttons). The program compiles and links with no errors or warnings but when I run it and select the menu item which activates the dialog box I get an error message form windows saying error in kernel dll. If I remove the SetDlgItemText() The program works fine. The point of the SetDlgItemText is to initialise the edit box so it has the first string thats in the list box.

    As a short term fix I'll just leave it out, but would like some suggestions????
    All spelling mistakes, syntatical errors and stupid comments are intentional.

  2. #2
    Unregistered
    Guest
    Did you try

    SendDlgItemMessage(hdwnd, IDD_EB1,
    WM_SETTEXT, 0,(LPARAM)books[0]); ?


    What is books[0] ?

  3. #3
    Registered User C_Coder's Avatar
    Join Date
    Oct 2001
    Posts
    523
    THat works, thanks, any ideas why the other doesn't?
    books[] is just an array of strings(book titles).
    All spelling mistakes, syntatical errors and stupid comments are intentional.

  4. #4
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,855
    It may not realise that Books is a multi dimensional array.

    So it may not stop at the end of the Books[0], start of Books[1], string but use the rest of the memory allocated to the array. This may be bigger than is allowed / allocated for a string in the ctrl.
    I know Tree-views can't have more that 32k of items so there may be a limit.

    Try using a temp string to add the item to the ctrl.
    "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. SetDlgItemText not working
    By viaxd in forum Windows Programming
    Replies: 4
    Last Post: 01-14-2006, 01:55 AM
  2. Dialog doesn't respond to tab key
    By dhaupt in forum Windows Programming
    Replies: 8
    Last Post: 08-11-2004, 12:41 PM
  3. Using the SetDlgItemText function
    By nima_ranjbar in forum Windows Programming
    Replies: 4
    Last Post: 04-25-2002, 02:44 PM
  4. Problem with SetDlgItemText
    By face_master in forum Windows Programming
    Replies: 7
    Last Post: 01-28-2002, 09:24 PM
  5. SetDlgItemText?
    By BubbleMan in forum Windows Programming
    Replies: 19
    Last Post: 10-02-2001, 03:07 AM

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