CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    May 1999
    Location
    Spain
    Posts
    335

    COMBOBOXEX, Execution error when I try to insert one item



    Hi,

    I'm trying to insert items to a COMBOBOXEX control ( the combo from IE), but when I send the message the program stops

    and gives me a nasty error, my code is:

    BOOL CComboDlg::AddItems(HWND hwndCB)

    {

    COMBOBOXEXITEM cbei;

    int iCnt;

    typedef struct {

    int iImage;

    int iSelectedImage;

    int iIndent;

    LPSTR pszText;

    } ITEMINFO, *pITEMINFO;

    ITEMINFO IInf[]= {

    {0,0,0,"First"},

    {0,0,0,"Second"},

    {0,0,0,"Third"},

    {0,0,0,"Fourth"},

    };

    cbei.mask = CBEIF_TEXT;

    for (iCnt = 0;iCnt<4;iCnt++) {

    cbei.iItem = iCnt;

    cbei.pszText = IInf[iCnt].pszText;

    cbei.cchTextMax = sizeof(IInf[iCnt].pszText);

    cbei.iImage = 0;

    cbei.iSelectedImage = 0;

    cbei.iIndent = 0 ;

    if (::SendMessage(hwndCB,CBEM_INSERTITEM,0,(LPARAM)&cbei==-1)) return FALSE;

    }

    //::SendMessage(hwndCB,CBEM_SETIMAGELIST,0,(LPARAM) &m_smallImageList);

    return TRUE;

    }


    How can I solve this ?, Thanks, Bye !

    Braulio

  2. #2
    Join Date
    Apr 1999
    Posts
    396

    Re: COMBOBOXEX, Execution error when I try to insert one item



    Your CBEM_INSERTITEM call it wrong. The last parameter, the address of an ITEMINFO structure, is being compared to =-1. You are sending it the boolean result. Basically it's like this ::SendMessage(hwnd,CBEM_INSERTITEM,0,1); What you want is this

    if (::SendMessage(hwndCB,CBEM_INSERTITEM,0,(LPARAM)&cbei) == -1) return FALSE;



  3. #3
    Join Date
    May 1999
    Location
    Spain
    Posts
    335

    Thanks ! Was that !



    Thanks !, Was that error, I copied it wrong, and change one parenthesis, I didn't realize until now.


    ...Some questions, From wich inherit CComboBoxEx from Cwnd or from CComboBox ?, Is easy to capture the OnDropDown ( with the class wizard and a normal combo box is easy, but with this CComboBoxEx ?), can I attach a pointer to every item in the COMBOBOXEX like in the normal CComboBox ( SetItemDataPtr) ?


    Thanks, Bye !

    Braulio

  4. #4
    Join Date
    Apr 1999
    Posts
    396

    Re: Thanks ! Was that !



    Yeah, in your COMBOBOXEXITEM structure, there is an lParam member. Just fill that member in, and remember to add CBEIF_LPARAM to the mask, and you're all set

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