CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2006
    Location
    Bangalore
    Posts
    76

    [RESOLVED] Getting the Combo Box selected item.

    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.

  2. #2
    Join Date
    Dec 2006
    Location
    Bangalore
    Posts
    76

    Lightbulb Re: [RESOLVED] Getting the Combo Box selected item.

    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);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured