2013-04-22 117 views
-1

我在一個對話框中有兩個組合框,事情是我想知道哪個字符串已被選中並從組合框中獲取消息。我有以下代碼。但問題是,從這段代碼我無法區分哪個組合框被選中,並且這個代碼導致兩個框的索引號相同。win32 api從兩個組合框的對話框中讀取組合框的值

if(HIWORD(wParam) == CBN_SELCHANGE){ 
     _formatIndex = SendMessage((HWND) lParam, (UINT) CB_GETCURSEL, (WPARAM) 0, (LPARAM) IDD_IMAGES_MODE); 
     _savingModeIndex = SendMessage((HWND) lParam, (UINT) CB_GETCURSEL, (WPARAM) 0, (LPARAM) IDC_COMBOBOX_TIME_FRAME); 
    } 

回答

1

其實我只是找到了答案,這裏是代碼:

if(HIWORD(wParam) == CBN_SELCHANGE){ 
     if(LOWORD(wParam)==IDD_IMAGES_MODE){ 
     _formatIndex = SendMessage((HWND) lParam, (UINT) CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0); 
     } 
     if(LOWORD(wParam)==IDC_COMBOBOX_TIME_FRAME){ 
     _savingModeIndex = SendMessage((HWND) lParam, (UINT) CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0); 
     }   
    }