According to https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-nmlistview lParam is of Type: LPARAM and is a Application-defined value of the item. This member is undefined for notification messages that do not use it.
It does not say how an application can set its user defined lParam value.
You would have thought that as this is a specific Windows message, it would specify if it is a notification messages that do not use it.
So how does the lParam parameter within NMLISTVIEW get set?
Or is it always undefined?
you do not SET the lParam at all, you need to GET it if you process such a notification message. The system sets it.