Listview is deleting my tabs? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
JackPJ
Posts: 18
Joined: 19 Oct 2016, 05:52

Listview is deleting my tabs?

02 Feb 2018, 11:04

Hi all,

I've got some code where I set up a gui with multiple tabs,

I then try to add a listview to one of the tabs. But by adding in the bold line below, the listbox appears, but all my tabs disappear? :( What am I missing here?

Code: Select all

	;~ ===== Changes the font temporarily to add the Tabs, then changes back
    Gui, 1:font,s12, Verdana 
    Gui, 1:add, Tab, x1 y1 w1300 h900 vTabs, Search|Add|Edit
    Gui, 1:font,s8, Verdana 
	
	
	
	;~ ==========================================
	;~ ===== TAB 1 : SEARCH PAGE (a)
	;~ ==========================================
	{
		Gui, 1:tab, Search                                                  ;~ ===== Changes the focus to the managers tab, so all changes apply to it.
		
		Gui, 1:font, s18 cE31B23, Verdana									;~ ===== Makes text larger and red for title
		Gui, 1:add, text,  x5 y40 w200 h50, Accident Search					;~ ===== Adds title textbox
		Gui, 1:font, s8  c000000, Verdana 									;~ ===== Makes text back to default for rest of window
		

		
		;~ ==========================================
		;~ ===== Main Search Results  
		;~ ==========================================
		{
			MSStartx := 5																							;~ ===== Start X coord for the section
			MSStarty := 145																							;~ ===== Start Y coord for the section
			
			Offx := MSStartx + 0
			Offy := MSStarty + 0
			[b][u]Gui, 1:Add, ListView, aResults x%Offx% y%Offy% h500   w1285  , Item1|Item1|Item1|Item1|Item1|Item1  ;~ ===== Listbox for Account Code[/u][/b]
			
			;LV_ModifyCol(3, N500)
		}
	}
Many Thanks

jack
User avatar
divanebaba
Posts: 805
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: Listview is deleting my tabs?

02 Feb 2018, 13:31

>> Gui, 1:Add, ListView, aResults x%Offx% y%Offy% h500 w1285 , Item1|Item1|Item1|Item1|Item1|Item1 <<

This option is new for me and I could not find in help file.
Even if it's maybe not the bug, would you kindly explain this unknown option to me?
Einfach nur ein toller Typ. :mrgreen:
JackPJ
Posts: 18
Joined: 19 Oct 2016, 05:52

Re: Listview is deleting my tabs?

05 Feb 2018, 05:18

Apologies, I left that in from before when I was trying to differentiate between two different listviews, but I forgot to remove it when it didn't work.

It doesn't solve my issue though :(
garry
Posts: 3758
Joined: 22 Dec 2013, 12:50

Re: Listview is deleting my tabs?  Topic is solved

05 Feb 2018, 07:31

-example with 3 TABs ( see altsubmit , variable , define TAB etc )
- DRAG and MOVE the GUI

Code: Select all

;- 3 TAB's 
;- can DRAG and MOVE the GUI
;---------------------------------------
Gui,1:default
    Gui, 1:font,s12, Verdana
    Gui, 1:add, Tab, x1 y1 w1000 h500 vTabs altsubmit, Search|Add|Edit
    Gui, 1:font,s8, Verdana

    Gui, 1:tab, Search
	Gui, 1:font, s18 cE31B23, Verdana		           	;~ ===== Makes text larger and red for title
	Gui, 1:add, text,  x5 y40 w200 , Accident Search		;~ ===== Adds title textbox
	Gui, 1:font, s8  c000000, Verdana 				;~ ===== Makes text back to default for rest of window
	Gui, 1:Add, ListView, grid x10 y100 h400 w900 gMyListView vA1 altsubmit , A|B|C
        LV_Add("","Tab 1", "Line 1","C1")
        LV_Add("","Tab 1", "Line 2","C2")
        LV_Add("","Tab 1", "Line 3","C3")
        Gui,add,button,x10 y550  gT1,TEST1
        LV_ModifyCol()

     Gui, 1:Tab, Add
        Gui, 1:Add, ListView, x10 y50 h400 w900 gMyListView vA2 altsubmit,Tab-No|Line-No|C3
        LV_Add("","Tab 2", "Line 1","C1")
        LV_Add("","Tab 2", "Line 2","C2")
        LV_Add("","Tab 2", "Line 3","C3")
        Gui,add,button,x10 y550  gT2,TEST2
        LV_ModifyCol()

     Gui,1:Tab, Edit
        Gui,1:add,Edit, x10 y50 w950 h400 vA3,1Test3`n2TEST3
        Gui,1:add,button,x10 y550  gT3,TEST3
Gui, 1:Show,x10 y10 w1000 h600 , Tabs
OnMessage(0x201, "WM_LBUTTONDOWN")
return

Guiclose:
exitapp


T1:
Gui,1:submit,nohide
Gui,1:Listview,A%whichTab%
msgbox, 262208, ,T1,3
return
T2:
Gui,1:submit,nohide
Gui,1:Listview,A%whichTab%
msgbox, 262208, ,T2,3
return
T3:
Gui,1:submit,nohide
msgbox, 262208, ,T3,3
return

MyListView:
ControlGet, whichTab, Tab, , SysTabControl321, Tabs
Gui,1:submit,nohide
Gui,1:Listview,A%whichTab%
if A_GuiEvent = Normal          ;click once
  {
  LV_Gettext(C1,A_eventinfo,1)
  LV_Gettext(C2,A_eventinfo,2)
  LV_Gettext(C3,A_eventinfo,3)
  msgbox, 262208, ,Column1=%c1%`nColumn2=%c2%`nColumn3=%c3%,3
  }
Return

WM_LBUTTONDOWN(wParam, lParam, msg, hwnd)
{
Gui, +LastFound
Checkhwnd := WinExist()
if hwnd = %Checkhwnd%
   PostMessage, 0xA1, 2
;- 0x201 is the number for Windows Message WM_LBUTTONDOWN, which is the message Windows sends when the mouse clicks on our window.
;- 0xA1 is WM_NCLBUTTONDOWN, to make Windows think we clicked on the non-client area of the window (the border).
;- The "2" tells windows we clicked on caption at the top of the window, as if to drag it.
}
;=========================================================

Last edited by garry on 05 Feb 2018, 08:57, edited 1 time in total.
JackPJ
Posts: 18
Joined: 19 Oct 2016, 05:52

Re: Listview is deleting my tabs?

05 Feb 2018, 08:35

Thanks Garry,
I've managed to now condense the issue down to the following code

Code: Select all

    Gui, 1:color, f7f7f7    ;~ ===== Sets the background colour of the window (F5F5F5)
	gui, 1:-border			;~ ===== Turns off the border   
	

	;~ ===== Changes the font temporarily to add the Tabs, then changes back
    Gui, 1:font,s12, Verdana 
    Gui, 1:add, Tab, x1 y1 w1300 h900 vTabs, Search|Add|Edit
    Gui, 1:font,s8, Verdana 
	
		

		Gui, 1:tab, Search                                                  ;~ ===== Changes the focus to the managers tab, so all changes apply to it.
		

			MSStartx := 5																							;~ ===== Start X coord for the section
			MSStarty := 145																							;~ ===== Start Y coord for the section
					
			
			Offx := MSStartx + 0
			Offy := MSStarty + 0
			Gui, 1:Add, ListView, grid x%Offx% y%Offy% h500   w1285 vaResults , OrderNo|Registration|Dealership|Driver|Manager|Regional     	;~ ===== Listbox for Account Code
			
			gui, 1:default																												;~ =====  Dont know but needed to get listview to update
			Gui, 1:ListView, aResults																									;~ ===== Resets current listview focus to Accidents Results
			

	enableGuiDrag()
	gui, 1:show, w1300 h700
	return
	
	
	
	enableGuiDrag(GuiLabel=1) 
	{
		WinGetPos,,,A_w,A_h,A
		Gui, %GuiLabel%:Add, Text, x0 y0 w%A_w% h%A_h% +BackgroundTrans gGUI_Drag
		return
		
		GUI_Drag:
		PostMessage 0xA1,2  ;-- Goyyah/SKAN trick
		return
	}
- If I comment out the listview, the tabs work fine
- If I put the list view in, they dissappear
- I've narrowed it down to the enableGUIDrag function at the bottom. If I dont call it, they both work, but i cant drag the gui.

Do you have any idea why the enableGUIDrag function would kill off my tabs? Both the tabs and the listview work fine with it on their own, but not together :(
garry
Posts: 3758
Joined: 22 Dec 2013, 12:50

Re: Listview is deleting my tabs?

05 Feb 2018, 08:58

modified script above , possible to DRAG the GUI
JackPJ
Posts: 18
Joined: 19 Oct 2016, 05:52

Re: Listview is deleting my tabs?

05 Feb 2018, 09:37

Thanks Garry, that's a tonne of help! I should be able to port the dragging code over to mine easily enough now

I don't suppose you know what part of the dragging code in my example is causing the conflict or why? so I can learn a bit from all this?
garry
Posts: 3758
Joined: 22 Dec 2013, 12:50

Re: Listview is deleting my tabs?

05 Feb 2018, 09:54

@JackPJ, sorry I don't really understand the function 'EnableGuiDrag' , have just basic knowledge with ahk- commands
JackPJ
Posts: 18
Joined: 19 Oct 2016, 05:52

Re: Listview is deleting my tabs?

05 Feb 2018, 10:01

garry wrote:@JackPJ, sorry I don't really understand the function 'EnableGuiDrag' , have just basic knowledge with ahk- commands
No Worries, thanks anyway

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Giresharu and 269 guests