<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: классы]]></title>
	<link rel="self" href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=12913&amp;type=atom" />
	<updated>2017-08-29T09:10:09Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=12913</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: классы]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=118909#p118909" />
			<content type="html"><![CDATA[<p>Там имя класса прописывается, мне это не нравится. Типа если захотел поменять имя, то чтобы лезть больше никуда не надо. В 28 есть решение, также переделал часы из коллекции.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2017-08-29T09:10:09Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=118909#p118909</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: классы]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=118908#p118908" />
			<content type="html"><![CDATA[<p>Ну а если там и прописать? Вот так ведь вроде работает.<br /></p><div class="codebox"><pre><code>
m1 := new ClassName(&quot;Привет!&quot;, 300)
m2 := new ClassName(&quot;Пока!&quot;, 600) 
ToolTip % m1.arr[1] &quot;`n&quot; m2.arr[1]
Return

Class ClassName
{
   static arr := [], var := OnMessage(WM_LBUTTONDOWN := 0x201, ObjBindMethod(ClassName, &quot;OnButtonDown&quot;))
   __New(key, x) {
      Gui, New, +hwndhGui
      Gui, Show, x%x% w222 h222
      this.arr[1] := key
   }
   OnButtonDown(wp, lp, msg, hwnd) {
      MsgBox % this.arr[1] . &quot;`n&quot; . hwnd
   }
}
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[YMP]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=81</uri>
			</author>
			<updated>2017-08-29T08:16:22Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=118908#p118908</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: классы]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=118907#p118907" />
			<content type="html"><![CDATA[<p>Так лучше наверное нигде. В классе должно быть такое.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2017-08-29T07:40:12Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=118907#p118907</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: классы]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=118906#p118906" />
			<content type="html"><![CDATA[<p>А где ему придётся это прописывать?</p>]]></content>
			<author>
				<name><![CDATA[YMP]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=81</uri>
			</author>
			<updated>2017-08-29T07:05:51Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=118906#p118906</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: классы]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=118905#p118905" />
			<content type="html"><![CDATA[<p>Согласись не красиво,&nbsp; предоставляя класс,&nbsp; объснять пользователю что ему надо (в моем случае) прописывать еще 5 замысловатых строк.<br /></p><div class="codebox"><pre><code>		OnMessage(This.WM_LBUTTONDOWN, ObjBindMethod(Class, &quot;OnButtonDown&quot;))
		OnMessage(This.WM_LBUTTONDBLCLK, ObjBindMethod(Class, &quot;OnButtonDown&quot;))
		OnMessage(This.WM_RBUTTONDOWN, ObjBindMethod(Class, &quot;OnButtonDown&quot;))
		OnMessage(This.WM_RBUTTONDBLCLK, ObjBindMethod(Class, &quot;OnButtonDown&quot;))
		OnMessage(This.WM_MOUSEWHEEL, ObjBindMethod(Class, &quot;OnMouseWheel&quot;))</code></pre></div>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2017-08-29T01:13:32Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=118905#p118905</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: классы]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=118904#p118904" />
			<content type="html"><![CDATA[<p>С одним OnMessage:<br /></p><div class="codebox"><pre><code>m1 := new ClassName(&quot;Привет!&quot;, 300)
m2 := new ClassName(&quot;Пока!&quot;, 600) 
ToolTip % m1.arr[1] &quot;`n&quot; m2.arr[1]
OnMessage(WM_LBUTTONDOWN := 0x201, ObjBindMethod(ClassName, &quot;OnButtonDown&quot;))
Return

Class ClassName
{
   static arr := []
   __New(key, x) {
      Gui, New, +hwndhGui
      Gui, Show, x%x% w222 h222
      this.arr[1] := key
   }
   OnButtonDown(wp, lp, msg, hwnd) {
      MsgBox % this.arr[1]
   }
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2017-08-29T01:00:55Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=118904#p118904</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: классы]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=118903#p118903" />
			<content type="html"><![CDATA[<p>Формулировки честно говоря не было, от одного вопроса плавно перешли к другому. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /><br />С A_Gui лучше, а то в hwnd контрол может быть. Спасибо, сам недогадался, способ хороший, если сообщение требует привязки к конкретному окну. В моём случае это тоже требуется, но всё же не нравится дёргать OnProc по несколько раз при каждом клике или движении колёсика. При 10 окнах, 10 кликов вызовут очередь из 100 сообщений. Пока остановлюсь на своём решении передачи самого класса с одним OnMessage.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2017-08-29T00:51:08Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=118903#p118903</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: классы]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=118902#p118902" />
			<content type="html"><![CDATA[<p>А лучше даже так:<br /></p><div class="codebox"><pre><code>m1 := new ClassName(&quot;Привет!&quot;, 300)
m2 := new ClassName(&quot;Пока!&quot;, 600) 
ToolTip % m1.arr[1] &quot;`n&quot; m2.arr[1]
Return

Class ClassName
{
   static arr := []
   __New(key, x) {
      Gui, New, +hwndhGui
      Gui, Show, x%x% w222 h222
      this.arr[1] := key
      OnMessage(WM_LBUTTONDOWN := 0x201, ObjBindMethod(this, &quot;OnButtonDown&quot;, hGui))
   }
   OnButtonDown(hGui, wp, lp, msg, hwnd) {
      if (hGui = A_Gui)
         MsgBox % this.arr[1]
   }
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2017-08-29T00:36:02Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=118902#p118902</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: классы]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=118901#p118901" />
			<content type="html"><![CDATA[<p>Так ты зададачу не можешь чётко сформулировать. </p><div class="quotebox"><cite>serzh82saratov пишет:</cite><blockquote><p>каждый экземпляр это новое окно</p></blockquote></div><p>Ну а у тебя </p><div class="codebox"><pre><code>Gui, Show, w222 h222</code></pre></div><p>Подразумевается, что это одно и то же окно Gui, 1:. Если это разные окна, их нужно создавать</p><div class="codebox"><pre><code>Gui, New, +hwndhGui</code></pre></div><p>А потом, чтобы не было лишних срабатываний OnMessage, проверять параметр hwnd:<br /></p><div class="codebox"><pre><code>m1 := new ClassName(&quot;Привет!&quot;, 300)
m2 := new ClassName(&quot;Пока!&quot;, 600) 
ToolTip % m1.arr[1] &quot;`n&quot; m2.arr[1]
Return

Class ClassName
{
   static arr := []
   __New(key, x) {
      Gui, New, +hwndhGui
      Gui, Show, x%x% w222 h222
      this.arr[1] := key
      OnMessage(WM_LBUTTONDOWN := 0x201, ObjBindMethod(this, &quot;OnButtonDown&quot;, hGui))
   }
   OnButtonDown(hGui, wp, lp, msg, hwnd) {
      if (hGui = hwnd)
         MsgBox % this.arr[1]
   }
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2017-08-29T00:29:10Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=118901#p118901</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: классы]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=118900#p118900" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>serzh82saratov пишет:</cite><blockquote><p>Думаю надо писать то, что необходимо для конкретного функционала.</p></blockquote></div><div class="quotebox"><cite>serzh82saratov пишет:</cite><blockquote><p>А зачем мне такая функция, если нет доступа к нужным мне данным?</p></blockquote></div><p>Мне собственно изначально надо было внутри класса, так как речь идёт про как бы общий массив используемый в классе, и если что то написано вопреки тезису - &quot;иметь отношение ко всем экземплярам объектов&quot; то я просто варвар. Хотя - массив общий для всех экземпляров, вроде ему соответсвует.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2017-08-29T00:26:11Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=118900#p118900</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: классы]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=118899#p118899" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Ну так а откуда в функции за пределами класса возьмётся this?</p></blockquote></div><p>А зачем мне такая функция, если нет доступа к нужным мне данным?</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2017-08-29T00:14:24Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=118899#p118899</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: классы]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=118898#p118898" />
			<content type="html"><![CDATA[<p>Я тебе пытался привести как пример часы. В моём случае, или в других подобных, каждый экземпляр это новое окно (был пример и с двумя окнами п.34), создали окна, потом понадобилось какое то удалить, естественно удаляем вместе с экземпляром.</p><div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Нет, внутри конструктора имеет смысл писать то, что будет иметь отношение ко всем экземплярам объектов.</p></blockquote></div><p>Думаю надо писать то, что необходимо для конкретного функционала.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2017-08-29T00:13:27Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=118898#p118898</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: классы]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=118897#p118897" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>serzh82saratov пишет:</cite><blockquote><p>Тогда пусто.</p></blockquote></div><p>Ну так а откуда в функции за пределами класса возьмётся this?</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2017-08-29T00:07:05Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=118897#p118897</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: классы]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=118896#p118896" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>serzh82saratov пишет:</cite><blockquote><p>Так если я потом этот объект (экземпляр) удалю, я сообщения перестану получать.</p></blockquote></div><p>Этого не понял, зачем тогда вообще его создавать?<br /></p><div class="quotebox"><cite>serzh82saratov пишет:</cite><blockquote><p>Если пишешь класс, то как то не по фен шую что то выводить за его пределы</p></blockquote></div><p>Нет, внутри конструктора имеет смысл писать то, что будет иметь отношение ко всем экземплярам объектов. Вообще в принципе нелогично писать внутри метода __New </p><div class="codebox"><pre><code>Gui, Show, w222 h222</code></pre></div><p>если в реальности нужно только одно окно, а объектов может быть много. Получается, что команда Show выполняется всякий раз, как создаётся новый объект. А какой в этом смысл?</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2017-08-29T00:00:57Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=118896#p118896</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: классы]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=118895#p118895" />
			<content type="html"><![CDATA[<p>Тогда пусто.<br /></p><div class="codebox"><pre><code>m1 := new ClassName(&quot;Привет!&quot;)
m2 := new ClassName(&quot;Пока!&quot;) 
m1.Destroy()
ToolTip % m1.arr[1] &quot;`n&quot; m2.arr[1]
Return

Class ClassName
{
   static arr := [], var := OnMessage(WM_LBUTTONDOWN := 0x201, &quot;OnButtonDown&quot;)
   __New(key) {
      Gui, Show, w222 h222
      this.arr[1] := key
   }
   OnButtonDown(wp, lp, msg, hwnd) {
      MsgBox % this.arr[1]
   }
      Destroy() {   
      This.Base := &quot;&quot;
   }
}

OnButtonDown()  {
   MsgBox % this.arr[1]
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2017-08-28T23:56:17Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=118895#p118895</id>
		</entry>
</feed>
