Discussions related to Visual Prolog
dominique f pannier
Active Member
Posts: 38
Joined: 23 Sep 2002 23:01

Listviewcontrol item backgroundcolor

Unread post by dominique f pannier »

I'd like to modify the background color of selected items of a listviewcontrol.
Unfortunatly, it is trickier than for a treecontrol object : in that last one, nodes are objects with color properties, in a listviewcontrol object, items are not.
I saw that there was another way to modify the fore and back colors of a treecontrol, by using a notification filtered in the predicate dispatchWmNotify with the message nm_customdraw. The associated LParam converted in a nmTvCustomDraw domain allows to know the actual values of this compound structure, in which are defined the actual TextColor and BackColor variables, and to replace it in the memory by another one with the new wished colors.

It seemed to me that it should de possible to use the same strategy in a listviewcontrol object, which is also a control on the one hand, and which has in VIP 7.4 a structure nmLvCustomDraw parallel to the nmTvCustomDraw in a treeControl object on the other hand.
I added in the listviewvontrol.pro :

Code: Select all

clauses     dispatchWmNotify(nm_customdraw, LParam) = onCustomDraw(uncheckedConvert(nmLvCustomDraw, LParam)) :-         !.     dispatchWmNotify(_, _LParam) = window::defaultNativeHandling().   predicates     onCustomDraw : (nmLvCustomDraw NmLvCustomDraw) -> nativeResponse Result. clauses     onCustomDraw(NmLvCustomDraw) = window::nativeResult(cdrf_notifyitemdraw) :- % We want item draw notification         nmLvCustomDraw(NmCustomDraw, _TextForegroundColor, _TextBackgroundColor, _TreeLevel) = NmLvCustomDraw,         nmCustomDraw(_NmHdr, DrawStage, _HDC, _RC, _ItemH, _TreeItemState, LParam) = NmCustomDraw,         cdds_prepaint = DrawStage,         stdio::writef("LVC - LParam = %\n", LParam), % Control is about to be drawn         !.
but it does not run.
In the treecontrol.pro, I can edit the LParam values, in the listviewcontrol.pro, nothing.

1. Is it a bad strategy ? Or does it has to be complemented ?
2. Is there another way (may be simpler) for modifying the background of a listviewcontrol item ? I also saw an interleaved predicate in the listviewcontrol class, which is a customDraw, but I don't know how to use it.
Dominique Pannier
Post Reply