GetItem Fails with the my comuter - Programmer

This is a discussion on GetItem Fails with the my comuter - Programmer ; Hello, I am very new to MFC and Windows program, for our one application we are grouping all icons of desktop into a folder and using GetItem function to get the selected item, later on i am calling function ShellExecute ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: GetItem Fails with the my comuter

  1. GetItem Fails with the my comuter

    Hello,

    I am very new to MFC and Windows program, for our one application we
    are grouping all icons of desktop into a folder and using GetItem
    function to get the selected item, later on i am calling function
    ShellExecute to excute the command on the selected item.
    The GetItem in my case is not workig for Shell Name ext like My
    Computer , Outlook and Recycle Wind etc.
    Can anyone help me in this regards

    pitem->iItem = GetNextSelectedItem (pos);
    GetItem(pitem)
    SHGetPathFromIDList((LPITEMIDLIST)pitem->lParam, psSourcePath);


    For any of Shell Name ext , the lParam is coming 0

  2. Re: GetItem Fails with the my comuter

    There is two ways to get the selected item(s).

    the first one is to use GetFirstSelectedItemPosition and
    GetNextSelectedItem, the 2nd one is to use CListCtrl::GetNextItem with
    LVNI_SELECTED flag.If you check MFC source,you can find that the first
    method calls the 2nd method internally.

    sample code for GetFirstSelectedItemPosition and GetNextSelectedItem

    CListCtrl* pListCtrl = (CListCtrl*) GetDlgItem(IDC_YOURLISTCONTROL);
    ASSERT(pListCtrl != NULL);

    POSITION pos = pList->GetFirstSelectedItemPosition();
    if (pos == NULL)
    TRACE0("No items were selected!\n");
    else
    {
    while (pos)
    {
    int nItem = pList->GetNextSelectedItem(pos);
    TRACE1("Item %d was selected!\n", nItem);
    // you could do your own processing on nItem here
    }
    }
    sample code for GetNextItem
    void CListView::OnDblClick(NMHDR* /*k*/, LRESULT* /*j*/)
    {
    int nItem, nFlags;
    char szTest[80];
    nFlags = LVNI_SELECTED;
    nItem = m_ListCtrl->GetNextItem(-1, nFlags );
    if ( nItem != -1 )
    {
    sprintf( szTest, "Selected Item %d", nItem);
    AfxMessageBox(szTest);
    }
    }


    "Amit Gupta" дʼ
    news:5ff72250.0408250633.74cbab3f@posting.google.c om...
    > Hello,
    >
    > I am very new to MFC and Windows program, for our one application we
    > are grouping all icons of desktop into a folder and using GetItem
    > function to get the selected item, later on i am calling function
    > ShellExecute to excute the command on the selected item.
    > The GetItem in my case is not workig for Shell Name ext like My
    > Computer , Outlook and Recycle Wind etc.
    > Can anyone help me in this regards
    >
    > pitem->iItem = GetNextSelectedItem (pos);
    > GetItem(pitem)
    > SHGetPathFromIDList((LPITEMIDLIST)pitem->lParam, psSourcePath);
    >
    >
    > For any of Shell Name ext , the lParam is coming 0




+ Reply to Thread