<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Размещение метки "GuiClose" в теле функции.]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=11909</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=11909&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Размещение метки "GuiClose" в теле функции.».]]></description>
		<lastBuildDate>Mon, 15 Aug 2016 20:12:13 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Размещение метки "GuiClose" в теле функции.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=106815#p106815</link>
			<description><![CDATA[<p>Мой низкий поклон, господа!</p>]]></description>
			<author><![CDATA[null@example.com (KusochekDobra)]]></author>
			<pubDate>Mon, 15 Aug 2016 20:12:13 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=106815#p106815</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Размещение метки "GuiClose" в теле функции.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=106814#p106814</link>
			<description><![CDATA[<p>Да, каждое созданное окно GUI придётся перенаправлять на другую метку потока.<br /></p><div class="codebox"><pre><code>Gui 1:+LabelMy_Gui_Label
Gui 2:+LabelMy_Gui_Label
Gui 3:+LabelMy_Gui_Label

!1::Gui, 1:	Show, w100 h100
!2::Gui, 2:	Show, w200 h200
!3::Gui, 3:	Show, w300 h300

My_Gui_LabelClose:
Gui +HwndMy_Gui_Hwnd
Gui, %A_Gui%: Show, Hide
MsgBox,  GUI № %A_Gui% `r`n %My_Gui_Hwnd%
Return</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (ypppu)]]></author>
			<pubDate>Mon, 15 Aug 2016 20:07:06 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=106814#p106814</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Размещение метки "GuiClose" в теле функции.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=106813#p106813</link>
			<description><![CDATA[<div class="codebox"><pre><code>
Loop 12
{
	Gui, %A_Index%: +LabelMyGui -DPIScale +AlwaysOnTop
	Gui, %A_Index%: Add, Button, w80 gButton, % A_Index 
	Gui, %A_Index%: Show, % &quot;x&quot; 133 * (A_Index - 1), Gui %A_Index%
}
Return

MyGuiClose:
	Gui, %A_Gui%: Show, Hide
	MsgBox, , , % A_Gui, 0.3
	Return
	
Button:
	MsgBox % A_Gui
	Return
</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Mon, 15 Aug 2016 20:05:27 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=106813#p106813</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Размещение метки "GuiClose" в теле функции.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=106807#p106807</link>
			<description><![CDATA[<p>А как-то универсальней можно сделать запись? Например, если вдруг окажется, что сгенерированных таким способом окон с кнопками будет 20, или даже 30.</p>]]></description>
			<author><![CDATA[null@example.com (KusochekDobra)]]></author>
			<pubDate>Mon, 15 Aug 2016 15:52:04 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=106807#p106807</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Размещение метки "GuiClose" в теле функции.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=106798#p106798</link>
			<description><![CDATA[<div class="codebox"><pre><code>!1::Gui, 1: Show, w100 h100
!2::Gui, 2: Show, w200 h200
!3::Gui, 3: Show, w300 h300
return
GuiClose:
2GuiClose:
3GuiClose:
Gui, %A_Gui%: Show, Hide
MsgBox, % &quot;GUI № &quot; A_Gui
return</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (ypppu)]]></author>
			<pubDate>Mon, 15 Aug 2016 14:36:21 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=106798#p106798</guid>
		</item>
		<item>
			<title><![CDATA[AHK: Размещение метки "GuiClose" в теле функции.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=106788#p106788</link>
			<description><![CDATA[<p>Здоровья всем.<br />Понадобилось выполнять частый выбор из множества вариантов и чтобы для каждого варианта выбора не писать отдельный код, решил описать шаблон в функции:<br /></p><div class="codebox"><pre><code>
nmbrArr := [&quot;число1&quot;,&quot;число2&quot;,&quot;число3&quot;,&quot;число4&quot;,&quot;число5&quot;,&quot;чииислооо6&quot;]
abcArr := [&quot;one&quot;, &quot;two&quot;, &quot;three&quot;, &quot;four&quot;, &quot;fivewwwww&quot;]

CreateButton_list(nmbrArr, 1)
CreateButton_list(abcArr, 2)
CreateButton_list(nmbrArr, 3)

!1::Gui, 1: Show,, Числа 1
!2::Gui, 2: Show,, Слова 1
!3::Gui, 3: Show,, Числа 2

!q::MsgBox,, Title, % &quot;Имя -&gt; &quot; clickReturn &quot;`nВ GUI № -&gt; &quot; guiReturn &quot;`nКнопка номер -&gt; &quot; GetBttnNmbr(clickReturn, guiReturn)

CheckNmbrGUI(nmbr_GUI) {
	Static checkGUI
	if (checkGUI == &quot;&quot;)
		checkGUI := [-1]
	while (A_Index &lt;= checkGUI.Length()) {
		if (checkGUI[A_Index] == nmbr_GUI)
			return false
	}
	checkGUI.Push(nmbr_GUI)
	return true
}

CreateButton_list(workArr, nmbr_GUI) {
	if (CheckNmbrGUI(nmbr_GUI)) {
		
		Global allBttnNames
		if (allBttnNames == &quot;&quot;)
			allBttnNames := {}
		ObjRawSet(allBttnNames, nmbr_GUI, workArr)
			
		arrSize := workArr.Length()
		xBttn := 10
		yBttn := 10
		hBttn := 20
		
		bttnLen := 0
		while (A_Index &lt;= arrSize) {
			if (StrLen(workArr[A_Index]) &gt; bttnLen)
				bttnLen := StrLen(workArr[A_Index])
		}
		wBttn := bttnLen * 9
		Gui, %nmbr_GUI%: +AlwaysOnTop +Toolwindow
		colBttn := 1
		while (A_Index &lt;= arrSize) {
			if (colBttn == 20)
				colBttn := 1, xBttn := wBttn + 20, yBttn := 10
			Gui, %nmbr_GUI%: Add, Button, x%xBttn% y%yBttn% w%wBttn% h%hBttn%, % A_Index &quot; &quot; workArr[A_Index]
			yBttn += 22
			colBttn++
		}
		OnMessage(0x202, &quot;bttnClick&quot;)
		Return
		GuiClose:
			Gui, %A_Gui%: Show, Hide
			MsgBox,, Title, % &quot;GUI № &quot; A_Gui
		return
	} else {
		MsgBox,, Title, % &quot;GUI номер &#039;&quot; nmbr_GUI &quot;&#039; зарезервирован`nОсуществите вызов с другим параметром!`nПосле закрытия этого окна, приложение завершит работу.&quot;
		ExitApp
	}
}

bttnClick() {  
    Global clickReturn, guiReturn
	Static newCntrl
	if (newCntrl != A_GuiControl) {
		newCntrl := A_GuiControl
		ctrlNameArr := StrSplit(A_GuiControl, A_Space)
		clickReturn := ctrlNameArr[2]
		guiReturn := A_Gui
		Gui, %guiReturn%: Show, Hide
	} 
}

GetBttnNmbr(bttnName, GUInmbr) {
	Global allBttnNames
	arrSize := allBttnNames[GUInmbr].Length()
	while (A_Index &lt;= arrSize) {
		if (allBttnNames[GUInmbr][A_Index] == bttnName)
			return A_Index
	}
}
</code></pre></div><p>Результат кликов по кнопкам в сгенерированных GUI хранится в глобальных переменных, отследить который можно при изменении их содержимого, но если окно было закрыто крестиком, результат остаётся без изменений. Метка &quot;GuiClose&quot; работает только для первого созданного GUI. Есть ли альтернатива? Пробовал OnMessage(0x10, &quot;bttnClose&quot;), но реакции на закрытие крестиком нет. Подскажите пожалуйста.</p>]]></description>
			<author><![CDATA[null@example.com (KusochekDobra)]]></author>
			<pubDate>Mon, 15 Aug 2016 14:00:11 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=106788#p106788</guid>
		</item>
	</channel>
</rss>
