Class_LVColors, Does this have a fix? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Smile_
Posts: 858
Joined: 03 May 2020, 00:51

Class_LVColors, Does this have a fix?

Post by Smile_ » 27 Jan 2022, 14:06

@just me

Lib used [Class] LV_Colors - 1.1.04.01 (2016-05-03)

This is a list view control:
Bugged.png
Bugged
Bugged.png (16.03 KiB) Viewed 506 times

But there is something you may already noticed, the content is not clear at all, like it is bugged, it is supposed to be like this:
Normal.png
Normal
Normal.png (20.75 KiB) Viewed 506 times

I get it when I use this class and scroll the list view at certain speed using page up or down buttons, same goes for scrolling using the mouse or up and down arrows.

This list view view is fixed when I minimize and restore the window, so I suppose it is something with refreshing.
I use Windows 7 - 64 bits operating system.
Do you have any clue for what it can be the cause?

Edit: Used code

Code: Select all

#Include, Class_LVColors.ahk

Gui, Add, ListView, w800 h400 HwndThisLV Grid, Col1|Col2|Col3
LV_ModifyCol(1, "300 Center"), LV_ModifyCol(2, "200 Center"), LV_ModifyCol(3, "300 Center")

CLV := New LV_Colors(ThisLV)
CLV.SelectionColors(0x00FF00)

Loop, 1000 {
    LV_Add(, A_Index, A_Index, A_Index)
}

Gui, Show,, List View Color Test
Return

GuiClose:
ExitApp
Thanks for your attentions!

User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: Class_LVColors, Does this have a fix?  Topic is solved

Post by jNizM » 28 Jan 2022, 03:34

See discuss from here: https://www.autohotkey.com/boards/viewtopic.php?p=431950#p431950
and here: https://www.autohotkey.com/boards/viewtopic.php?p=37484#p37484


With this I had (at least in v1) less (not null) problems with coloring a large table

Code: Select all

class ListView
{
	static list := []

	__New(handle)
	{
		this.list[handle] := this
		OnMessage(0x004e, "WM_NOTIFY")
		this.handle := handle
		this.control := []
	}

	Add(options, items*)
	{
		Gui, ListView, % this.handle
		for a, b in items
		{
			if (A_Index = 1)
				item := LV_Add(options, b)
			else
				LV_Modify(item, "col" A_Index, b)
		}
	}

	Clear()
	{
		this.control := []
	}

	Color(item, fore := "", back := "")
	{
		LV_GetText(text, item)
		if (fore != "")
			this.Control[text, "fore"] := fore
		if (back != "")
			this.Control[text, "back"] := back
	}
}

WM_NOTIFY(param*)
{
	static NM_FIRST            := 0
	static NM_CUSTOMDRAW       := (NM_FIRST - 12)
	static CDRF_NOTIFYITEMDRAW := 0x00000020
	static CDDS_ITEM           := 0x00010000
	static CDDS_PREPAINT       := 0x00000001
	static CDDS_ITEMPREPAINT   := (CDDS_ITEM | CDDS_PREPAINT)

	critical
	control := ""
	if (this := ListView.list[NumGet(param[2])]) && (NumGet(param[2], 2 * A_PtrSize, "int") = NM_CUSTOMDRAW)
	{
		stage := NumGet(param[2], 3 * A_PtrSize, "uint")
		if (stage = CDDS_PREPAINT)
			return CDRF_NOTIFYITEMDRAW
		if (stage = CDDS_ITEMPREPAINT)
		{ 
			index := NumGet(param[2], (A_PtrSize = 4) ? (9 * A_PtrSize) : (7 * A_PtrSize), "uint")
			LV_GetText(text, index + 1)
			info := this.Control[text]
			if (info.fore != "")
				NumPut(info.fore, param[2], (A_PtrSize = 4) ? (12 * A_PtrSize) : (10 * A_PtrSize), "int")
			if (info.back != "")
				NumPut(info.back, param[2], (A_PtrSize = 4) ? (13 * A_PtrSize) : (10.5 * A_PtrSize), "int")
		}
	}
}

Code: Select all

; load class
LV := new ListView(hLV)

; clear colors
LV.Clear()

; color something
LV.Color(A_Index,, 0xD2CDFF)
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile

User avatar
Smile_
Posts: 858
Joined: 03 May 2020, 00:51

Re: Class_LVColors, Does this have a fix?

Post by Smile_ » 28 Jan 2022, 04:46

Well well @jNizM, that is pretty much what I'm looking for, and I want you to understand that the next is not so necessary.
You see here I'm limited to colorize a one row per time using this class you just shared, so do you think is it possible to make that change (WM_NOTIFY(param*)) to [Class] LV_Colors - 1.1.04.01 (2016-05-03), I'm not trying to do anything illegal, @just me can decide that.

Or as alternative, would be great to add selection and one cell coloring, that is all what I'm looking right now.

And thanks for your help, much appreciated, that helps me a lot you know!

User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: Class_LVColors, Does this have a fix?

Post by jNizM » 28 Jan 2022, 05:11

Do you want to just color the selected row? Than try this: https://www.autohotkey.com/boards/viewtopic.php?t=17331

Edit: after reading the comments. the problem still exist with this function too.
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile

User avatar
Smile_
Posts: 858
Joined: 03 May 2020, 00:51

Re: Class_LVColors, Does this have a fix?

Post by Smile_ » 28 Jan 2022, 05:32

Yeah, that is enough for me right now, but you know the issue still persists, I accept your first answer.
There is a little hitch left, however it doesn't bother me, when I used LV_SetSelColors() - user-defined selection colors for ListViews with your suggestion, the content made blank if I use PageUp or PageDn, I don't think someone will do scrolling in that speed, so it is fine.

Thank you @jNizM, Have a good day.

Edit :D :D :D :
I wrote my answer before I see your edit.

Post Reply

Return to “Ask for Help (v1)”