Code:
case IDB_CHOOSE:
cob_hwnd = GetDlgItem(hwnd,COB_COUNTRY);
cob_pos = (int)SendMessage(cob_hwnd,CB_GETCURSEL,0,0);
if(CB_ERR == SendDlgItemMessage
(hwnd,COB_COUNTRY,
CB_GETLBTEXT,
(WPARAM)1,(LPARAM)(LPCSTR)szCountryname)
{
error = GetLastError();
MessageBox(hwnd,"ttt","ttt",MB_OK);
}
SetDlgItemText(hwnd,IDE_COUNTRYCODE,szCountryname);
break;
COB_COUNTRY is the resource id of a combo box
the error code is 1400, that means invalid window handle.
In MSDN specification:
"The return value is the length of the string, in bytes, excluding the terminating null character. If the index parameter does not specify a valid index, the return value is CB_ERR. "
But I set a break point in first SendMessage statement, the cob_pos is a correct return value.
I've met this problem in many other programs, not only in combo box control, but also in other controls.