About listview function

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Kevin_yeh2020
Posts: 106
Joined: 11 Apr 2020, 00:54

About listview function

25 Jul 2021, 10:23

Hello,

How can I display A1~C90 data in sheet1? I try to change the code "LV_Add" to code "Gui, 2:LV_Add",but an error message will be displayed

Code: Select all

Gui, Show, x27 y87 h400 w400, Window
Gui, Font, Norm S10 W600 cblack , Tahoma 
Gui, Add, Button, x40 y40 w70 h40, Button1
Return

GuiClose:
ExitApp

ButtonButton1:
#NoTrayIcon				
Gui,2: +AlwaysOnTop				
WinActivate, ahk_id %k_ID%				
Gui,2:Submit, NoHide						
Gui,2:Font, S10 W600, Tahoma 				
Gui,2:Show, x50 y20 h825 w540, New window
Gui,2:Add, Tab, x1 y5 w540 h820 , Sheet1|Sheet2|Sheet3|Sheet4				
Gui,2:Tab, Sheet1
Gui,2:Add, ListView, x110 y190 w200 h200, A|B|C|D|E
LV_Add("", "A1", "A10", "A40", "A70")
LV_Add("", "B1", "B20", "B50", "B80")
LV_Add("", "C1", "C30", "C60", "C90")
return

2GuiClose:
Gui,2:Destroy
return
User avatar
mikeyww
Posts: 26939
Joined: 09 Sep 2014, 18:38

Re: About listview function

25 Jul 2021, 10:41

The routine label would need to start with the GUI name if there is one (e.g., 2ButtonButton1), and your top routine would also add that name. You can use Gui, Guiname:Default at the top of each thread.

Code: Select all

Gui, 2:Default
Gui, Font, s10
Gui, Add, Button, x40 y40 w70 h40, Button1
Gui, Show, w400 h400, Test
Return

2ButtonButton1:
Gui, 2:Default
Gui, Add, Tab3,, Sheet1|Sheet2|Sheet3|Sheet4
Gui, Tab, Sheet1
Gui, Add, ListView, w200 h200, A|B|C|D|E
LV_Add("", "A1", "A10", "A40", "A70"), LV_Add("", "B1", "B20", "B50", "B80")
Return
An alternative is below.

Code: Select all

Gui, Font, s10
Gui, Add, Button, x40 y40 w70 h40, Button1
Gui, Add, Tab3, w540 h820 vtabs, Sheet1|Sheet2|Sheet3|Sheet4
Gui, Tab, Sheet1
Gui, Add, ListView, w200 h200, A|B|C|D|E
LV_Add("", "A1", "A10", "A40", "A70"), LV_Add("", "B1", "B20", "B50", "B80")
GuiControl, Hide, tabs
Gui, Show, h400 w400, Test
Return

ButtonButton1:
GuiControl, Show, tabs
Return
For different GUIs with your approach:

Code: Select all

Gui, Font, Norm S10 W600 cblack , Tahoma
Gui, Add, Button, x40 y40 w70 h40, Button1
Gui, Show, x27 y87, Window
Return

ButtonButton1:
Gui, 2:Default
Gui, Font, S10 W600, Tahoma
Gui, Add, Tab3, w440 h320, Sheet1|Sheet2|Sheet3|Sheet4
Gui, Tab, Sheet1
Gui, Add, ListView, w200 h200, A|B|C|D|E
LV_Add("", "A1", "A10", "A40", "A70"), LV_Add("", "B1", "B20", "B50", "B80")
Gui, Show,, New window
Return
Or:

Code: Select all

Gui, Font, s10
Gui, Add, Button,, Button1
Gui, Show, x100 y100, Actions
Gui, 2:Default
Gui, Font, s10
Gui, Add, Tab3, w440 h320, Sheet1|Sheet2|Sheet3|Sheet4
Gui, Tab, Sheet1
Gui, Add, ListView, w200 h200, A|B|C|D|E
LV_Add("", "A1", "A10", "A40", "A70"), LV_Add("", "B1", "B20", "B50", "B80")
Return

ButtonButton1:
Gui, 2:Show,, Sheets
Return
Kevin_yeh2020
Posts: 106
Joined: 11 Apr 2020, 00:54

Re: About listview function

25 Jul 2021, 11:16

mikeyww wrote:
25 Jul 2021, 10:41
The routine label would need to start with the GUI name if there is one (e.g., 2ButtonButton1), and your top routine would also add that name. You can use Gui, Guiname:Default at the top of each thread.

Code: Select all

Gui, 2:Default
Gui, Font, s10
Gui, Add, Button, x40 y40 w70 h40, Button1
Gui, Show, w400 h400, Test
Return

2ButtonButton1:
Gui, 2:Default
Gui, Add, Tab3,, Sheet1|Sheet2|Sheet3|Sheet4
Gui, Tab, Sheet1
Gui, Add, ListView, w200 h200, A|B|C|D|E
LV_Add("", "A1", "A10", "A40", "A70"), LV_Add("", "B1", "B20", "B50", "B80")
Return
An alternative is below.

Code: Select all

Gui, Font, s10
Gui, Add, Button, x40 y40 w70 h40, Button1
Gui, Add, Tab3, w540 h820 vtabs, Sheet1|Sheet2|Sheet3|Sheet4
Gui, Tab, Sheet1
Gui, Add, ListView, w200 h200, A|B|C|D|E
LV_Add("", "A1", "A10", "A40", "A70"), LV_Add("", "B1", "B20", "B50", "B80")
GuiControl, Hide, tabs
Gui, Show, h400 w400, Test
Return

ButtonButton1:
GuiControl, Show, tabs
Return
For different GUIs with your approach:

Code: Select all

Gui, Font, Norm S10 W600 cblack , Tahoma
Gui, Add, Button, x40 y40 w70 h40, Button1
Gui, Show, x27 y87, Window
Return

ButtonButton1:
Gui, 2:Default
Gui, Font, S10 W600, Tahoma
Gui, Add, Tab3, w440 h320, Sheet1|Sheet2|Sheet3|Sheet4
Gui, Tab, Sheet1
Gui, Add, ListView, w200 h200, A|B|C|D|E
LV_Add("", "A1", "A10", "A40", "A70"), LV_Add("", "B1", "B20", "B50", "B80")
Gui, Show,, New window
Return
Or:

Code: Select all

Gui, Font, s10
Gui, Add, Button,, Button1
Gui, Show, x100 y100, Actions
Gui, 2:Default
Gui, Font, s10
Gui, Add, Tab3, w440 h320, Sheet1|Sheet2|Sheet3|Sheet4
Gui, Tab, Sheet1
Gui, Add, ListView, w200 h200, A|B|C|D|E
LV_Add("", "A1", "A10", "A40", "A70"), LV_Add("", "B1", "B20", "B50", "B80")
Return

ButtonButton1:
Gui, 2:Show,, Sheets
Return
Hi, mikeyww
I will adjust the field width, thanks for your reply

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Joey5 and 270 guests