Class LV_Colors v2.0 - 2023-05-06

Post your working scripts, libraries and tools.
fenchai
Posts: 292
Joined: 28 Mar 2016, 07:57

Re: Class LV_Colors v2.0 - 2023-01-04

13 Mar 2023, 06:50

just me wrote:
13 Mar 2023, 03:41
Currently you might need to call BgCLV.UpdateProps() after you changed the LVs contents.
I added BgCLV.UpdateProps() before and after main.Show() but it still does not change any color. Am I out of luck?
fenchai
Posts: 292
Joined: 28 Mar 2016, 07:57

Re: Class LV_Colors v2.0 - 2023-01-04

13 Mar 2023, 17:06

I found a solution, I removed .ShowColors(), used updateProps() then apply the .row() coloring before showing the GUI. the steps position matters.
just me
Posts: 9466
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Class LV_Colors v2.0 - 2023-01-04

15 Mar 2023, 06:24

@fenchai,

you created the LV_Colors object with an empty ListView, so the internal RowCount property was set to 0. That's why BgCLV.Row(1, 0x00FF00, 0x000080) failed. With the current version of the class you need to call UpdateProps() after adding rows to the ListView before you can access newly added rows.
fenchai
Posts: 292
Joined: 28 Mar 2016, 07:57

Re: Class LV_Colors v2.0 - 2023-01-04

15 Mar 2023, 07:23

thanks for letting me know!
iPhilip
Posts: 822
Joined: 02 Oct 2013, 12:21

Re: Class LV_Colors v2.0 - 2023-01-04

04 May 2023, 02:46

just me wrote:
19 Aug 2021, 08:41

Code: Select all

      Return (HTML.HasOwnProp(Color) ? HTML[Color] : Default)
I think the above line in the original post should be:

Code: Select all

      Return (HTML.HasOwnProp(Color) ? HTML.%Color% : Default)
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)
just me
Posts: 9466
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Class LV_Colors v2.0 - 2023-05-06

06 May 2023, 05:44

@iPhilip, of course, i fixed it, thanks.
iPhilip
Posts: 822
Joined: 02 Oct 2013, 12:21

Re: Class LV_Colors v2.0 - 2023-05-06

10 Jul 2023, 12:24

I used this class to study the GetSysColor function. What I learned is that the GetSysColor function returns values in BGR format, not RGB as specified in the documentation page.
In contrast, registry entries under Computer\HKEY_CURRENT_USER\Control Panel\Colors or Computer\HKEY_CURRENT_USER\Control Panel\Desktop\Colors are in the form of R G B values between 0 and 255.

Here's the script:

Code: Select all

#Requires AutoHotkey v2.0.1
#Include Class_LV_Colors.ahk

DisplayElements := ['COLOR_SCROLLBAR'
                  , 'COLOR_DESKTOP'
                  , 'COLOR_ACTIVECAPTION'
                  , 'COLOR_INACTIVECAPTION'
                  , 'COLOR_MENU'
                  , 'COLOR_WINDOW'
                  , 'COLOR_WINDOWFRAME'
                  , 'COLOR_MENUTEXT'
                  , 'COLOR_WINDOWTEXT'
                  , 'COLOR_CAPTIONTEXT'
                  , 'COLOR_ACTIVEBORDER'
                  , 'COLOR_INACTIVEBORDER'
                  , 'COLOR_APPWORKSPACE'
                  , 'COLOR_HIGHLIGHT'
                  , 'COLOR_HIGHLIGHTTEXT'
                  , 'COLOR_3DFACE'
                  , 'COLOR_3DSHADOW'
                  , 'COLOR_GRAYTEXT'
                  , 'COLOR_BTNTEXT'
                  , 'COLOR_INACTIVECAPTIONTEXT'
                  , 'COLOR_3DHILIGHT'
                  , 'COLOR_3DDKSHADOW'
                  , 'COLOR_3DLIGHT'
                  , 'COLOR_INFOTEXT'
                  , 'COLOR_INFOBK'
                  , 'N/A'
                  , 'COLOR_HOTLIGHT'
                  , 'COLOR_GRADIENTACTIVECAPTION'
                  , 'COLOR_GRADIENTINACTIVECAPTION'
                  , 'COLOR_MENUHILIGHT'
                  , 'COLOR_MENUBAR']

MyGui := Gui('-DPIScale', 'GetSysColor Test')
MyGui.MarginX := MyGui.MarginY := 0
MyGui.SetFont('s11', 'Consolas')
LV := MyGui.Add('ListView', 'w525 R31 Grid', StrSplit('No.|R|G|B|BGR|Color|Display Element', '|'))
CLV := LV_Colors(LV)
for Element in DisplayElements {
   BGR := DllCall('GetSysColor', 'Int', A_Index - 1, 'UInt')
   R := BGR & 0xFF, G := (BGR & 0xFF00) >> 8, B := BGR >> 16
   LV.Add( , A_Index - 1, R, G, B, Format('0x{:06X}', BGR), , Element)
   CLV.UpdateProps()
   CLV.Cell(A_Index, 6, (R << 16) | (G << 8) | B)
}
LV.ModifyCol(1, 'AutoHdr Integer Center')
LV.ModifyCol(2, 'Auto Integer Center')
LV.ModifyCol(3, 'Auto Integer Center')
LV.ModifyCol(4, 'Auto Integer Center')
LV.ModifyCol(5, 'Auto Center')
LV.Move( , , 600)
MyGui.Show()

Here is an image of the resulting Gui:

GetSysColor Results.png
GetSysColor Results.png (64.2 KiB) Viewed 2058 times
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)
Spitzi
Posts: 313
Joined: 24 Feb 2022, 03:45

Re: Class LV_Colors v2.0 - 2023-05-06

22 Aug 2023, 08:11

Hi @just me. Always a pleasure to use your classes!! Thanks.

Just a note: when deleting all rows from a listview and then repopulating the rows using LV.Add, I had to call UpdateProps() before Row(), for colors to show in the listview. Is that an intended/explainable behaviour?

One more wish: could you publish your LV_Colors_V2 Class under a license on github?

And: do you have a "buy me a coffee" account?

Greets Spitzi
just me
Posts: 9466
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Class LV_Colors v2.0 - 2023-05-06

22 Aug 2023, 10:14

Spitzi wrote: Just a note: when deleting all rows from a listview and then repopulating the rows using LV.Add, I had to call UpdateProps() before Row(), for colors to show in the listview. Is that an intended/explainable behaviour?
It depends on how you delete the rows from the listview. Do you call the Clear() method? Does the number of newly added rows exceed the previous number of rows?
Spitzi
Posts: 313
Joined: 24 Feb 2022, 03:45

Re: Class LV_Colors v2.0 - 2023-05-06

23 Aug 2023, 02:49

Hi @just me. I currently use LV.Delete. The number of added rows is the same as the previously deleted.
just me
Posts: 9466
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Class LV_Colors v2.0 - 2023-05-06

23 Aug 2023, 03:15

I cannot reproduce it here. Please show the relevant code.
theyakutoo
Posts: 14
Joined: 09 Sep 2023, 11:15

Re: Class LV_Colors v2.0 - 2023-05-06

02 Oct 2023, 11:23

How do you change the header colors?
just me
Posts: 9466
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Class LV_Colors v2.0 - 2023-05-06

03 Oct 2023, 05:23

The header control is a separate control within the list-view area. It sends own NM_CUSTOMDRAW notifications which can be intercepted to change the colors.
denis_q2
Posts: 4
Joined: 24 May 2023, 11:36

Re: Class LV_Colors v2.0 - 2023-05-06

27 Nov 2023, 03:45

It seems that 'NoSort' is ignored by LV.Opt().

AHK v2.0.10
just me
Posts: 9466
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Class LV_Colors v2.0 - 2023-05-06

27 Nov 2023, 04:32

'NoSort' is an AHK specific option and must be handled by the script. Seems to be a bug!
Spitzi
Posts: 313
Joined: 24 Feb 2022, 03:45

Re: Class LV_Colors v2.0 - 2023-05-06

29 Jan 2024, 11:27

Hello @just me.

I want to declare all my external libraries/classes in my script. I am also (very frequently) using your LV_Colors_V2 class, which is great, thank you again for that. Would it be possible for you to put the code for V2 on github, too, so I could link to it?? I don't want to link to a autohokey-forum-thread (feels a little to DIY, if you know what I mean)

Thanks for considering... Spitzi
just me
Posts: 9466
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Class LV_Colors v2.0 - 2023-05-06

29 Jan 2024, 11:56

Hi @Spitzi, :arrow: AHK2_LV_Colors.
Spitzi
Posts: 313
Joined: 24 Feb 2022, 03:45

Re: Class LV_Colors v2.0 - 2023-05-06

29 Jan 2024, 15:32

Hi @just me Thank you! There is one ore piece of code of yours that I use, from viewtopic.php?f=83&t=94046, LVICE_XXS. Would you be willing to put it in a repository on github as well?

And a side note: can your RichTextEdit control be used to display javascript code with syntax highlighting?

Thanks for your help and greets Spitzi
just me
Posts: 9466
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Class LV_Colors v2.0 - 2023-05-06

31 Jan 2024, 09:35

Spitzi wrote: There is one ore piece of code of yours that I use, from viewtopic.php?f=83&t=94046, LVICE_XXS. Would you be willing to put it in a repository on github as well?
I will do it till weekend.
Spitzi wrote: And a side note: can your RichTextEdit control be used to display javascript code with syntax highlighting?
It is theoretically feasible. But I don't know any existing solution. Most probably you'll have to do the whole stuff on your own
User avatar
kczx3
Posts: 1643
Joined: 06 Oct 2015, 21:39

Re: Class LV_Colors v2.0 - 2023-05-06

31 Jan 2024, 22:22

You could probably use viewtopic.php?t=35119 at least as a starting point.

Return to “Scripts and Functions (v2)”

Who is online

Users browsing this forum: No registered users and 54 guests