ListView and Tabs Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Ocelot
Posts: 8
Joined: 04 Oct 2020, 16:21

ListView and Tabs

05 Oct 2020, 16:40

Is there a way to show a tab by clicking a row in a Listview? I'm aware it's possible in TreeView and have used it in the past which was easier. I'm thinking somehow compare the rows and if the rows text match, then show the tab?

I've got this incomplete mess here.

Code: Select all

Gui, Add, Listview, y0 R10 W500 gMyListView altsubmit, File | Type | Media
LV_ADD("", "DWTD", "File", "Music")
LV_ADD("", "Scandroid", "File", "Music")
LV_ADD("", "FuryWeekend", "File", "Music")

Loop, 1
    LV_ModifyCol(A_Index AutoHdr)
Gui, +Resize
Gui,Add,Text,, % ""LV_GetCount()" Items Total."

Gui, Add, Tab2, x0 y250 w200 h0 -Wrap vMyTab, A1|A2|A3|

Gui, Tab, A1
Gui, Add, Text,,DWTD
Gui, Add, Text,,DWTD

Gui, Tab, A2
Gui, Add, Text,,Scandroid
Gui, Add, Text,,Scandroid

Gui, Tab, A3
Gui, Add, Text,,FuryWeekend
Gui, Add, Text,,FuryWeekend

Gui, Show, Y0 X960
Return

MyListView:
if (a_guievent = "K") OR (A_GuiEvent = "Normal")
{
	GNVari:=LV_GetNext("","F")
	LV_GetText(RowText1,GNVari)
	{
If (A_EventInfo == DWTD)
		{
			GuiControl,,Tab A1
			GuiControl, Choose, MyTab,A1
		}
If (A_EventInfo == Scandroid)
		{
			GuiControl,,Tab A2
			GuiControl, Choose, MyTab,A2
		}
If (A_EventInfo == FuryWeekend)
		{
			GuiControl,,Tab A3
			GuiControl, Choose, MyTab,A3
		}
}
return

Guiclose:
reload
return
User avatar
mikeyww
Posts: 27366
Joined: 09 Sep 2014, 18:38

Re: ListView and Tabs

05 Oct 2020, 17:36

Could try the following sort of format. It worked for me with this code.

Code: Select all

Gui, New
Gui, Font, s10
Gui, Add, Listview, R10 W500 gEvent AltSubmit, Text
Gui, Add, Tab3, vTabs, Tab1|Tab2|Tab3
LV_Add("", "Row1 in main listview")
Gui, Tab, 3
Gui, Add, Listview, R10 W500, Text2
LV_Add("", "Row1 in tab 3")
Gui, Show
Return

Event:
If (A_GuiEvent = "Normal")
 GuiControl, Choose, Tabs, 3
Return
User avatar
Ocelot
Posts: 8
Joined: 04 Oct 2020, 16:21

Re: ListView and Tabs

06 Oct 2020, 15:24

Not quite. That selects a tab no matter what row you select where as I'm trying to select a row to select a specific tab. I'm sure I'll find something that will work if no one here has any ideas.
User avatar
mikeyww
Posts: 27366
Joined: 09 Sep 2014, 18:38

Re: ListView and Tabs

06 Oct 2020, 15:36

LV_GetNext allows you to determine the row number of a selected, focused, or checked row. LV_GetText allows you to retrieve the text from such a row. It sounds like that might be what you need. I see you have that; I'll go back and review.
Last edited by mikeyww on 06 Oct 2020, 15:37, edited 1 time in total.
User avatar
Ocelot
Posts: 8
Joined: 04 Oct 2020, 16:21

Re: ListView and Tabs

06 Oct 2020, 15:36

So this works...

Code: Select all

Gui, Add, Listview, y0 R10 W500 gMyListView altsubmit, File | Type | Media
LV_ADD("", "DWTD", "File", "Music")
LV_ADD("", "Scandroid", "File", "Music")
LV_ADD("", "FuryWeekend", "File", "Music")

Loop, 1
    LV_ModifyCol(A_Index AutoHdr)
Gui, +Resize
Gui,Add,Text,, % ""LV_GetCount()" Items Total."

Gui, Add, Tab2, x0 y250 w200 h0 -Wrap vMyTab, DWTD|Scandroid|FuryWeekend

Gui, Tab, DWTD
Gui, Add, Text,,DWTD
Gui, Add, Text,,DWTD

Gui, Tab, Scandroid
Gui, Add, Text,,Scandroid
Gui, Add, Text,,Scandroid

Gui, Tab, FuryWeekend
Gui, Add, Text,,FuryWeekend
Gui, Add, Text,,FuryWeekend

Gui, Show, Y0 X960
Return

MyListView:
if (a_guievent = "K") OR (A_GuiEvent = "Normal")
{
	GNVari:=LV_GetNext("","F")
	LV_GetText(RowText1,GNVari)
	GuiControl,,Tab %RowText1%
	GuiControl, Choose, MyTab,%RowText1%
}
return
Seems kind of janky but it will work until I meet any problems.
User avatar
mikeyww
Posts: 27366
Joined: 09 Sep 2014, 18:38

Re: ListView and Tabs

06 Oct 2020, 15:49

Not sure if this helps any!

Code: Select all

Gui, Add, Tab3, vTabs, Menu|DWTD|Scandroid|FuryWeekend
Gui, Tab, Menu
Gui, Add, Listview, R10 W500 gEvent altsubmit, File|Type|Media
LV_ADD("", "DWTD", "File", "Music")
LV_ADD("", "Scandroid", "File", "Music")
LV_ADD("", "FuryWeekend", "File", "Music")
Gui, Tab, DWTD
Gui, Add, Text,,DWTD
Gui, Add, Text,,DWTD
Gui, Tab, Scandroid
Gui, Add, Text,,Scandroid
Gui, Add, Text,,Scandroid
Gui, Tab, FuryWeekend
Gui, Add, Text,,FuryWeekend
Gui, Add, Text,,FuryWeekend
LV_ModifyCol()
Gui, Show
Return

Event:
If (A_GuiEvent = "K") OR (A_GuiEvent = "Normal")
 GuiControl, Choose, Tabs, % LV_GetNext() + 1
Return
User avatar
Ocelot
Posts: 8
Joined: 04 Oct 2020, 16:21

Re: ListView and Tabs  Topic is solved

08 Oct 2020, 14:54

So my above code has a flicker if you added too many rows that seemed to have no solution to it. Apparently with "autoHotkey_L. It's a side effect of "invalidating" the portion of the window which the control occupies," according to Lexikos back in 2012. //autohotkey.com/board/topic/78773-guicontrol-removing-backgroundtrans-from-text/?p=528199

Anyhow, adding a second gui for the tabs seems to fix any kind of flickering. If that doesn't work for some trying to get rid of a flicker, maybe try elModo7's suggestion: https://www.autohotkey.com/boards/viewtopic.php?p=337653

Code: Select all

#SingleInstance, Force

Gui,1:Add, Listview, R25 W380 hwndLVX gEvent AltSubmit +LV0x800 +LV0x40, Title|Date|Type
LV_ADD("", "DWTD", "File", "Music")
LV_ADD("", "Scandroid", "File", "Music")
LV_ADD("", "FuryWeekend", "File", "Music")
LV_ADD("", "Dance WIth The Dead", "File", "Music")
LV_ADD("", "Elmer Berstein", "File", "Music")
LV_ADD("", "Eluveltie", "File", "Music")
LV_ADD("", "Christoffer Ling", "File", "Music")
LV_ADD("", "Thomas Barrandon", "File", "Music")
LV_ADD("", "Zwei", "File", "Music")
LV_ADD("", "Overwerk", "File", "Music")
LV_ADD("", "Code Elektro", "File", "Music")
LV_ADD("", "Mykah", "File", "Music")
LV_ADD("", "Neon Nox", "File", "Music")
LV_ADD("", "Savlonic", "File", "Music")
LV_ADD("", "Aimee Blackschleger", "File", "Music")
LV_ADD("", "Silent Poets", "File", "Music")
LV_ADD("", "Minutes TIl Midnight", "File", "Music")
LV_ADD("", "Savoy", "File", "Music")
LV_ADD("", "Red Marker", "File", "Music")
LV_ADD("", "MPI", "File", "Music")
LV_ADD("", "Kevin Penkin", "File", "Music")
LV_ADD("", "Saltillo", "File", "Music")
LV_ADD("", "Midnight Romeo", "File", "Music")
LV_ADD("", "Low Roar", "File", "Music")
LV_ADD("", "Man WIth A Mission", "File", "Music")
LV_ADD("", "Orjan Nilsen", "File", "Music")
LV_ADD("", "Otto Knows", "File", "Music")
LV_ADD("", "Pain", "File", "Music")

Gui,1:Font, Bold
Gui,1:Font, S13 c00FFF8, Arial

Loop, 3
  LV_ModifyCol(A_Index AutoHdr)
Gui,1:+Resize
Gui,1:Add,Text,, % ""LV_GetCount()" Items Indexed."
Gui,1:Color, Black
Gui,1:Show,w800 h500,Index

Gui,2:Add, Tab2, x0 y0 w400 h0 -Wrap vMyTab, DWTD|Scandroid|FuryWeekend|Dance WIth The Dead |Elmer Berstein |Eluveltie |Christoffer Ling |Thomas Barrandon |Zwei |Overwerk |Code Elektro |Mykah |Neon Nox |Savlonic |Aimee Blackschleger |Silent Poets |Minutes TIl Midnight |Savoy |Red Marker |MPI |Kevin Penkin |Saltillo |Midnight Romeo |Low Roar |Man WIth A Mission |Orjan Nilsen |Otto Knows |Pain
Gui,2:Tab, DWTD
Gui,2:Font, Bold
Gui,2:Font, S13 cFF8500, Arial
Gui,2:Add, Text,,DWTD
Gui,2:Add, Text,,DWTD
Gui,2:Tab, Scandroid
Gui,2:Add, Text,,Scandroid
Gui,2:Add, Text,,Scandroid
Gui,2:Tab, FuryWeekend
Gui,2:Add, Text,,FuryWeekend
Gui,2:Add, Text,,FuryWeekend
Gui,2:Tab, Aimee Blackschleger
Gui,2:Add, Text,, Aimee Blackschleger
Gui,2:Add, Text,, Aimee Blackschleger
Gui,2:Tab, Christoffer Ling
Gui,2:Add, Text,, Christoffer Ling
Gui,2:Add, Text,, Christoffer Ling
Gui,2:Tab, Code Elektro
Gui,2:Add, Text,, Code Elektro
Gui,2:Add, Text,, Code Elektro
Gui,2:Tab, Dance WIth The Dead
Gui,2:Add, Text,, Dance WIth The Dead
Gui,2:Add, Text,, Dance WIth The Dead
Gui,2:Tab, Elmer Berstein
Gui,2:Add, Text,, Elmer Berstein
Gui,2:Add, Text,, Elmer Berstein
Gui,2:Tab, Eluveltie
Gui,2:Add, Text,, Eluveltie
Gui,2:Add, Text,, Eluveltie
Gui,2:Tab, Kevin Penkin
Gui,2:Add, Text,, Kevin Penkin
Gui,2:Add, Text,, Kevin Penkin
Gui,2:Tab, Low Roar
Gui,2:Add, Text,, Low Roar
Gui,2:Add, Text,, Low Roar
Gui,2:Tab, Man WIth A Mission
Gui,2:Add, Text,, Man WIth A Mission
Gui,2:Add, Text,, Man WIth A Mission
Gui,2:Tab, Midnight Romeo
Gui,2:Add, Text,, Midnight Romeo
Gui,2:Add, Text,, Midnight Romeo
Gui,2:Tab, Minutes TIl Midnight
Gui,2:Add, Text,, Minutes TIl Midnight
Gui,2:Add, Text,, Minutes TIl Midnight
Gui,2:Tab, MPI
Gui,2:Add, Text,, MPI
Gui,2:Add, Text,, MPI
Gui,2:Tab, Mykah
Gui,2:Add, Text,, Mykah
Gui,2:Add, Text,, Mykah
Gui,2:Tab, Neon Nox
Gui,2:Add, Text,, Neon Nox
Gui,2:Add, Text,, Neon Nox
Gui,2:Tab, Orjan Nilsen
Gui,2:Add, Text,, Orjan Nilsen
Gui,2:Add, Text,, Orjan Nilsen
Gui,2:Tab, Otto Knows
Gui,2:Add, Text,, Otto Knows
Gui,2:Add, Text,, Otto Knows
Gui,2:Tab, Overwerk
Gui,2:Add, Text,, Overwerk
Gui,2:Add, Text,, Overwerk
Gui,2:Tab, Pain
Gui,2:Add, Text,, Pain
Gui,2:Add, Text,, Pain
Gui,2:Tab, Red Marker
Gui,2:Add, Text,, Red Marker
Gui,2:Add, Text,, Red Marker
Gui,2:Tab, Saltillo
Gui,2:Add, Text,, Saltillo
Gui,2:Add, Text,, Saltillo
Gui,2:Tab, Savlonic
Gui,2:Add, Text,, Savlonic
Gui,2:Add, Text,, Savlonic
Gui,2:Tab, Savoy
Gui,2:Add, Text,, Savoy
Gui,2:Add, Text,, Savoy
Gui,2:Tab, Silent Poets
Gui,2:Add, Text,, Silent Poets
Gui,2:Add, Text,, Silent Poets
Gui,2:Tab, Thomas Barrandon
Gui,2:Add, Text,, Thomas Barrandon
Gui,2:Add, Text,, Thomas Barrandon
Gui,2:Tab, Zwei
Gui,2:Add, Text,, Zwei
Gui,2:Add, Text,, Zwei

Gui,2:+Parent1 -Caption
;Gui,2:Color, White
Gui,2:Font, S13 cE200FF, Arial
Gui,2:Color, Black
Gui,2:Show, x400 y0 w400 h500,
return

Event:
if (A_GuiEvent = "K") OR (A_GuiEvent = "Normal")
{
GNVari:=LV_GetNext("","F")
LV_GetText(RowText1,GNVari)
GuiControl, 2:Choose, MyTab, %RowText1%
}
return

GuiClose:
ExitApp
;Reload
Return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: apeironn, Descolada, fiaztv1, Google [Bot], JKJadan, Pianist and 208 guests