<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: GUI динамическое задание контролов и их обработка]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=10409</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=10409&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: GUI динамическое задание контролов и их обработка».]]></description>
		<lastBuildDate>Sun, 15 Feb 2015 04:36:49 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: GUI динамическое задание контролов и их обработка]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=91575#p91575</link>
			<description><![CDATA[<p>Ещё, раз спасибо - возникнут вопросы по этой теме, тогда я напишу.</p>]]></description>
			<author><![CDATA[null@example.com (Indomito)]]></author>
			<pubDate>Sun, 15 Feb 2015 04:36:49 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=91575#p91575</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: GUI динамическое задание контролов и их обработка]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=91574#p91574</link>
			<description><![CDATA[<p>Конечно, потребуется, а где он не требуется? Другое дело, что никакого значения он вернуть не может.</p>]]></description>
			<author><![CDATA[null@example.com (YMP)]]></author>
			<pubDate>Sun, 15 Feb 2015 04:08:47 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=91574#p91574</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: GUI динамическое задание контролов и их обработка]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=91566#p91566</link>
			<description><![CDATA[<p>Спасибо за идею. <img src="//forum.script-coding.com/img/smilies/wink.png" width="15" height="15" /></p><p>А разве, префикс <strong>g</strong> не говорит что это подпрограмма, т.е. аналог <strong>Gosub Cancel</strong>, т.е.&nbsp; потребуется <strong>Return</strong>?</p>]]></description>
			<author><![CDATA[null@example.com (Indomito)]]></author>
			<pubDate>Sat, 14 Feb 2015 17:17:11 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=91566#p91566</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: GUI динамическое задание контролов и их обработка]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=91565#p91565</link>
			<description><![CDATA[<p>Метка обработчика кнопки ведь не обязана содержать имя этой кнопки. Почему так не сделать, например?<br /></p><div class="codebox"><pre><code>
Gui, Add, Button, section Default x+m gCancel, %ButCancel%

Cancel:
</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (YMP)]]></author>
			<pubDate>Sat, 14 Feb 2015 16:46:01 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=91565#p91565</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: GUI динамическое задание контролов и их обработка]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=91564#p91564</link>
			<description><![CDATA[<p>Нет, экранировать надо, чтобы они воспринимались как символы. Но здесь они уже так воспринимаются.</p>]]></description>
			<author><![CDATA[null@example.com (YMP)]]></author>
			<pubDate>Sat, 14 Feb 2015 16:37:52 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=91564#p91564</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: GUI динамическое задание контролов и их обработка]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=91563#p91563</link>
			<description><![CDATA[<p>Так их надо экранировать? Или есть другой метод?</p>]]></description>
			<author><![CDATA[null@example.com (Indomito)]]></author>
			<pubDate>Sat, 14 Feb 2015 16:30:18 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=91563#p91563</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: GUI динамическое задание контролов и их обработка]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=91562#p91562</link>
			<description><![CDATA[<p>Судя по несложным экспериментам, знаки процента в именах меток воспринимаются как простые символы, т.е. просто как часть имени метки. Не как обрамление переменной.</p>]]></description>
			<author><![CDATA[null@example.com (YMP)]]></author>
			<pubDate>Sat, 14 Feb 2015 16:26:19 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=91562#p91562</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: GUI динамическое задание контролов и их обработка]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=91561#p91561</link>
			<description><![CDATA[<p>Да, упустил, ища основную ошибку, придётся немного перестроить функцию.</p><p>А с метками то как быть?</p>]]></description>
			<author><![CDATA[null@example.com (Indomito)]]></author>
			<pubDate>Sat, 14 Feb 2015 16:18:35 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=91561#p91561</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: GUI динамическое задание контролов и их обработка]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=91560#p91560</link>
			<description><![CDATA[<p>Откуда же код возврата у процедуры? Это, батенька, ересь. <img src="//forum.script-coding.com/img/smilies/wink.png" width="15" height="15" /></p>]]></description>
			<author><![CDATA[null@example.com (YMP)]]></author>
			<pubDate>Sat, 14 Feb 2015 16:13:56 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=91560#p91560</guid>
		</item>
		<item>
			<title><![CDATA[AHK: GUI динамическое задание контролов и их обработка]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=91559#p91559</link>
			<description><![CDATA[<p>Я тут собрался написать свой MsgBox, но натолкнулся на проблемы.<br />После, фрагмента кода их опишу.<br /></p><div class="codebox"><pre><code>;************************************************************************************
;                         Начало описания функций
;************************************************************************************
;------------------Начало определения функции GMsgBox (Свой MsgBox)------------------
GMsgBox(i,TittleGMB,TextGMB
        ,DelayGMB := 30, ButtonKey := False, ButtonLng := 2
        ,SizeTextGMB := 12, ColorTextGMB := &quot;000000&quot;, FontTextGMB := &quot;Verdana&quot;
        ,SizeButnGMB := 10, ColorButnGMB := &quot;000000&quot;, FontButnGMB  := &quot;Verdana&quot;)
{
Global vDirGMB, arSoundIco, arNameBT, сMsgOptionsEr
  ; If ((BtOk || BtOkC || BtYN || BtYNC)&lt;0) Then Left-Most Else Right-Most
  Static BtNot := False, BtOk   := 1, BtOkC  := 2, BtYN   := 3, BtYNC  := 4
  Static retTimeOut := -1, retCancel := False, retOk := retYes := 1, retNo := 2, retESC  := 3, retCross  := 4, 
  
  Gosub lAllCheck ;Проверяем валидность входных данных, т.е. которые можем проверить - выход без условный при ошибке
  DelayGMB := Round(DelayGMB) ; Коррекция и установка времени задержки
  SoundGMB := arSoundIco[i,1]   ; Установка звукового сигнала
  PicGMB   := arSoundIco[i,2]   ; Установка титульной картинки
  
  ButOk      := arNameBT[ButtonLng,1] ; Имя кнопки ОК
  ButCancel  := arNameBT[ButtonLng,2] ; Имя кнопки Cancel
  ButYes     := arNameBT[ButtonLng,3] ; Имя кнопки Yes
  ButNo      := arNameBT[ButtonLng,4] ; Имя кнопки No
  
  If (ButtonKey &lt; 0)        ; Расчёт позиционировани кнопок
        posBT:= &quot;xm y+m&quot;          ; Слева
     Else
        posBT:= &quot;x+m y+m&quot;         ; Справа
        
  ButtonKey := Abs(ButtonKey)   ;Сброс значения кнопок в абсолютное значение
  
  Gosub lCreateGMB    ; Создание окна MsgBox со всеми требуемыми параметрами
  Gosub lWaitGMB      ; Тайм-Аут до закрытия окна, если не нажата кнопка
; Return  ret

lCreateGMB:
;--------------------
; Тут создание окна - проблем нет.
;--------------------

; Задание кнопок по входным условиям - тоже проблем нет.
  If (ButtonKey = BtOk)
          Gui, Add, Button, section Default %posBT%, &amp;%ButOk%

    Else If (ButtonKey = BtOkC)
            {
              Gui, Add, Button, section Default %posBT%, &amp;%ButOk%
              Gui, Add, Button, section Default x+m , %ButCancel%
            }
    Else If (ButtonKey = BtYN)
            {
              Gui, Add, Button, section Default %posBT%, &amp;%ButYes%
              Gui, Add, Button, section Default x+m , %ButNo%
            }
    Else If (ButtonKey = BtYNC)
            {
              Gui, Add, Button, section Default %posBT%, &amp;%ButYes%
              Gui, Add, Button, section Default x+m , %ButNo%
              Gui, Add, Button, section Default x+m, %ButCancel%
            }
    Else
      {
       ;Ошибочный код, просто не выводим кнопки, эквивалент BtNot
      }
 
  Gui, Show, AutoSize Center
  SoundPlay %SoundGMB%
  fGMB := False
Return

; ----&gt; А вот тут, не работает, т.е. не работают обработчики, перепробовал все варианты - не получается.
Button%ButOk%:
  ret :=  retOk
Goto CloseGMB

Button%ButCancel%:
  ret :=  retCancel
Goto CloseGMB

Button%ButnYes%:
  ret :=  retYes
Goto CloseGMB

Button%ButNo%:
  ret :=  retNo
Goto CloseGMB

GuiEscape:
  ret :=  retESC
Goto CloseGMB

GuiClose:
  ret :=  retCross
Goto CloseGMB

lWaitGMB:
  Loop %DelayGMB% ; N секунд
    {
    If (fGMB)
          Break
    Sleep 1000
   }
  ret :=  retTimeOut
CloseGMB:
  fGMB := True
  Gui, Cancel
Return ret

;Подпрограмма валидности входных данных не привожу - в ней не должно быть проблем.
lAllCheck:
Return
}</code></pre></div><p>Дополнительно даю иниациализацию функции, только то что может быть связанно с ошибкой в скрипте.<br /></p><div class="codebox"><pre><code>  arNameBT  := [[&quot;OK&quot;,&quot;Cansel&quot;,&quot;Yes&quot;,&quot;No&quot;]
              ,[&quot;ОК&quot;,&quot;Отмена&quot;,&quot;Да&quot;,&quot;Нет&quot;]]

 ; Описание массива Звук + ICO для простоты вызова 
  cSoundBeep    := &quot;*-1&quot;      
  cIcoBackup    := &quot;Backup.png&quot;
  cSoundDone    := &quot;Done.wav&quot; 
  cIcoDone      := &quot;Done.png&quot;
  cSoundError   := &quot;*16&quot; 
  cIcoError     := &quot;Error.png&quot;
  cSoundQuest   := &quot;*32&quot; 
  cIcoQuest     := &quot;Question.png&quot;
  cSoundAlert  := &quot;*48&quot; 
  cIcoAlert    := &quot;Alert.png&quot;
  cSoundInfo    := &quot;*64&quot;
  cIcoInfo      := &quot;Info.png&quot;
  arSoundIco    := [[cSoundBeep,cIcoBackup]
                   ,[cSoundDone,cIcoDone]
                   ,[cSoundError,cIcoError]                   
                   ,[cSoundQuest,cIcoQuest]                   
                   ,[cSoundAlert,cIcoAlert]                   
                   ,[cSoundInfo,cIcoInfo]]</code></pre></div><p>И так, если сказать кратко, то не работают две вещи.</p><p><strong>Первое.</strong><br /></p><div class="codebox"><pre><code>
;----- Этот код(например)
              Gui, Add, Button, section Default %posBT%, &amp;%ButOk%
              Gui, Add, Button, section Default x+m , %ButCancel%

;-----Не доходит до обработчика/Не приходит к обработчи(ку)кам
Button%ButOk%:
  ret :=  retOk
Goto CloseGMB

Button%ButCancel%:
  ret :=  retCancel
Goto CloseGMB
</code></pre></div><p><strong>Второе.</strong><br /></p><div class="codebox"><pre><code>
;----- Нет кода возврата.
CloseGMB:
  fGMB := True
  Gui, Cancel
Return ret</code></pre></div><p>Я как понимаю писать, так <strong>Button%ButCancel%:</strong> нельзя, но как иначе я не нашёл.<br />Ну, а код возврата я найду... со временем.</p>]]></description>
			<author><![CDATA[null@example.com (Indomito)]]></author>
			<pubDate>Sat, 14 Feb 2015 16:00:57 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=91559#p91559</guid>
		</item>
	</channel>
</rss>
