[Class] LV_Colors - 1.1.05.00 (2024-03-16)

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
JoeWinograd
Posts: 2182
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: [Class] LV_Colors - 1.1.04.01 (2016-05-03)

Post by JoeWinograd » 25 Apr 2021, 10:57

Hi just me,

As you know, I've been using your LV_Colors class with great success for many years in an output-only LV that I call the "Processing Console"...thanks again for this terrific class!

I'm now trying to use it in an LV on the input side, where the user selects a color (or multiple colors) from a list with a large number of choices (will probably wind up in the 20-30 range). When clicking the checkbox, it looks fine. The issue I'm having is that when clicking the row, the text color changes to white and the background color changes to a shade of blue (0x0078D7). This happens regardless of the text color and background color that had been set (it also happens if the LV does not have a checkbox). Here's a simple example with three rows (yellow on red, black on green, pink on blue):

Code: Select all

#SingleInstance Force
Gui,Font,s12,Arial
Gui,Add,ListView,Checked xm r5 hwndSelectColorHandle,ColorLV
SelectColor:=New LV_Colors(SelectColorHandle,True,True,True)

ColorBack:="0xFF0000" ; Red
ColorText:="0xFFFF00" ; Yellow
RowNum:=LV_Add("","Red")
SelectColor.Row(RowNum,ColorBack,ColorText)

ColorBack:="0x00FF00" ; Green
ColorText:="0x000000" ; Black
RowNum:=LV_Add("","Green")
SelectColor.Row(RowNum,ColorBack,ColorText)

ColorBack:="0x0000FF" ; Blue
ColorText:="0xFFC0CB" ; Pink
RowNum:=LV_Add("","Blue")
SelectColor.Row(RowNum,ColorBack,ColorText)

Gui,Show
Return

GuiClose:
GuiEsc:
ExitApp

#Include Class_LV_Colors.ahk
Clicking on any row (not the checkbox) turns the colors into white on 0x0078D7. Then clicking on another row or at the empty space under the rows brings back the correct colors. Screenshots:

before clicking row.png
before clicking row.png (5.88 KiB) Viewed 1825 times
after clicking red.png
after clicking red.png (6 KiB) Viewed 1825 times

I've tried with StaticMode both True and False...same behavior. Is there any way to keep this from happening? Thanks much, Joe

Edit: Possible work-around that I'm considering: Use AltSubmit when adding the LV and at the g-label look for A_GuiEvent="Normal" then do something like this:

Code: Select all

RowNum:=A_EventInfo
If (RowNum=0)
  Return
LV_GetText(RowColor,RowNum)
NextChecked:=LV_GetNext(RowNum-1,"Checked")
If (RowNum=NextChecked)
  CheckStatus:="Check"
Else
  CheckStatus:="-Check"
LV_Delete(RowNum)
RowNum:=LV_Insert(RowNum,,RowColor)
LV_Modify(RowNum,CheckStatus)
That seems to solve the color problem. Regards, Joe

just me
Posts: 9425
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [Class] LV_Colors - 1.1.04.01 (2016-05-03)

Post by just me » 26 Apr 2021, 05:13

Should be enough to remove the Select (and Focus) state.

User avatar
JoeWinograd
Posts: 2182
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: [Class] LV_Colors - 1.1.04.01 (2016-05-03)

Post by JoeWinograd » 27 Apr 2021, 01:24

just me wrote:
26 Apr 2021, 05:13
Should be enough to remove the Select (and Focus) state.
Works a charm! Thanks very much! Regards, Joe

Edit#1: Subsequent testing shows that it is enough to remove only Select. Thanks again!

Edit#2: Yet more testing shows that both need to be removed.

Chappier
Posts: 44
Joined: 21 Aug 2021, 21:58

Re: [Class] LV_Colors - 1.1.04.01 (2016-05-03)

Post by Chappier » 01 Jun 2022, 07:52

just me, is possible to change the background color of the entire ListView?
I mean, when there are no rows yet, the background is fully white, possible to change it to another color?

Also, when i add the class to the listview, i cant resize it anymore, by resize i mean this:
image.png
image.png (1.22 KiB) Viewed 1575 times
Is this a 'bug' or a desired behavior?

list
Posts: 221
Joined: 26 Mar 2014, 14:03
Contact:

Re: [Class] LV_Colors - 1.1.04.01 (2016-05-03)

Post by list » 03 Jun 2022, 16:52

@Chappier
1. You can just use the standard c and Background col options of a listview - https://www.autohotkey.com/docs/commands/ListView.htm#Options
2. By default the NoSizing is set to True, so change it to False (same goes for NoSort) - https://github.com/AHK-just-me/Class_LV_Colors/blob/master/Sources/Class_LV_Colors.ahk#L53

MetalHotkey5000
Posts: 2
Joined: 24 Feb 2023, 13:47

Re: [Class] LV_Colors - 1.1.04.01 (2016-05-03)

Post by MetalHotkey5000 » 24 Feb 2023, 13:59

Hello,

Has anyone been able to set colors for both even and odd rows/columns? I can't figure out what is making the class only do even rows/columns.

list
Posts: 221
Joined: 26 Mar 2014, 14:03
Contact:

Re: [Class] LV_Colors - 1.1.04.01 (2016-05-03)

Post by list » 25 Feb 2023, 11:22

Use AlternateRows(), you can omit the text colour if you wish.

BenRen
Posts: 19
Joined: 19 Sep 2015, 02:38

Re: [Class] LV_Colors - 1.1.04.01 (2016-05-03)

Post by BenRen » 19 Mar 2023, 01:57

Is it possible to use LV_Colors with Autohotkey 2.0.2?

Rahl
Posts: 6
Joined: 08 Mar 2021, 19:35

Re: [Class] LV_Colors - 1.1.04.01 (2016-05-03)

Post by Rahl » 05 Jun 2023, 11:46

Nice script; However, for some reson it does freeze my own script at some loop points!
No matter what I do, I can not finger the bug..

User avatar
JoeWinograd
Posts: 2182
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: [Class] LV_Colors - 1.1.04.01 (2016-05-03)

Post by JoeWinograd » 05 Jun 2023, 12:35

Rahl wrote:for some reason it does freeze my own script
Well, it could be a problem with LV_Colors, but it could be a problem with your script. For us to really help you, you'll have to post your script, or, if it's a large script, reproduce the problem in a small/test script and post that.

In the meantime, here's an idea for you. I wrote a script a few years back where my script with LV_Colors was freezing. just me helped me fix it with these suggestions:

(1) I was doing a GuiControl,+Redraw,%ConsoleHandle%. He said to remove it.

(2) I was doing LV_Modify(RowNumber,"Vis") BEFORE ColorConsole.Row(RowNumber,ColorBackground,ColorText). He said to reverse the order.

After making those two changes, my script no longer froze. Of course, your issue could be completely different. Regards, Joe

just me
Posts: 9425
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [Class] LV_Colors - 1.1.05.00 (2024-03-16)

Post by just me » 16 Mar 2024, 05:58

With his last update for AHK 1.1 @lexikos ported a change from v2 which prevents scripts like Class_LV_Colors.ahk from freezing. Many thanks for this change.
Now this is my last update to Class_LV_Colors.ahk. Version 1.1.05.00 is available on GitHub.

User avatar
KruschenZ
Posts: 44
Joined: 20 Jan 2021, 07:05
Location: Germany (Rheinhessen)
Contact:

Re: [Class] LV_Colors - 1.1.05.00 (2024-03-16)

Post by KruschenZ » 16 Mar 2024, 13:51

I m so happy, that he merged my pull request.
https://github.com/AutoHotkey/AutoHotkey/commit/dd9911bb5fe2b8189f9240265c00842df43858b3
Because, I used my branch a long time for that bug.

Post Reply

Return to “Scripts and Functions (v1)”