Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 989917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:52:02+00:00 2026-05-16T05:52:02+00:00

I was thinking i could use the LVITEM structures LPARAM to attach a pointer

  • 0

I was thinking i could use the LVITEM structures LPARAM to attach a pointer to my class, but i can’t seem to get it to work!

Heres the main parts of my code:

Creating the listview:

hlvQuiz = CreateChild(WC_LISTVIEW, "",
    WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | LVS_ICON | LVS_AUTOARRANGE,
    0, 0, 320, 240, m_hwnd, FontNormal);

Adding items:

if (vQuizes.size() > 0)
{
    LVITEM lvi;
    lvi.mask = LVIF_TEXT | LVIF_PARAM;
    lvi.iItem = 0;
    lvi.iSubItem = 0;
    lvi.cchTextMax = QUIZSTRLEN;

    for (unsigned int i = 0; i < vQuizes.size(); i++)
    {
        lvi.lParam = (LPARAM)&vQuizes[i]; // adding pointer to lparam
        lvi.pszText = vQuizes[i].szName;
        ListView_InsertItem(hlvQuiz, &lvi);
    }
}

Then later when i go to get my class back from the LPARAM:

        LVITEM lvi;
    lvi.iItem = ListView_GetNextItem(hwnd, -1, LVNI_SELECTED);
    lvi.iSubItem = 0;

    if (ListView_GetItem(fm->hlvQuiz, &lvi) == TRUE)
    {
        Quiz* q = (Quiz*)lvi.lParam;
        if (q != NULL) // i get stopped here because my pointer is NULL
            if (Exists(q->szPath) == IS_FILE)
                ShellExecute(NULL, "edit", q->szPath, NULL, NULL, SW_SHOWNORMAL);
    }

Is there anything that i’m doing wrong? the listview creates fine, and the items add, but the pointer to my class which i put in the LPARAM value seems to be ignored, or changed by the time i come to dereference it

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T05:52:03+00:00Added an answer on May 16, 2026 at 5:52 am

    I haven’t worked at this low level before, but I suspect you need to set the mask member of the LVITEM structure to LVIF_PARAM (as well as the appropriate values for anything else you need) for the call to ListView_GetItem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been thinking hard for a long time but couldn't work this out. Consider
I wonder if you could help me with something I've been thinking about. Say
Could mapreduce be used to implement a webserver? I'm thinking something like when a
Could somebody explain to me the architecture behind chatroulette? I was thinking about a
Thinking that the answer to this is pretty obvious but here it goes: When
Im thinking about to use a DB for my logs instead of a normal
How could I write javascript that iterates through a table, grabs the class, and
You're probably thinking this has been asked a million times before but I think
How would you check if a file is an image? I'm thinking you could
I have no code done yet but I'm thinking on how I'm supposed to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.