<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: ListView. Взаимодействие из других потоков.]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=12292&amp;type=atom" />
	<updated>2017-01-08T15:58:49Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=12292</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: ListView. Взаимодействие из других потоков.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=110697#p110697" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>
#Persistent
#SingleInstance, Force

myTableArr:=[[&quot;Name&quot;,&quot;ID&quot;,&quot;Date&quot;,&quot;Other data&quot;]
			,[&quot;Name1&quot;,&quot;001&quot;,&quot;01.01.2017&quot;,&quot;Some data1&quot;]
			,[&quot;Name2&quot;,&quot;002&quot;,&quot;01.01.2017&quot;,&quot;Some data2&quot;]
			,[&quot;Name3&quot;,&quot;003&quot;,&quot;01.01.2017&quot;,&quot;Some data3&quot;]
			,[&quot;Name4&quot;,&quot;004&quot;,&quot;01.01.2017&quot;,&quot;Some data4&quot;]]
			
Gui, Add,Button,gS_table,ShowTable
Gui, Add,Button,x+10 gI_data,InsData
Gui, Show,y750,Main

Gui, 10: Default
Gui, 10: Add, ListView,w500 h200 vLVval
Gui, 10: Add,Button,y+10 gI_data,InsData
Gui, 10: Show,Hide,Table

Menu,MyContextMenu,Add,Изменить ID,TheEdit
Menu,MyContextMenu,Add,Удалить,DelData
Menu,MyContextMenu,Add,Копировать Имя,CopyName
return
GuiClose:
	ExitApp

S_table:
	Gui, 10: Show
return
I_data:
	ReCreateTable(myTableArr)
return

10GuiContextMenu:
	if (A_GuiControl!=&quot;LVval&quot;)
		return
	newRowNmbr:=A_EventInfo+1
	if (newRowNmbr&gt;1) {
		LVname:=myTableArr[newRowNmbr][1]
		LV_Modify(newRowNmbr-1, &quot;-Focus&quot;)
		Menu, MyContextMenu, Show, %A_GuiX%, %A_GuiY%
	}
return
CopyName:
	Clipboard:=LVname
	MsgBox,, Title, %Clipboard%
return
TheEdit:
	if (newRowNmbr&gt;1) {
		if (editIDWin) {
			Gui, 50: Show
			ControlSetText,Edit1,% myTableArr[newRowNmbr][2],ahk_id%hEdit% 
		} else {
			editIDWin:=1
			Gui, 50: +AlwaysOnTop +ToolWindow +HWNDhEdit
			Gui, 50: Add,Edit,w100 vChangeEdit,% myTableArr[newRowNmbr][2]
			Gui, 50: Add,Button,y+3 h18 gEditChange,Изменить
			Gui, 50: Add,Button,x+5 h18 gNoEdit,Отмена
			Gui, 50: Show, ,Изменить 
		} 
	}
return
50GuiClose:
NoEdit:
	Gui, 50: Show, Hide
return
EditChange:
	Gui, 50: Submit 
	myTableArr[newRowNmbr][2]:=ChangeEdit 
	Gui, 10:Default
	LV_Modify(newRowNmbr - 1,&quot;Col2&quot;,ChangeEdit), LV_ModifyCol()
return

DelData: 
	if (newRowNmbr&gt;1) { 
		myTableArr.RemoveAt(newRowNmbr) 
		ReCreateTable(myTableArr)
	}
return

ReCreateTable(tableArr) { 
	Gui, 10:Default
	GuiControl, -ReDraw, LVval
	LV_Delete()
	Loop, % LV_GetCount(&quot;Column&quot;)
		LV_DeleteCol(1)
	Loop,% tableArr[1].Length()
		LV_InsertCol(A_Index,&quot;&quot;, tableArr[1][A_Index])
	Loop,% tableArr.Length()-1 {
		rNmbr := LV_Add(&quot;&quot;, &quot;&quot;)
		Loop,% tableArr[rNmbr+1].Length()
			LV_Modify(rNmbr, &quot;Col&quot; . A_Index, tableArr[rNmbr+1][A_Index])
	}
	Loop, % tableArr[1].Length()
		LV_ModifyCol(A_Index, &quot;AutoHdr&quot;)
	GuiControl, +ReDraw, LVval
} 

 </code></pre></div>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2017-01-08T15:58:49Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=110697#p110697</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: ListView. Взаимодействие из других потоков.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=110696#p110696" />
			<content type="html"><![CDATA[<p>Всем доброго здоровья и с прошедшими праздниками!<br /></p><div class="codebox"><pre><code>
myTableArr:=[[&quot;Name&quot;,&quot;ID&quot;,&quot;Date&quot;,&quot;Other data&quot;]
			,[&quot;Name1&quot;,&quot;001&quot;,&quot;01.01.2017&quot;,&quot;Some data1&quot;]
			,[&quot;Name2&quot;,&quot;002&quot;,&quot;01.01.2017&quot;,&quot;Some data2&quot;]
			,[&quot;Name3&quot;,&quot;003&quot;,&quot;01.01.2017&quot;,&quot;Some data3&quot;]
			,[&quot;Name4&quot;,&quot;004&quot;,&quot;01.01.2017&quot;,&quot;Some data4&quot;]]
			
Gui, Add,Button,gS_table,ShowTable
Gui, Add,Button,x+10 gI_data,InsData
Gui, Show,y750,Main

Gui, 10: Default
Gui, 10: Add, ListView,w500 h200 vLVval
Gui, 10: Add,Button,y+10 gI_data,InsData
Gui, 10: Show,Hide,Table

Menu,MyContextMenu,Add,Изменить ID,TheEdit
Menu,MyContextMenu,Add,Удалить,DelData
Menu,MyContextMenu,Add,Копировать Имя,CopyName
return
GuiClose:
	ExitApp

S_table:
	Gui, 10: Show
return
I_data:
	ReCreateTable(myTableArr)
return
10GuiContextMenu:
	if (A_GuiControl!=&quot;LVval&quot;)
		return
	newRowNmbr:=A_EventInfo+1
	if (newRowNmbr&gt;1) {
		LVname:=myTableArr[newRowNmbr][1]
		LV_Modify(newRowNmbr-1, &quot;-Focus&quot;)
		Menu, MyContextMenu, Show, %A_GuiX%, %A_GuiY%
	}
return
CopyName:
	Clipboard:=LVname
	MsgBox,, Title, %Clipboard%
return
TheEdit:
	if (newRowNmbr&gt;1) {
		if (editIDWin) {
			Gui, 50: Show
			ControlSetText,Edit1,% myTableArr[newRowNmbr][2],ahk_id%hEdit%
		} else {
			editIDWin:=1
			Gui, 50: +AlwaysOnTop +ToolWindow +HWNDhEdit
			Gui, 50: Add,Edit,w100 vChangeEdit,% myTableArr[newRowNmbr][2]
			Gui, 50: Add,Button,y+3 h18 gEditChange,Изменить
			Gui, 50: Add,Button,x+5 h18 gNoEdit,Отмена
			Gui, 50: Show,,Изменить
		}
	}
return
50GuiClose:
NoEdit:
	Gui, 50: Show, Hide
return
EditChange:
	Gui, 50: Submit
	myTableArr[newRowNmbr][2]:=ChangeEdit
	LV_Modify(newRowNmbr,&quot;Col2&quot;,ChangeEdit)
return
DelData:
	if (newRowNmbr&gt;1) {
		myTableArr.RemoveAt(newRowNmbr)
		ReCreateTable(myTableArr)
	}
return
ReCreateTable(tableArr) {
	Global
	GuiControl, -ReDraw, LVval
	LV_Delete()
	Loop, % LV_GetCount(&quot;Column&quot;)
		LV_DeleteCol(1)
	Loop,% tableArr[1].Length()
		LV_InsertCol(A_Index,&quot;&quot;, tableArr[1][A_Index])
	Loop,% tableArr.Length()-1 {
		rNmbr := LV_Add(&quot;&quot;, &quot;&quot;)
		Loop,% tableArr[rNmbr+1].Length()
			LV_Modify(rNmbr, &quot;Col&quot; . A_Index, tableArr[rNmbr+1][A_Index])
	}
	Loop, % tableArr[1].Length()
		LV_ModifyCol(A_Index, &quot;AutoHdr&quot;)
	GuiControl, +ReDraw, LVval
}
</code></pre></div><p>Подскажите пожалуйста, как можно вежливо попросить кнопку &quot;InsData&quot; в окне &quot;Main&quot;, приводить к аналогичному результату работы одноимённой кнопки в окне &quot;Table&quot;? Подпрограмму &quot;EditChange&quot;, обновлять содержимое ячейки функцией &quot;LV_Modify&quot;? Подпрограмму &quot;DelData&quot; обновлять таблицу после удаления из неё данных?<br />Всё время приходится тыкать &quot;InsData&quot; в окне &quot;Table&quot;, чтобы произошедшие изменения отобразились визуально. =/</p>]]></content>
			<author>
				<name><![CDATA[KusochekDobra]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33846</uri>
			</author>
			<updated>2017-01-08T15:27:59Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=110696#p110696</id>
		</entry>
</feed>
