Qutestion about combo box, I know I should not post this thread in this place, but...

This is a discussion on Qutestion about combo box, I know I should not post this thread in this place, but... within the C Programming forums, part of the General Programming Boards category; 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); ...

  1. #1
    Registered User
    Join Date
    Jun 2004
    Posts
    42

    Qutestion about combo box, I know I should not post this thread in this place, but...

    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.

  2. #2
    Registered User
    Join Date
    Jun 2004
    Posts
    42
    oops the forth parameter of the second SendMessage statement should be "cob_pos"

  3. #3
    ---
    Join Date
    May 2004
    Posts
    1,379
    This should be in the windows programming forum

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 02-13-2008, 02:59 PM
  2. disabling user input in a .NET 2.0 Combo box control
    By reanimated in forum Windows Programming
    Replies: 3
    Last Post: 05-01-2006, 07:29 AM
  3. Combo Box Problem
    By osal in forum Windows Programming
    Replies: 1
    Last Post: 06-06-2004, 05:45 PM
  4. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 10:44 AM
  5. Combo Box Extended
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 11-15-2001, 09:04 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21