HWND g_hList;
LRESULT CALLBACK WndProc(HWND hWnd,UINT iMessage,WPARAM wParam,LPARAM lParam)
{
int i;
TCHAR str[128];
switch (iMessage) {
case WM_CREATE:
g_hList = CreateWindow(TEXT("listbox"), NULL, WS_CHILD|WS_VISIBLE|WS_BORDER|
LBS_NOTIFY,10,10,100,200,hWnd,(HMENU)ID_LISTBOX,g_hInst,NULL);
for (i=0; i<5; i++) {
SendMessage(g_hList, LB_ADDSTRING, 0, (LPARAM)Items[i]);
}
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case ID_LISTBOX:
switch (HIWORD(wParam)) {
case LBN_SELCHANGE:
i = SendMessage(g_hList, LB_GETCURSEL, 0, 0);
SendMessage(g_hList, LB_GETTEXT, i, (LPARAM)str);
SetWindowText(hWnd, str);
break;
}
}
return 0;
}
return (DefWindowProc(hWnd, iMessage, wParam, lParam));
}