LRESULT CALLBACK WndProc(HWND hWnd,UINT iMessage,WPARAM wParam,LPARAM lParam)
{
static HWND hCombo;
static TCHAR *Items[]={TEXT("Apple"),TEXT("Orange"),TEXT("Melon"),TEXT("Grape"),
TEXT("Strawberry")};
switch (iMessage) {
case WM_CREATE: {
int i;
hCombo=CreateWindow(TEXT("combobox"),NULL,WS_CHILD | WS_VISIBLE |
CBS_DROPDOWN,10,10,100,200,hWnd,(HMENU)ID_COMBOBOX,g_hInst,NULL);
for (i=0;i<5;i++) {
SendMessage(hCombo,CB_ADDSTRING,0,(LPARAM)Items[i]);
}
return 0;
}
case WM_DESTROY:
PostQuitMessage(0);
return 0;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case ID_COMBOBOX:
switch (HIWORD(wParam)) {
case CBN_SELCHANGE: {
TCHAR str[128];
int i;
i=SendMessage(hCombo, CB_GETCURSEL,0,0);
SendMessage(hCombo, CB_GETLBTEXT, i, (LPARAM)str);
...
}
return 0;
case CBN_EDITCHANGE: {
TCHAR str[128];
GetWindowText(hCombo, str, 128);
...
}
return 0;
}
}
break;
}
return(DefWindowProc(hWnd,iMessage,wParam,lParam));
}