<?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=11024&amp;type=atom" />
	<updated>2015-10-22T23:55:52Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=11024</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Автоподстройка высоты окна GUI под содержимое]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=98103#p98103" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2015-10-22T23:55:52Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=98103#p98103</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Автоподстройка высоты окна GUI под содержимое]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=98102#p98102" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2015-10-22T23:49:14Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=98102#p98102</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Автоподстройка высоты окна GUI под содержимое]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=98101#p98101" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Indrik]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=29749</uri>
			</author>
			<updated>2015-10-22T23:43:29Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=98101#p98101</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Автоподстройка высоты окна GUI под содержимое]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=98099#p98099" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2015-10-22T23:11:21Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=98099#p98099</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Автоподстройка высоты окна GUI под содержимое]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=98098#p98098" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Indrik]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=29749</uri>
			</author>
			<updated>2015-10-22T23:01:51Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=98098#p98098</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Автоподстройка высоты окна GUI под содержимое]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=98097#p98097" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2015-10-22T22:29:34Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=98097#p98097</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Автоподстройка высоты окна GUI под содержимое]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=98096#p98096" />
			<content type="html"><![CDATA[<p>Да, действительно. А почему с текстовой областью нужны проценты, а с кнопкой нет?</p>]]></content>
			<author>
				<name><![CDATA[Indrik]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=29749</uri>
			</author>
			<updated>2015-10-22T22:24:58Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=98096#p98096</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Автоподстройка высоты окна GUI под содержимое]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=98095#p98095" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>GuiControlGet, posb, Pos, b</code></pre></div>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2015-10-22T22:21:13Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=98095#p98095</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Автоподстройка высоты окна GUI под содержимое]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=98094#p98094" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Indrik]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=29749</uri>
			</author>
			<updated>2015-10-22T22:17:08Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=98094#p98094</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Автоподстройка высоты окна GUI под содержимое]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=98093#p98093" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Indrik]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=29749</uri>
			</author>
			<updated>2015-10-22T21:46:51Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=98093#p98093</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Автоподстройка высоты окна GUI под содержимое]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=98092#p98092" />
			<content type="html"><![CDATA[<p>Да, ваш скрипт ресайзит всё как надо. Только он работает не так как было задумано. Например, в строке 12 в моём случае не нужно делать gui, show, т.к. там ещё нечего показывать. Но когда я закомментировал эту строку, то скрипт вообще перестал что-либо показывать. Многое в коде непонятно (откуда берётся у+10, почему 10?, почему wrap идёт с минусом, если это как раз должно отменять перенос слов, ну и другие моменты). В общем, буду разбираться.</p>]]></content>
			<author>
				<name><![CDATA[Indrik]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=29749</uri>
			</author>
			<updated>2015-10-22T20:42:24Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=98092#p98092</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Автоподстройка высоты окна GUI под содержимое]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=98091#p98091" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Indrik пишет:</cite><blockquote><p>Только что методом научного тыка (guicontrol, move, m, h200) выяснил, что сам по себе текст на следующую строку переносится, проблема только в том, что не ресайзится окно, не подстраивается под текст.</p></blockquote></div><p>Немного неверно, в первую очередь размер самого контрола text не меняется при изменении в нём текста.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2015-10-22T20:32:04Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=98091#p98091</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Автоподстройка высоты окна GUI под содержимое]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=98090#p98090" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2015-10-22T20:22:14Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=98090#p98090</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Автоподстройка высоты окна GUI под содержимое]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=98089#p98089" />
			<content type="html"><![CDATA[<p>Только что методом научного тыка (guicontrol, move, m, h200) выяснил, что сам по себе текст на следующую строку переносится, проблема только в том, что не ресайзится окно, не подстраивается под текст.</p>]]></content>
			<author>
				<name><![CDATA[Indrik]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=29749</uri>
			</author>
			<updated>2015-10-22T20:18:33Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=98089#p98089</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Автоподстройка высоты окна GUI под содержимое]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=98088#p98088" />
			<content type="html"><![CDATA[<p>У вас -wrap,%tex% добавлено в момент создания окна. Но в этот момент переменная tex ещё не содержит текста (да, в этом примере содержит, но этот скрипт просто для иллюстрации), в реальном коде переменная обретает значение уже после строки<br /></p><div class="codebox"><pre><code>gui, add, button, x155 default, Хорошо!</code></pre></div><p>Поэтому ресайзить под текст, видимо надо уже на этапе guicontrol...</p>]]></content>
			<author>
				<name><![CDATA[Indrik]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=29749</uri>
			</author>
			<updated>2015-10-22T19:59:37Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=98088#p98088</id>
		</entry>
</feed>
