Gui Tabs - move a gui control to another tab

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
AHK_user
Posts: 515
Joined: 04 Dec 2015, 14:52
Location: Belgium

Gui Tabs - move a gui control to another tab

Post by AHK_user » 18 Jul 2021, 12:00

Does somebody know how to move a Gui control to a different tab after the gui is created?

Below example shows the effect I want to have: if you resize the height of the gui smaller with your mouse, an extra tab "4" should appear and the first edit control should be moved to tab 4.

The following code gives kind of the effect that I am looking for, by using 2 Edit controls and hide and show them. But this trick seems to be more complicated than it needs to be, and if it is possible to just move the control, it would be easier:
The need to add labels that mirror the content of the one Edit to the other, and for my final script I want to use a listview with actions attached, so it becomes even more complex to mirror it. Just moving it seems less complicated and better way of work.
2021-07-18 18_49_54-Window.png
2021-07-18 18_49_54-Window.png (19.68 KiB) Viewed 864 times

Code: Select all

#SingleInstance, Force

Gui, Add, Edit, x6 y6 w200 vvEdit1, test
Gui, Add, Tab3, vvTab, 1|2|3|4
Gui, Tab, 4

; Code added for demonstration,  Edit2 should not exist normally
Gui, Add, Edit, x20 y60 w200  vvEdit2, test

Gui, +Resize
Gui, Show, W300 H300
return
GuiSize:

TabHeight := A_GuiHeight - 40

if (A_GuiHeight<200){
	TabY:=4
	TabHeight+=26
	GuiControl, , vTab, |1|2|3|4
	
	; Suspected code, but it does not seem work
	;~ Gui, Tab, 4
	;~ GuiControl, Move, vEdit1, x20 y60
	;~ Gui, Tab
	
	; Code added for demonstration, these lines should be removed
	GuiControl, Hide, vEdit1,
	GuiControl, Show, vEdit2,
}
else{
	TabY:=30
	GuiControl, , vTab, |1|2|3
	
	; Suspected code, but it does not work
	;~ Gui, Tab
	;~ GuiControl, Move, vEdit1, x6 Y6
	
	; Code added for demonstration, these lines should be removed
	GuiControl, Show, vEdit1,
	GuiControl, Hide, vEdit2,
}

GuiControl, Move, vTab, % "y" TabY " h" TabHeight
return
AHKStudent
Posts: 1472
Joined: 05 May 2018, 12:23

Re: Gui Tabs - move a gui control to another tab

Post by AHKStudent » 18 Jul 2021, 12:28

Sorry I cannot test now but a quick look I would say

You need to add

Code: Select all

gui, submit, nohide
Anytime you want data to be saved on the gui in a text box

I dont know the answers to your other question
AHK_user
Posts: 515
Joined: 04 Dec 2015, 14:52
Location: Belgium

Re: Gui Tabs - move a gui control to another tab

Post by AHK_user » 18 Jul 2021, 13:14

AHKStudent wrote:
18 Jul 2021, 12:28
Sorry I cannot test now but a quick look I would say

You need to add

Code: Select all

gui, submit, nohide
Anytime you want data to be saved on the gui in a text box

I dont know the answers to your other question
This could indeed used to "mirror" the edits, if you type in one, it changes the content of the other. But if it is possible to move the control, this would be less complicated and cleaner, certainly if you add other events and you want to move multiple controls and listviews...

Here is the code that also mirrors the content, but I am actually trying to find a way to just move the edit1 control and not having to use a second control.

Code: Select all

;Demonstration of desired result
#SingleInstance, Force

Gui, Add, Edit, x6 y6 w200 vvEdit1 ggEdit1, test
Gui, Add, Tab3, vvTab, 1|2|3|4
Gui, Tab, 4

; Code added for demonstration,  Edit2 should not exist normally
Gui, Add, Edit, x20 y60 w200 vvEdit2 ggEdit2, test

Gui, +Resize
Gui, Show, W300 H300
return
GuiSize:

TabHeight := A_GuiHeight - 40

if (A_GuiHeight<200){
	TabY:=4
	TabHeight+=26
	GuiControl, , vTab, |1|2|3|4
	
	; Suspected correct code, but it does not work
	;~ Gui, Tab, 4
	;~ GuiControl, Move, vEdit1, x20 y60
	;~ GuiControl, Show, vEdit1,
	;~ Gui, Tab
	
	; Code added for demonstration, these lines should be removed
	GuiControl, Hide, vEdit1,
	GuiControl, Show, vEdit2,
}
else{
	TabY:=30
	GuiControl, , vTab, |1|2|3
	
	; Suspected code, but it does not work
	;~ Gui, Tab
	;~ GuiControl, Move, vEdit1, x6 Y6
	
	; Code added for demonstration, these lines should be removed
	GuiControl, Show, vEdit1,
	GuiControl, Hide, vEdit2,
}

GuiControl, Move, vTab, % "y" TabY " h" TabHeight
return

; Labels used to mirror the content of the Edits
gEdit1:
Gui, Submit, Nohide
if (vEdit2!=vEdit1)
	GuiControl, , vEdit2, % vEdit1
return

gEdit2:
Gui, Submit, Nohide
if (vEdit2!=vEdit1)
	GuiControl, , vEdit1, % vEdit2
return
AHKStudent
Posts: 1472
Joined: 05 May 2018, 12:23

Re: Gui Tabs - move a gui control to another tab

Post by AHKStudent » 18 Jul 2021, 14:19

AHK_user wrote:
18 Jul 2021, 13:14
AHKStudent wrote:
18 Jul 2021, 12:28
Sorry I cannot test now but a quick look I would say

You need to add

Code: Select all

gui, submit, nohide
Anytime you want data to be saved on the gui in a text box

I dont know the answers to your other question
This could indeed used to "mirror" the edits, if you type in one, it changes the content of the other. But if it is possible to move the control, this would be less complicated and cleaner, certainly if you add other events and you want to move multiple controls and listviews...

Here is the code that also mirrors the content, but I am actually trying to find a way to just move the edit1 control and not having to use a second control.

Code: Select all

;Demonstration of desired result
#SingleInstance, Force

Gui, Add, Edit, x6 y6 w200 vvEdit1 ggEdit1, test
Gui, Add, Tab3, vvTab, 1|2|3|4
Gui, Tab, 4

; Code added for demonstration,  Edit2 should not exist normally
Gui, Add, Edit, x20 y60 w200 vvEdit2 ggEdit2, test

Gui, +Resize
Gui, Show, W300 H300
return
GuiSize:

TabHeight := A_GuiHeight - 40

if (A_GuiHeight<200){
	TabY:=4
	TabHeight+=26
	GuiControl, , vTab, |1|2|3|4
	
	; Suspected correct code, but it does not work
	;~ Gui, Tab, 4
	;~ GuiControl, Move, vEdit1, x20 y60
	;~ GuiControl, Show, vEdit1,
	;~ Gui, Tab
	
	; Code added for demonstration, these lines should be removed
	GuiControl, Hide, vEdit1,
	GuiControl, Show, vEdit2,
}
else{
	TabY:=30
	GuiControl, , vTab, |1|2|3
	
	; Suspected code, but it does not work
	;~ Gui, Tab
	;~ GuiControl, Move, vEdit1, x6 Y6
	
	; Code added for demonstration, these lines should be removed
	GuiControl, Show, vEdit1,
	GuiControl, Hide, vEdit2,
}

GuiControl, Move, vTab, % "y" TabY " h" TabHeight
return

; Labels used to mirror the content of the Edits
gEdit1:
Gui, Submit, Nohide
if (vEdit2!=vEdit1)
	GuiControl, , vEdit2, % vEdit1
return

gEdit2:
Gui, Submit, Nohide
if (vEdit2!=vEdit1)
	GuiControl, , vEdit1, % vEdit2
return
In your controlmove (guicontrol, move) try Edit1 not vEdit1, (I know you called it vvEdit1) but I am saying that I think you should use the control name not the variable name you gave it, it's confusing because you named it the way the controls are automatically named
AHK_user
Posts: 515
Joined: 04 Dec 2015, 14:52
Location: Belgium

Re: Gui Tabs - move a gui control to another tab

Post by AHK_user » 18 Jul 2021, 17:40

AHKStudent wrote:
18 Jul 2021, 14:19
AHK_user wrote:
18 Jul 2021, 13:14
AHKStudent wrote:
18 Jul 2021, 12:28
Sorry I cannot test now but a quick look I would say

You need to add

Code: Select all

gui, submit, nohide
Anytime you want data to be saved on the gui in a text box

I dont know the answers to your other question
This could indeed used to "mirror" the edits, if you type in one, it changes the content of the other. But if it is possible to move the control, this would be less complicated and cleaner, certainly if you add other events and you want to move multiple controls and listviews...

Here is the code that also mirrors the content, but I am actually trying to find a way to just move the edit1 control and not having to use a second control.

Code: Select all

;Demonstration of desired result
#SingleInstance, Force

Gui, Add, Edit, x6 y6 w200 vvEdit1 ggEdit1, test
Gui, Add, Tab3, vvTab, 1|2|3|4
Gui, Tab, 4

; Code added for demonstration,  Edit2 should not exist normally
Gui, Add, Edit, x20 y60 w200 vvEdit2 ggEdit2, test

Gui, +Resize
Gui, Show, W300 H300
return
GuiSize:

TabHeight := A_GuiHeight - 40

if (A_GuiHeight<200){
	TabY:=4
	TabHeight+=26
	GuiControl, , vTab, |1|2|3|4
	
	; Suspected correct code, but it does not work
	;~ Gui, Tab, 4
	;~ GuiControl, Move, vEdit1, x20 y60
	;~ GuiControl, Show, vEdit1,
	;~ Gui, Tab
	
	; Code added for demonstration, these lines should be removed
	GuiControl, Hide, vEdit1,
	GuiControl, Show, vEdit2,
}
else{
	TabY:=30
	GuiControl, , vTab, |1|2|3
	
	; Suspected code, but it does not work
	;~ Gui, Tab
	;~ GuiControl, Move, vEdit1, x6 Y6
	
	; Code added for demonstration, these lines should be removed
	GuiControl, Show, vEdit1,
	GuiControl, Hide, vEdit2,
}

GuiControl, Move, vTab, % "y" TabY " h" TabHeight
return

; Labels used to mirror the content of the Edits
gEdit1:
Gui, Submit, Nohide
if (vEdit2!=vEdit1)
	GuiControl, , vEdit2, % vEdit1
return

gEdit2:
Gui, Submit, Nohide
if (vEdit2!=vEdit1)
	GuiControl, , vEdit1, % vEdit2
return
In your controlmove (guicontrol, move) try Edit1 not vEdit1, (I know you called it vvEdit1) but I am saying that I think you should use the control name not the variable name you gave it, it's confusing because you named it the way the controls are automatically named
That is not the problem, the control moves, but is still not connected to the tab...
AHK_user
Posts: 515
Joined: 04 Dec 2015, 14:52
Location: Belgium

Re: Gui Tabs - move a gui control to another tab

Post by AHK_user » 20 Jul 2021, 18:02

I kind of intuitively managed to get it working... :dance: with some DLL calls I can put the control on top of the tab, and hide and show it by code. I guess this is less code than mirroring a complex control.

If somebody can explain what I did :think: , I would love to hear it, maybe we can improve the code further and really set the control on the tab.

Code: Select all

#SingleInstance, Force

Gui, Add, Edit, x6 y6 w200 vvEdit1 hwndhEdit1, test
Gui, Add, Tab3, vvTab hwndhTab ggTab , 1|2|3|test

; Code added for demonstration,  Edit2 should not exist normally
Gui, Add, Edit, x20 y60 w200 vvEdit2 hwndhEdit2 Hidden, t
tabId:=DllCall( "GetParent", "uint", hEdit2 )

; This DllCall seems to add the edit on top of the tab control
DllCall("SetParent", "uint", tabId, "uint", hEdit1)

Gui, +Resize
Gui, Show, W300 H300
return

GuiSize(){
	global
	; Disabeling redraw of Gui
	DllCall("LockWindowUpdate", Uint,hTestGui)
	TabHeight := A_GuiHeight - 36
	
	if (A_GuiHeight<200){
		if (TabY!=4){
			TabY:=4
			GuiControl, , vTab, |1|2|3|test
			
			; Suspected code, but it does not work
			GuiControl, Hide, vEdit1,
			GuiControl, Move, vEdit1, x20 y40
		}
		TabHeight+=26
	}
	else{
		if (TabY!=30){
			TabY:=30
			GuiControl, , vTab, |1|2|3
			
			; Code added for demonstration, these lines should be removed
			GuiControl, Move, vEdit1, x6 y6
			GuiControl, Show, vEdit1,
		}
	}
	
	GuiControl, Move, vTab, % "y" TabY " h" TabHeight
	
	; Enable redraw of Gui
	DllCall("LockWindowUpdate", Uint,0)
	return
}

gTab(var1, var2){
	; Manually showing and hiding the control
	global
	GuiControlGet, TabNumber, ,  vTab 
	if (TabNumber="test"){
		GuiControl, show, vEdit1
	}
	else {
		if (TabY=4){
			GuiControl, hide, vEdit1
		}
	}
}
AHK_user
Posts: 515
Joined: 04 Dec 2015, 14:52
Location: Belgium

Re: Gui Tabs - move a gui control to another tab

Post by AHK_user » 21 Jul 2021, 12:29

After some testing, it seems that setting the dll call would cause to many issues because it maybe works ok for 1 edit, but if you need multiple, it crashes :think: . So for now I go with the mirror technique, but if somebody figures out a way to move a control to a tab, I would love to hear it.
AHK_user
Posts: 515
Joined: 04 Dec 2015, 14:52
Location: Belgium

Re: Gui Tabs - move a gui control to another tab

Post by AHK_user » 22 Jul 2021, 17:02

Another option is to save the content of the control, delete the control and then recreate it.
The only thing to keep in mind with this method is to not use the v option to define the variable, use the hwnd option to get and modify the contol, because it is not possible to create a control with the same variable. Or is there maybe a better dll command to destroy the control better :think: ?

Code: Select all

#SingleInstance Force

Gui, +Resize
oGui := {}
Gui, Add, Edit, x6 y6 w200 hwndhEdit1, test

Gui, Add, Tab3, vvTab, 1|2|3|4
Gui, Tab, 4

Gui, Show, W300 H300
return

GuiSize:

TabHeight := A_GuiHeight - 35

if (A_GuiHeight<200){
	if (TaBY!=4){
		TabY:=4
		
		GuiControlGet, SelectedTab, , vTab
		GuiControl, , vTab, |1|2|3|4
		GuiControl, Choose, vTab,  % SelectedTab
		; Suspected code, but it does not seem work
		Gui, Tab, 4
		GuiControlGet, Edit1_Content, , % hEdit1
		DllCall("DestroyWindow", "UInt", hEdit1)
		Gui, Add, Edit, x10 y60 w200 hwndhEdit1, % Edit1_Content
		
		Gui, Tab
	}
	TabHeight+=26
	
}
else{
	if (TabY!=30){
		TabY:=30
		GuiControlGet, SelectedTab, , vTab
		GuiControl, , vTab, |1|2|3
		GuiControl, Choose, vTab,  % SelectedTab
		; Suspected code, but it does not work
		Gui, Tab
		GuiControlGet, Edit1_Content, , % hEdit1
		DllCall("DestroyWindow", "UInt", hEdit1)
		Gui, Add, Edit, x6 y6 w200 hwndhEdit1, % Edit1_Content
	}

}

GuiControl, Move, vTab, % "y" TabY " h" TabHeight " w" A_GuiWidth-10
Gui, Show
return
teadrinker
Posts: 4309
Joined: 29 Mar 2015, 09:41
Contact:

Re: Gui Tabs - move a gui control to another tab

Post by teadrinker » 22 Jul 2021, 18:56

Try this option:

Code: Select all

Gui, Main: New, +Resize
Gui, Margin, 10, 10
Gui, Add, Tab3, vTab gTab y50 w300 h200, 1|2|3
Gui, Child: New, +ParentMain -Caption +ToolWindow
Gui, Margin, 0, 0
Gui, Add, Edit, w135, Edit1
Gui, Add, Edit, x+10 yp w135, Edit2
Gui, Show, NA x20 y15
Gui, Main:Show
Return

MainGuiSize(GuiHwnd, EventInfo, Width, Height) {
   static GW_HWNDNEXT := 2, hParent := 0, toggle := "out"
   if !hParent {
      GuiControlGet, hTab, Hwnd, Tab
      hParent := DllCall("GetWindow", "Ptr", hTab, "UInt", GW_HWNDNEXT, "Ptr")
   }
   GuiControl, Move, Tab, % "w" . (Width <= 320 ? 300 : Width - 20)
                         . " h" . (Height <= 250 ? Height - 20 : Height - 60)
                         
   if (toggle = "out" && Height <= 250) {
      toggle := "in"
      GuiControl,, Tab, |1|2|3|4
      GuiControl, Move, Tab, y10
      Gui, Child: Color, White
      Gui, Child: +Parent%hParent%
      Gui, Child: Show, Hide x7 y10
   }                 
   if (toggle = "in" && Height > 250) {
      toggle := "out"
      GuiControl,, Tab, |1|2|3
      GuiControl, Move, Tab, y50
      Gui, Child: Color, Default
      Gui, Child: +ParentMain
      Gui, Child: Show, NA x20 y15
   }
}

Tab() {
   GuiControlGet, Tab
   if (Tab = 4)
      Gui, Child: Show, NA
   else {
      GuiControlGet, hTab, Hwnd, Tab
      SendMessage, TCM_GETITEMCOUNT := 0x1304,,,, ahk_id %hTab%
      if (ErrorLevel = 4)
         Gui, Child: Hide
   }
}

MainGuiClose() {
   ExitApp
}
AHK_user
Posts: 515
Joined: 04 Dec 2015, 14:52
Location: Belgium

Re: Gui Tabs - move a gui control to another tab

Post by AHK_user » 22 Jul 2021, 23:36

teadrinker wrote:
22 Jul 2021, 18:56
Try this option:

Code: Select all

Gui, Main: New, +Resize
Gui, Margin, 10, 10
Gui, Add, Tab3, vTab gTab y50 w300 h200, 1|2|3
Gui, Child: New, +ParentMain -Caption +ToolWindow
Gui, Margin, 0, 0
Gui, Add, Edit, w135, Edit1
Gui, Add, Edit, x+10 yp w135, Edit2
Gui, Show, NA x20 y15
Gui, Main:Show
Return

MainGuiSize(GuiHwnd, EventInfo, Width, Height) {
   static GW_HWNDNEXT := 2, hParent := 0, toggle := "out"
   if !hParent {
      GuiControlGet, hTab, Hwnd, Tab
      hParent := DllCall("GetWindow", "Ptr", hTab, "UInt", GW_HWNDNEXT, "Ptr")
   }
   GuiControl, Move, Tab, % "w" . (Width <= 320 ? 300 : Width - 20)
                         . " h" . (Height <= 250 ? Height - 20 : Height - 60)
                         
   if (toggle = "out" && Height <= 250) {
      toggle := "in"
      GuiControl,, Tab, |1|2|3|4
      GuiControl, Move, Tab, y10
      Gui, Child: Color, White
      Gui, Child: +Parent%hParent%
      Gui, Child: Show, Hide x7 y10
   }                 
   if (toggle = "in" && Height > 250) {
      toggle := "out"
      GuiControl,, Tab, |1|2|3
      GuiControl, Move, Tab, y50
      Gui, Child: Color, Default
      Gui, Child: +ParentMain
      Gui, Child: Show, NA x20 y15
   }
}

Tab() {
   GuiControlGet, Tab
   if (Tab = 4)
      Gui, Child: Show, NA
   else {
      GuiControlGet, hTab, Hwnd, Tab
      SendMessage, TCM_GETITEMCOUNT := 0x1304,,,, ahk_id %hTab%
      if (ErrorLevel = 4)
         Gui, Child: Hide
   }
}

MainGuiClose() {
   ExitApp
}
Also an ingenious method to create an invisible gui on top of the main. Works perfect! I like the way the focus cursor stays the same and you can move all the controls at once, it even lets you type into the controls if they are not visible :lol: . And this way you could use the v option without a problem.

:think: I will probably go in the destroy method in the end and accept not been able to use the v option, but a global variable that holds the hwnd. Having to write the handler of the tab control seems a to big disadvantage if your gui has a lot of controls that needs to be moving.

If I find some time, I`ll post a new function that lets you copy the content of the control, destroys it and redraws it with new options.
AHK_user
Posts: 515
Joined: 04 Dec 2015, 14:52
Location: Belgium

Re: Gui Tabs - move a gui control to another tab

Post by AHK_user » 23 Jul 2021, 17:36

I tumbled upon another problem when I tried to create a function to redraw every control.
When I tried to read or destroy the dropdownlist, it does not seem to work, because probably the dropdownlist is a combination of multiple controls.

I already managed to do the following controls: Edit, Button, Listview (the functions are not finisched yet, I want just one function that automatically detects the type and the size and also copies this, if no new size is given). The Listview works already quite good, it copies the content, columnsize and the selection (if only one line selected). I commented the Listview commands out, so you can test it if you want.

I could not get the list of the dropdownlist without the v variable, and destroying this control is apparently also difficult. Does anybody has some experience with this?

Code: Select all

#SingleInstance Force

Gui, +Resize
oGui := {}
Gui, Add, DropDownList, hwndhDDL1, row1|row2|Row3
;~ Gui, Add, Button, ggButton hwndhButton, Test
;~ Gui, Add, Edit, x6 y6 w200 hwndhEdit1, test
;~ Gui, Add, ListView, r3 hwndhLV1, col1|col2
LV_Add(, "Field1", "Field2")
LV_Add(, "Field15", "Field3")
LV_Add(, "Field25", "Field4")
LV_Add(, "Field35", "Field5")
Gui, Add, Tab3, vvTab, 1|2|3|4
Gui, Tab, 4
Gui, +hwndhGuiTest
Gui, Show, W300 H300 
return

GuiSize:
DllCall("LockWindowUpdate", Uint,hGuiTest)
TabHeight := A_GuiHeight - 110

if (A_GuiHeight<200){
	if (TaBY!=4){
		TabY:=4
		
		GuiControlGet, SelectedTab, , vTab
		GuiControl, , vTab, |1|2|3|4
		GuiControl, Choose, vTab,  % SelectedTab
		
		Gui, Tab, 4
		hDDL1 :=GuiRedrawDDL(hDDL1, "x15 y140")
		;~ hbutton:=GuiRedrawButton(hbutton, "ggButton")
		;~ hEdit1:=GuiRedraw(hEdit1, "x10 y60 w200")
		;~ hLV1:=GuiRedrawLV(hLV1, "x15 y140 r3")
		Gui, Tab
	}
	TabHeight+=96
}
else{
	if (TabY!=30){
		TabY:=100
		GuiControlGet, SelectedTab, , vTab
		GuiControl, , vTab, |1|2|3
		GuiControl, Choose, vTab,  % SelectedTab
		
		Gui, Tab
		hDDL1 :=GuiRedrawDDL(hDDL1, "x6 y6")
		;~ hbutton:=GuiRedrawButton(hbutton, "ggButton x6 y6")
		;~ hEdit1:=GuiRedraw(hEdit1, "x6 y6 w200")
		;~ hLV1:=GuiRedrawLV(hLV1, "x6 y6 r3")
	}
}

GuiControl, Move, vTab, % "y" TabY " h" TabHeight " w" A_GuiWidth-20
;Enable updating of gui
DllCall("LockWindowUpdate", Uint, 0)
Gui, Show
return

GuiRedrawEdit(ControlID, Options){
	; works
	GuiControlGet, Control_Content, , % ControlID
	DllCall("DestroyWindow", "UInt", ControlID)
	Gui, Add, Edit, % options  " hwndControlID", % Control_Content
	return ControlID
}

GuiRedrawButton(ControlID, Options){
	; works
	
	GuiControlGet, Control_Content, , % ControlID
	DllCall("DestroyWindow", "UInt", ControlID)
	Gui, Add, Button, % options  " hwndControlID", % Control_Content
	return ControlID
}

GuiRedrawDDL(ControlID, Options :=""){
	; does not work
	WinGetClass, controlClass, ahk_id %ControlID%
	GuiControlGet, Control_List, List , % ControlID
	;Seems to fail
	MsgBox, % Control_List
	GuiControlGet, Control_Content, , % ControlID
	DllCall("DestroyWindow", "UInt", ControlID)
	Gui, Add, DropDownList, % options  " hwndControlID", % StrReplace(DDLList, "`n", "|")
	return ControlID
}

GuiRedrawLV(ControlID, Options){
	; works, copies content and selection
	WinGetClass, controlClass, ahk_id %ControlID%
	Control_Content:=""
	Number_Col := LV_GetCount("Col")
	Number_Rows := LV_GetCount()
	SelectedRow:=LV_GetNext()

	loop, % Number_Col{
		LV_GetText(RetrievedText,0, A_Index)
		Control_Content .= Control_Content="" ? RetrievedText : "|" RetrievedText
	}
	RowWidth:={}
	Loop % Number_Col	{
		SendMessage, 0x101D, A_Index -1, 0, % controlClass "1"    ; 0x101D is LVM_GETCOLUMNWIDTH.
		RowWidth[A_Index]:= ErrorLevel
	}

	Control_List := 
	Loop % Number_Rows
	{
		Row := A_Index
		Line_content :=""
		loop, % Number_Col{
			LV_GetText(RetrievedText,Row, A_Index)
			Line_content .= Line_content="" ? RetrievedText : "`t" RetrievedText
		}
		Control_List .= Control_List="" ? Line_content : "`n" Line_content
	}
	
	DllCall("DestroyWindow", "UInt", ControlID)
	Gui, Add, ListView, % options  " hwndControlID", % Control_Content
	GuiControl, -Redraw, % ControlID
	Loop, Parse, Control_List, `n
	{
		oLine := StrSplit(A_LoopField, "`t")
		LV_Add(,oLine* )
	}
	Loop, % Number_Col
	{
		if (RowWidth[A_Index]!= "Fail"){
			LV_ModifyCol(A_Index, RowWidth[A_Index])
		}
	}
	if (SelectedRow!=0){
		LV_Modify(SelectedRow, "Select")
	}
	GuiControl, +Redraw, % ControlID
	return ControlID
}

gButton:
;~ DebugWindow("test`n",Clear:=0)
MsgBox, test
return
teadrinker
Posts: 4309
Joined: 29 Mar 2015, 09:41
Contact:

Re: Gui Tabs - move a gui control to another tab

Post by teadrinker » 23 Jul 2021, 18:08

I'd use my variant with one child GUI. It's a weird idea to destroy and recreate a lot of controls.
AHK_user
Posts: 515
Joined: 04 Dec 2015, 14:52
Location: Belgium

Re: Gui Tabs - move a gui control to another tab

Post by AHK_user » 24 Jul 2021, 05:27

teadrinker wrote:
23 Jul 2021, 18:08
I'd use my variant with one child GUI. It's a weird idea to destroy and recreate a lot of controls.
Indeed, if destroying and recreating the controls again and again does not work stable, it seems better and faster working to use the Child Gui, or alternative duplicate controls that mirror their content and show/hide when a resize event occurs.
Post Reply

Return to “Ask for Help (v1)”