A problem of uncheck all checkboxes of a listview Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
songdg
Posts: 609
Joined: 04 Oct 2017, 20:04

A problem of uncheck all checkboxes of a listview

11 May 2024, 02:52

I want to uncheck all checkboxes of a listview by doubleclick on the text Uncheck_All, but get this error
Error: This value of type "Gui.Text" has no method named "Modify".

011: g.OnEvent("Close", (*) => ExitApp())
014: {
▶ 015: LV.Modify(0, "-Check")
016: }
020: {

Code: Select all

#Requires AutoHotkey v2.0
g := Gui("+AlwaysOnTop")
g.Add("Text", "VUncheck cRed", "Uncheck_All").OnEvent('doubleclick', Uncheck_All)
LV := g.AddListView("w400 r12 -readonly checked", ["name","items"])
loop 12
	LV.Add(, "Name " A_Index,"Item " A_Index * 10)
LV.modifycol(1, 190)
LV.modifycol(2, 190)
LV.OnEvent("doubleclick", LVClick)
g.Show()
g.OnEvent("Close", (*) => ExitApp())

Uncheck_All(LV, Item,*)
{
  LV.Modify(0, "-Check")  ; Uncheck all the checkboxes.
}

LVClick(LV, Item,*)
{
  {
  ItemState := SendMessage(0x102C, item - 1, 0xF000, LV)
  if !((ItemState >> 12) - 1)
      LV.Modify(item,	"Check")
  else
      LV.Modify(item,	"-Check")
  }
}
vmech
Posts: 361
Joined: 25 Aug 2019, 13:03

Re: A problem of uncheck all checkboxes of a listview

11 May 2024, 03:13

@songdg
Because Uncheck_All callback take Text Gui Control object in named LV parameter. Not ListView Gui Control object.
Try:

Code: Select all

Uncheck_All(*)
{
  global LV
  LV.Modify(0, "-Check")  ; Uncheck all the checkboxes.
}
Spoiler
Please post your script code inside [code] ... [/code] block. Thank you.
XMCQCX
Posts: 251
Joined: 14 Oct 2020, 23:44

Re: A problem of uncheck all checkboxes of a listview  Topic is solved

11 May 2024, 04:37

As stated by @vmech, the LV parameter represents the text Gui Control object, not the ListView Gui Control object. I highly recommend using VSCode alongside the Debugger extension. By hovering over variables, you can examine both their type and content. You will save a ton of time.
Image

Code: Select all

#Requires AutoHotkey v2.0
#SingleInstance

g := Gui('+AlwaysOnTop')
g.OnEvent('Close', (*) => ExitApp())
g.Add('Text',, 'Check all').OnEvent('DoubleClick', (*) => g.lv.Modify(0, '+Check'))
g.Add('Text', 'x+m', 'Uncheck all').OnEvent('DoubleClick', (*) => g.lv.Modify(0, '-Check'))
g.Add('Text', 'x+m', 'Select all').OnEvent('DoubleClick', (*) => g.lv.Modify(0, '+Select'))
g.Add('Text', 'x+m', 'Deselect all').OnEvent('DoubleClick', (*) => g.lv.Modify(0, '-Select'))
g.lv := g.AddListView('xm w400 r12 -readonly checked', ['name','items'])

loop 12
    g.lv.Add(, 'Name ' A_Index,'Item ' A_Index * 10)

Loop 2
    g.lv.modifycol(A_Index, 190)

g.Show()
songdg
Posts: 609
Joined: 04 Oct 2017, 20:04

Re: A problem of uncheck all checkboxes of a listview

12 May 2024, 11:41

vmech wrote:
11 May 2024, 03:13
@songdg
Because Uncheck_All callback take Text Gui Control object in named LV parameter. Not ListView Gui Control object.
Try:

Code: Select all

Uncheck_All(*)
{
  global LV
  LV.Modify(0, "-Check")  ; Uncheck all the checkboxes.
}
Spoiler
Thank you very much :clap:
songdg
Posts: 609
Joined: 04 Oct 2017, 20:04

Re: A problem of uncheck all checkboxes of a listview

12 May 2024, 11:43

XMCQCX wrote:
11 May 2024, 04:37
As stated by @vmech, the LV parameter represents the text Gui Control object, not the ListView Gui Control object. I highly recommend using VSCode alongside the Debugger extension. By hovering over variables, you can examine both their type and content. You will save a ton of time.
Image

Code: Select all

#Requires AutoHotkey v2.0
#SingleInstance

g := Gui('+AlwaysOnTop')
g.OnEvent('Close', (*) => ExitApp())
g.Add('Text',, 'Check all').OnEvent('DoubleClick', (*) => g.lv.Modify(0, '+Check'))
g.Add('Text', 'x+m', 'Uncheck all').OnEvent('DoubleClick', (*) => g.lv.Modify(0, '-Check'))
g.Add('Text', 'x+m', 'Select all').OnEvent('DoubleClick', (*) => g.lv.Modify(0, '+Select'))
g.Add('Text', 'x+m', 'Deselect all').OnEvent('DoubleClick', (*) => g.lv.Modify(0, '-Select'))
g.lv := g.AddListView('xm w400 r12 -readonly checked', ['name','items'])

loop 12
    g.lv.Add(, 'Name ' A_Index,'Item ' A_Index * 10)

Loop 2
    g.lv.modifycol(A_Index, 190)

g.Show()
Thanks for the help and recommendation :dance:

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: Bing [Bot], WarlordAkamu67 and 28 guests