<?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=11024</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=11024&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Автоподстройка высоты окна GUI под содержимое».]]></description>
		<lastBuildDate>Thu, 22 Oct 2015 23:55:52 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Автоподстройка высоты окна GUI под содержимое]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=98103#p98103</link>
			<description><![CDATA[<p>Да и тут:</p><div class="codebox"><pre><code>gui, show, w400 autosize</code></pre></div><p>w400 ничего не даёт, ведь действует autosize.</p><p>В общих случаях как то так:<br /></p><div class="codebox"><pre><code>
col = navy
font = Calibri

sender1 = Джубадзе
sender2 = Меладзе
sender3 = Орджоникидзе

text1 = В чащах юга жил был кактус, но фальшивый экземпляр. Слово экземпляр и этот текст уже не отображаются.`n|
text2 = Только что методом научного тыка (guicontrol, move, m, h200) выяснил, что сам по себе текст на следующую строку переносится, проблема только в том, что не ресайзится окно, не подстраивается под текст.`n|
text3 = В чащах юга жил был кактус`n|

gui, Margin, 88
gui, font, s14 c%col%, %font%
gui, add, text, w380 center hwndhtext
gui, add, button, default vbutton, |    |    | 
gosub Move

Loop {
    Sleep 600 
    DllCall(&quot;DestroyWindow&quot;, &quot;Ptr&quot;, htext)
    i := (i=&quot;&quot; || i = 3) ? 0 : ++i
    gui, add, text, w380 xm ym center hwndhtext, % text%i% 
    gosub Move
}

Move:
    GuiControlGet, text_, Pos, %htext%
    GuiControlGet, but_, Pos, button
    guicontrol, move, button, % &quot;y&quot; text_y+text_h+10 &quot;x&quot; text_x+round((text_w/2)-(but_w/2))
    gui, show, autosize, % &quot;Сообщение от &quot; sender%i%
    Return
</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Thu, 22 Oct 2015 23:55:52 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=98103#p98103</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Автоподстройка высоты окна GUI под содержимое]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=98102#p98102</link>
			<description><![CDATA[<div class="quotebox"><blockquote><p>Хотя в документации сказано, что текстовый блок добавляется borderless, т.е. без оконтовочных пикселей</p></blockquote></div><p>Читайте <a href="http://www.script-coding.com/AutoHotkey/GUI.html#margin">Margin</a>.</p><p>Если обнулить Margin, то и ваш старый код подойдёт:</p><div class="codebox"><pre><code>
gui, +hwndguihwnd
gui, Margin, 0 
gui, font, s14 c%col%, %font%
gui, add, text, w380 center vt
gui, add, button, x1 y+10 default vb, |   |   |
GuiControlGet, posb, Pos, b

DllCall(&quot;DestroyWindow&quot;, &quot;Ptr&quot;, t)
gui, add, text, w380 xm ym center hwndt, |   |   |
GuiControlGet, post, Pos, %t%

guicontrol, move, b, % &quot;y&quot; posty+posth+10 &quot;x&quot; round((postw/2)-(posbw/2))
gui, show, w400 autosize center, Сообщение от %sender%
winwaitclose, ahk_id %guihwnd%
return
</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Thu, 22 Oct 2015 23:49:14 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=98102#p98102</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Автоподстройка высоты окна GUI под содержимое]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=98101#p98101</link>
			<description><![CDATA[<p>А, ну т.е. отсчёт надо было явно ставить от текстового блока. Хотя в документации сказано, что текстовый блок добавляется borderless, т.е. без оконтовочных пикселей. Ну да ладно, видимо у них всё-таки есть какая-то оконтовка (не у текстового блока, так у самого gui).<br />В общем, вот что получилось, может, кому пригодится:<br /></p><div class="codebox"><pre><code>#SingleInstance force
#NoEnv
SetBatchLines, -1
SetTitleMatchMode, 3

sender = Джубадзе
col = navy
font = Calibri
tex = В чащах юга жил был кактус, но фальшивый экземпляр.

gui, +hwndguihwnd
gui, font, s14 c%col%, %font%
gui, add, text, w400 center vt
gui, add, button, x156 y+10 default vb, Хорошо!
GuiControlGet, posb, Pos, b

DllCall(&quot;DestroyWindow&quot;, &quot;Ptr&quot;, t)
gui, add, text, w400 xm ym center hwndt, %tex%
GuiControlGet, post, Pos, %t%

guicontrol, move, b, % &quot;y&quot; posty+posth+10 &quot;x&quot; postx+round((postw/2)-(posbw/2))
gui, show, w400 autosize center, Сообщение от %sender%
winwaitclose, ahk_id %guihwnd%

buttonХорошо!:
guiclose:
gui, destroy
exitapp
return</code></pre></div><p><strong>Большое спасибо serzh82saratov-у! Вы мне очень помогли!</strong></p><p>P.S. Кстати, то что у меня в одном месте стояло 380, а в другом 400, на позицию кнопки не влияло. Я пробовал ставить 400 везде, но кнопка всё равно была смещена влево. Это прошло только когда я задал <strong>postx+</strong>round((postw/2)-(posbw/2))</p>]]></description>
			<author><![CDATA[null@example.com (Indrik)]]></author>
			<pubDate>Thu, 22 Oct 2015 23:43:29 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=98101#p98101</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Автоподстройка высоты окна GUI под содержимое]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=98099#p98099</link>
			<description><![CDATA[<div class="codebox"><pre><code>gui, font, s14 c%col%, %font% 
gui, add, button, x1 y+10 default vb, I        I        I  
DllCall(&quot;DestroyWindow&quot;, &quot;Ptr&quot;, t)
gui, add, text, w380 xm ym center hwndt, I
GuiControlGet, text, Pos, %t%
GuiControlGet, button, Pos, b
guicontrol, move, b, % &quot;y&quot; texty+texth &quot;x&quot; textx+textw//2-buttonw//2 
gui, show, w400 autosize center, Сообщение от %sender%
return</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Thu, 22 Oct 2015 23:11:21 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=98099#p98099</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Автоподстройка высоты окна GUI под содержимое]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=98098#p98098</link>
			<description><![CDATA[<p>Да, спасибо. С хэндлами я не очень дружу.<br />Но центровку всё равно сделать не получается. Кнопка явно чуть смещена влево. Где-то на 15-20 пикселей.<br /></p><div class="codebox"><pre><code>gui, +hwndguihwnd
gui, font, s14 c%col%, %font%
gui, add, text, w380 center vt
gui, add, button, x1 y+10 default vb, Хорошо!
GuiControlGet, posb, Pos, b

DllCall(&quot;DestroyWindow&quot;, &quot;Ptr&quot;, t)
gui, add, text, w380 xm ym center hwndt, %tex%
GuiControlGet, post, Pos, %t%

guicontrol, move, b, % &quot;y&quot; posty+posth+10 &quot;x&quot; round((postw/2)-(posbw/2))
gui, show, w400 autosize center, Сообщение от %sender%
winwaitclose, ahk_id %guihwnd%

buttonХорошо!:
guiclose:
gui, destroy
msgbox, % round((postw/2)-(posbw/2))
exitapp
return</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Indrik)]]></author>
			<pubDate>Thu, 22 Oct 2015 23:01:51 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=98098#p98098</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Автоподстройка высоты окна GUI под содержимое]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=98097#p98097</link>
			<description><![CDATA[<p>Не с текстовой областью, а с переменной содержащей хэндл.<br />Есть разница?<br /></p><div class="codebox"><pre><code>gui, add, text, w380 center hwndt</code></pre></div><p>и<br /></p><div class="codebox"><pre><code>gui, add, text, w380 center vt</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Thu, 22 Oct 2015 22:29:34 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=98097#p98097</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Автоподстройка высоты окна GUI под содержимое]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=98096#p98096</link>
			<description><![CDATA[<p>Да, действительно. А почему с текстовой областью нужны проценты, а с кнопкой нет?</p>]]></description>
			<author><![CDATA[null@example.com (Indrik)]]></author>
			<pubDate>Thu, 22 Oct 2015 22:24:58 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=98096#p98096</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Автоподстройка высоты окна GUI под содержимое]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=98095#p98095</link>
			<description><![CDATA[<div class="codebox"><pre><code>GuiControlGet, posb, Pos, b</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Thu, 22 Oct 2015 22:21:13 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=98095#p98095</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Автоподстройка высоты окна GUI под содержимое]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=98094#p98094</link>
			<description><![CDATA[<p>Пытаюсь сделать точную центровку по горизонтали. Не удаётся получить данные только что созданного элемента. Вот:<br /></p><div class="codebox"><pre><code>#SingleInstance force
#NoEnv
SetBatchLines, -1
SetTitleMatchMode, 3

sender = Джубадзе
col = navy
font = Calibri
tex = В чащах юга жил был кактус, но фальшивый экземпляр. Слово экземпляр и этот текст уже не отображаются. Здесь пишу произвольный длинный текст, проверяю отображение при длинном тексте. Ехал грека через реку, видит грека – в реке рак, сунул грека руку в реку, рак за руку грека цап!

gui, +hwndguihwnd
gui, font, s14 c%col%, %font%
gui, add, text, w380 center vt
gui, add, button, x155 y+10 default vb, Хорошо!
GuiControlGet, posb, Pos, %b%

msgbox, %posbx%
exitapp</code></pre></div><p>msgbox отображает пустой текст. guicontrolget не работает с кнопками?</p>]]></description>
			<author><![CDATA[null@example.com (Indrik)]]></author>
			<pubDate>Thu, 22 Oct 2015 22:17:08 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=98094#p98094</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Автоподстройка высоты окна GUI под содержимое]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=98093#p98093</link>
			<description><![CDATA[<p>Вот такая морковина получилась.<br /></p><div class="codebox"><pre><code>#SingleInstance force
#NoEnv
SetBatchLines, -1
SetTitleMatchMode, 3

sender = Джубадзе
col = navy
font = Calibri
tex = В чащах юга жил был кактус, но фальшивый экземпляр. Слово экземпляр и этот текст уже не отображаются. Здесь пишу произвольный длинный текст, проверяю отображение при длинном тексте. Ехал грека через реку, видит грека – в реке рак, сунул грека руку в реку, рак за руку грека цап!

gui, +hwndguihwnd
gui, font, s14 c%col%, %font%
gui, add, text, w380 center vt
gui, add, button, x155 y+10 default vb, Хорошо!

DllCall(&quot;DestroyWindow&quot;, &quot;Ptr&quot;, t)
gui, add, text, w380 xm ym center hwndt, %tex%
GuiControlGet, position, Pos, %t%
guicontrol, move, b, % &quot;y&quot; positiony+positionh+10
gui, show, w400 autosize center, Сообщение от %sender%
winwaitclose, ahk_id %guihwnd%

buttonХорошо!:
guiclose:
gui, destroy
exitapp
return</code></pre></div><p>Но я нигде не использовал -wrap. Так и не понял, зачем он. В остальном вроде разобрался.</p>]]></description>
			<author><![CDATA[null@example.com (Indrik)]]></author>
			<pubDate>Thu, 22 Oct 2015 21:46:51 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=98093#p98093</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Автоподстройка высоты окна GUI под содержимое]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=98092#p98092</link>
			<description><![CDATA[<p>Да, ваш скрипт ресайзит всё как надо. Только он работает не так как было задумано. Например, в строке 12 в моём случае не нужно делать gui, show, т.к. там ещё нечего показывать. Но когда я закомментировал эту строку, то скрипт вообще перестал что-либо показывать. Многое в коде непонятно (откуда берётся у+10, почему 10?, почему wrap идёт с минусом, если это как раз должно отменять перенос слов, ну и другие моменты). В общем, буду разбираться.</p>]]></description>
			<author><![CDATA[null@example.com (Indrik)]]></author>
			<pubDate>Thu, 22 Oct 2015 20:42:24 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=98092#p98092</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Автоподстройка высоты окна GUI под содержимое]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=98091#p98091</link>
			<description><![CDATA[<div class="quotebox"><cite>Indrik пишет:</cite><blockquote><p>Только что методом научного тыка (guicontrol, move, m, h200) выяснил, что сам по себе текст на следующую строку переносится, проблема только в том, что не ресайзится окно, не подстраивается под текст.</p></blockquote></div><p>Немного неверно, в первую очередь размер самого контрола text не меняется при изменении в нём текста.</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Thu, 22 Oct 2015 20:32:04 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=98091#p98091</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Автоподстройка высоты окна GUI под содержимое]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=98090#p98090</link>
			<description><![CDATA[<div class="codebox"><pre><code>sender = Джубадзе
col = navy
font = Calibri

tex1 = В чащах юга жил был кактус, но фальшивый экземпляр. Слово экземпляр и этот текст уже не отображаются. 
tex2 = Только что методом научного тыка (guicontrol, move, m, h200) выяснил, что сам по себе текст на следующую строку переносится, проблема только в том, что не ресайзится окно, не подстраивается под текст.
tex3 = В чащах юга жил был кактус

gui, font, s14 c%col%, %font%
gui, add, text, w380 center hwndm -Wrap
gui, add, button, x155 y+10 default vbutton, Хорошо!
gui, show, w400
return

buttonХорошо!:
    i := (!i || i = 3) ? 1 : ++i
    DllCall(&quot;DestroyWindow&quot;, &quot;Ptr&quot;, m)
    gui, add, text, w380 xm ym center hwndm -Wrap, % tex%i%
    GuiControlGet, p, Pos, %m%
    guicontrol, move, button, % &quot;y&quot; py+ph+10 
    gui, show, w400   autosize, Сообщение от %sender% 
    return</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Thu, 22 Oct 2015 20:22:14 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=98090#p98090</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Автоподстройка высоты окна GUI под содержимое]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=98089#p98089</link>
			<description><![CDATA[<p>Только что методом научного тыка (guicontrol, move, m, h200) выяснил, что сам по себе текст на следующую строку переносится, проблема только в том, что не ресайзится окно, не подстраивается под текст.</p>]]></description>
			<author><![CDATA[null@example.com (Indrik)]]></author>
			<pubDate>Thu, 22 Oct 2015 20:18:33 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=98089#p98089</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Автоподстройка высоты окна GUI под содержимое]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=98088#p98088</link>
			<description><![CDATA[<p>У вас -wrap,%tex% добавлено в момент создания окна. Но в этот момент переменная tex ещё не содержит текста (да, в этом примере содержит, но этот скрипт просто для иллюстрации), в реальном коде переменная обретает значение уже после строки<br /></p><div class="codebox"><pre><code>gui, add, button, x155 default, Хорошо!</code></pre></div><p>Поэтому ресайзить под текст, видимо надо уже на этапе guicontrol...</p>]]></description>
			<author><![CDATA[null@example.com (Indrik)]]></author>
			<pubDate>Thu, 22 Oct 2015 19:59:37 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=98088#p98088</guid>
		</item>
	</channel>
</rss>
