Is there a way of disabling certain elements in a listview(report style)?
For instance:
If the list has 6 items, i want to disable no. 2 & 4
Is there a way of disabling certain elements in a listview(report style)?
For instance:
If the list has 6 items, i want to disable no. 2 & 4
In WIN32
The LV will send msg's to its parents callback (the hwndparent param in the CreateWindow() call)
The LV will send WM_NOTIFY msg's
test the control ID in the wparam to ensure is right control
in MFCCode:NM_LISTVIEW *LView; LView = (NM_LISTVIEW FAR *) lParam; //the row clicked is LView->iItem, process
add a LVN_ITEMCHANGING handler and do the same
In both cases
return FALSE to cancel the change
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill
Thanks.
Is there any way i can gray it, and prevent it from receiving focus?
AFAIK you can only disable the whole LV.
You could use the OWNERDRAW style and colour the background grey for the disable ones AND ignore any clicks on them.
I would set the LPARAM to a code for the colour.
Set the LV style to LVS_OWNERDRAWFIXED
MFC
add a handler for the OnDrawItem msg.
WIN32
handle the WM_DRAWITEM msg in the parents callback
in both cases something like
pDrawItem = (DRAWITEMSTRUCT *)lParam;
Then in the handler
Check lParam code (I would use an index to a COLORREF array)
select and create correct colour brush (using my array element with the items lParam as the index)
The DRAWITEM contains the info including a RECT and HDC, use FillRect()
Kill Brush
Draw text for item
or
create a loop for each col
Use SetTextColor() if needed
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill