LV_Add do not add item when using GuiName inside subcommands

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
calvey
Posts: 2
Joined: 23 Oct 2021, 09:42

LV_Add do not add item when using GuiName inside subcommands

Post by calvey » 23 Oct 2021, 09:51

[Moderator's note: Topic moved from Bug Reports.]

Hello guys,

I found that I cannot use both GuiName: inside Gui subcommands and LV_Add function at the same time.

Here is the code to reproduce:

Code: Select all

#SingleInstance, Force
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input
SetWorkingDir, %A_ScriptDir%

Gui, testWin:Add, ListView, vMyListView AltSubmit -ReadOnly R10 w310, Column 1|Column 2|Column 3
Gui, testWin:Show,, Test LV_Add

; Create entries inside ListView
Gui, testWin:ListView, MyListView
Loop, 10 {
    LV_Add("", "Column-1 | Row-" A_Index ,  "Column-2 | Row-" A_Index,  "Column-3 | Row-" A_Index)
}
LV_ModifyCol()  ; Auto-size each column to fit its contents.


GuiClose(hWnd) {
    ExitApp
}
If I remove GuiName's part (testWin: in my example), it works as it should. I need to use GuiName as I have a project with many GUIs and I want to identify them in my code.

Please help.
Thank you.

garry
Posts: 3740
Joined: 22 Dec 2013, 12:50

Re: LV_Add do not add item when using GuiName inside subcommands

Post by garry » 23 Oct 2021, 10:10

add

Code: Select all

Gui, testWin: default

garry
Posts: 3740
Joined: 22 Dec 2013, 12:50

Re: LV_Add do not add item when using GuiName inside subcommands

Post by garry » 23 Oct 2021, 10:21

this example works also :

Code: Select all

#SingleInstance, Force
#NoEnv  ;- Recommended for performance and compatibility with future AutoHotkey releases.
#Warn   ;- Enable warnings to assist with detecting common errors.
SendMode Input
SetWorkingDir, %A_ScriptDir%
;Gui, testWin: default
Gui, testWin:Add, ListView,gA1 vMyListView AltSubmit -ReadOnly R10 w310, Column 1|Column 2|Column 3
Gui, testWin:Show,, Test LV_Add
gosub,A1
return
;-------------------
TestWinGuiClose:
Exitapp
;-------------------
A1:
Gui, testWin:ListView, MyListView
Loop, 10 
    LV_Add("", "Column-1 | Row-" A_Index ,  "Column-2 | Row-" A_Index,  "Column-3 | Row-" A_Index)
LV_ModifyCol()  ;- Auto-size each column to fit its contents.
return
;====================

calvey
Posts: 2
Joined: 23 Oct 2021, 09:42

Re: LV_Add do not add item when using GuiName inside subcommands

Post by calvey » 23 Oct 2021, 11:40

@garry, thank you for your answer. I added it and it worked!

Post Reply

Return to “Ask for Help (v1)”