Click to See Complete Forum and Search --> : [RESOLVED] Getting the Combo Box selected item.


Suresh.hc
January 17th, 2007, 12:23 AM
Hello All,

I am adding values 0,1,3 to a combo box in Initdialog

switch(Message)
{
case WM_INITDIALOG:
{
HWND hwndCombo = GetDlgItem(hwnd, IDC_CB);
SendMessage(hwndCombo , CB_ADDSTRING,0, (LPARAM) "0");
SendMessage(hwndCombo , CB_ADDSTRING,0, (LPARAM) "1");
SendMessage(hwndCombo , CB_ADDSTRING,0, (LPARAM) "2");
}



in other function I want to use the value of the combo box, (user selected item) for that I am using below code

int F;
HWND HCBF = GetDlgItem(hwnd, IDC_CB);
SendMessage(HCBF , CB_GETITEMDATA,(WPARAM)F, 0);


This code has no error but I am getting some junk value and i am not geting the values 0,1,2
Can u please tell me what is the error in the above code ???


Thanking you,

Suresh HC.

Suresh.hc
January 17th, 2007, 01:28 AM
I got the Solution.

HWND hCombo = GetDlgItem(hwnd, IDC_CB);
int nIndex =::SendMessage(hCombo,CB_GETCURSEL,0,0);
TCHAR F[4];
SendMessage(hCombo,CB_GETLBTEXT,(WPARAM)nIndx,(LPARAM)F);