Home > front end >  Virtual list (Problems with parameter/pointer)
Virtual list (Problems with parameter/pointer)

Time:11-26

I am trying to convert my CListCtrl into a virtual list, but i dont know which parameter i have to use

    // --- Virtual List ---
void CSpielebibliothekGUIDlg::OnGetdispinfoList(NMHDR* pNMHDR, LRESULT* pResult) // --- nullptr muss weg --- 
{
    LPNMITEMACTIVATE pNMIA = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);

    LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;

    LV_ITEM* pItem = &(pDispInfo)->item;

    int itemid = pItem->iItem;

    if (pItem->mask & LVIF_TEXT)
    {
        CString text;
        // --- Welche Spalte ---
        if (pItem->iSubItem == 0)
        {
            // --- Name ---
            text = Spiele[itemid].m_Name;
        }
        if (pItem->iSubItem == 1)
        {
            //Text is slogan
            text = Spiele[itemid].m_Plattform;
        }
        if (pItem->iSubItem == 2)
        {
            text = Spiele[itemid].m_Genre;
        }
        if (pItem->iSubItem == 3)
        {
            CString Release;
            Release.Format(_T("%d"), Spiele[itemid].m_Erscheinungsjahr);
            text = Release;
        }
        if (pItem->iSubItem == 4)
        {
            CString Preis;
            Preis.Format(_T("%g"), Spiele[itemid].m_Preis);
            text = Preis;
        }
        if (pItem->iSubItem == 5)
        {
            CString EAN;
            EAN.Format(_T("%d"), Spiele[itemid].m_EAN);
            text = EAN;
        }
        if (pItem->iSubItem == 6)
        {
            text = Spiele[itemid].Verwandschaft;
        }

        lstrcpyn(pItem->pszText, text, pItem->cchTextMax);
    }

    *pResult = 0;
}

this is my function call


    OnGetdispinfoList(nullptr, nullptr);

of course the nullptr are not right, iam glad for any help.

CodePudding user response:

You don't need to call message handlers, they will be called by system after you:

  • Set proper window styles (LVS_OWNERDATA)
  • Set item count
  • Add your OnGetdispinfoList to the message map
  • Related