I have a listbox on a dialog box. I want to change the text of a static control to the selected text of the listbox whenever the selection is changed. The listbox is a "single selection" listbox and it has "LBS_NOTIFY" style. I am using the following code but nothing happens:

Code:
case ID_LIST:
if(HIWORD(wparam) == LBN_SELCHANGE)
{
selindex = SendMessage(GetDlgItem(hwnd, ID_LIST),
LB_GETCURSEL,0,0);
sellen = SendMessage(GetDlgItem(hwnd, ID_LIST), LB_GETTEXTLEN,selindex,0);
seltext = (char*)GlobalAlloc(GPTR, sellen + 1);
SendMessage(GetDlgItem(hwnd, ID_LIST), LB_GETTEXT,selindex, (LPARAM)seltext);
SetDlgItemText(hwnd, ID_SELECTION, "seltext");
GlobalFree(seltext);
}

Can you check the error in there please?