-
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????
-
Did you try
SendDlgItemMessage(hdwnd, IDD_EB1,
WM_SETTEXT, 0,(LPARAM)books[0]); ?
What is books[0] ?
-
THat works, thanks, any ideas why the other doesn't?
books[] is just an array of strings(book titles).
-
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.