<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: GUI динамическое задание контролов и их обработка]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=10409&amp;type=atom" />
	<updated>2015-02-15T04:36:49Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=10409</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: GUI динамическое задание контролов и их обработка]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=91575#p91575" />
			<content type="html"><![CDATA[<p>Ещё, раз спасибо - возникнут вопросы по этой теме, тогда я напишу.</p>]]></content>
			<author>
				<name><![CDATA[Indomito]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27285</uri>
			</author>
			<updated>2015-02-15T04:36:49Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=91575#p91575</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: GUI динамическое задание контролов и их обработка]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=91574#p91574" />
			<content type="html"><![CDATA[<p>Конечно, потребуется, а где он не требуется? Другое дело, что никакого значения он вернуть не может.</p>]]></content>
			<author>
				<name><![CDATA[YMP]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=81</uri>
			</author>
			<updated>2015-02-15T04:08:47Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=91574#p91574</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: GUI динамическое задание контролов и их обработка]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=91566#p91566" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Indomito]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27285</uri>
			</author>
			<updated>2015-02-14T17:17:11Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=91566#p91566</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: GUI динамическое задание контролов и их обработка]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=91565#p91565" />
			<content type="html"><![CDATA[<p>Метка обработчика кнопки ведь не обязана содержать имя этой кнопки. Почему так не сделать, например?<br /></p><div class="codebox"><pre><code>
Gui, Add, Button, section Default x+m gCancel, %ButCancel%

Cancel:
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[YMP]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=81</uri>
			</author>
			<updated>2015-02-14T16:46:01Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=91565#p91565</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: GUI динамическое задание контролов и их обработка]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=91564#p91564" />
			<content type="html"><![CDATA[<p>Нет, экранировать надо, чтобы они воспринимались как символы. Но здесь они уже так воспринимаются.</p>]]></content>
			<author>
				<name><![CDATA[YMP]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=81</uri>
			</author>
			<updated>2015-02-14T16:37:52Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=91564#p91564</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: GUI динамическое задание контролов и их обработка]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=91563#p91563" />
			<content type="html"><![CDATA[<p>Так их надо экранировать? Или есть другой метод?</p>]]></content>
			<author>
				<name><![CDATA[Indomito]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27285</uri>
			</author>
			<updated>2015-02-14T16:30:18Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=91563#p91563</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: GUI динамическое задание контролов и их обработка]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=91562#p91562" />
			<content type="html"><![CDATA[<p>Судя по несложным экспериментам, знаки процента в именах меток воспринимаются как простые символы, т.е. просто как часть имени метки. Не как обрамление переменной.</p>]]></content>
			<author>
				<name><![CDATA[YMP]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=81</uri>
			</author>
			<updated>2015-02-14T16:26:19Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=91562#p91562</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: GUI динамическое задание контролов и их обработка]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=91561#p91561" />
			<content type="html"><![CDATA[<p>Да, упустил, ища основную ошибку, придётся немного перестроить функцию.</p><p>А с метками то как быть?</p>]]></content>
			<author>
				<name><![CDATA[Indomito]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27285</uri>
			</author>
			<updated>2015-02-14T16:18:35Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=91561#p91561</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: GUI динамическое задание контролов и их обработка]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=91560#p91560" />
			<content type="html"><![CDATA[<p>Откуда же код возврата у процедуры? Это, батенька, ересь. <img src="//forum.script-coding.com/img/smilies/wink.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[YMP]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=81</uri>
			</author>
			<updated>2015-02-14T16:13:56Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=91560#p91560</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: GUI динамическое задание контролов и их обработка]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=91559#p91559" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Indomito]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27285</uri>
			</author>
			<updated>2015-02-14T16:00:57Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=91559#p91559</id>
		</entry>
</feed>
