<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK : DropDownList]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=14610&amp;type=atom" />
	<updated>2019-03-02T17:53:49Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=14610</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK : DropDownList]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=132650#p132650" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>kangar пишет:</cite><blockquote><p>Конечно, можно считать № строки, удалить и добавить нужную - но ведь можно проще?</p></blockquote></div><p><a href="https://github.com/ahkscript/autohotkey.net/blob/5ae7f80a82eaf6bfbec5f263ca9427425d90b1e5/web/~heresy/Functions/CB.ahk">https://github.com/ahkscript/autohotkey … ons/CB.ahk</a><br />Там тоже, удаляется и создаётся строка.<br />Есть некое CB_SETITEMDATA, но я не нашёл примеров, и не уверен что это про то.</p><p>АП: считать № строки можно с помощью CB_FINDSTRINGEXACT, номер будет в ErrorLevel, это есть и в примере выше.<br /></p><div class="codebox"><pre><code>Gui, Add, DropDownList, hwndhDDL, Colors||White|Red|Green|Blue
Gui, Show
SendMessage, 0x014F, 1, , , ahk_id %hDDL%   ;	CB_SHOWDROPDOWN

ItemText = White
Loop
{
	Sleep 100
	SendMessage, 0x158, 1, &amp;ItemText, , ahk_id %hDDL%  ;  CB_FINDSTRINGEXACT
	ItemIndex := ErrorLevel
	SendMessage, 0x0144, ItemIndex, , , ahk_id %hDDL%  ;  CB_DELETESTRING
	ItemText := A_TickCount
	SendMessage, 0x014A, ItemIndex, &amp;ItemText , , ahk_id %hDDL%  ;  CB_INSERTSTRING 
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2019-03-02T17:53:49Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=132650#p132650</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK : DropDownList]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=132641#p132641" />
			<content type="html"><![CDATA[<p>Тут используются константы, которые можно получить в удобном виде, например, <a href="https://github.com/AHK-just-me/AHK_Gui_Constants/tree/master/Sources">отсюда</a>. В Вашем случае, это список констант для ComboBox.</p><p>Программирование — не магия. Всё происходит именно так, как подсказывает логика и когда нужно один компонент заменить на другой, то всегда это происходит, как и в жизни =&gt; заменяемый нужно найти, удалить и добавить другой.</p><p><strong>serzh82saratov</strong> просто пошёл на встречу Вашему любопытству, на самом же деле, Ваши догадки из третьего сообщения наименее заморочены и именно они и используются в подавляющем большинстве. То есть, создаётся новая строка для ДДЛ и через GuiControl заменяется.</p>]]></content>
			<author>
				<name><![CDATA[KusochekDobra]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33846</uri>
			</author>
			<updated>2019-03-02T10:00:45Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=132641#p132641</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK : DropDownList]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=132637#p132637" />
			<content type="html"><![CDATA[<p><strong>serzh82saratov</strong><br />Хоть я и получил ответы на мои вопросы, но всё же я не понял сути.<br />Откуда вы берёте/как пишете sendmessage запросы на манипуляции с ddl/combobox?</p><p>Во время написания кода всплыла ещё 1 проблема - как изменять элемент ddl. Конечно, можно считать № строки, удалить и добавить нужную - но ведь можно проще?<br />Я нашел тему с библиотекой, которая позволяет выполнять все эти действия и более - <a href="https://autohotkey.com/board/topic/31163-cb-combobox-dropdownlist-manipulation-functions/">https://autohotkey.com/board/topic/3116 … functions/</a><br />Но библиотеку не скачать - ошибка страницы выдаёт.<br />Я нашел тему с &quot;Коды оконных сообщений&quot; со справки PostMessage / SendMessage, но там нет и близко таких кодов как 0x014A, 0x143 и 0x0146, что в свою очередь вы использовали при написании примеров ниже.</p><p>Подскажите, если не примером, то хоть справкой по этому вопросу.</p>]]></content>
			<author>
				<name><![CDATA[kangar]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39404</uri>
			</author>
			<updated>2019-03-02T06:32:18Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=132637#p132637</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK : DropDownList]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=132554#p132554" />
			<content type="html"><![CDATA[<p><strong>serzh82saratov</strong><br />Спасибо ещё один раз <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[kangar]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39404</uri>
			</author>
			<updated>2019-02-27T17:03:07Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=132554#p132554</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK : DropDownList]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=132552#p132552" />
			<content type="html"><![CDATA[<p>С удалением удивили, пример то отличный. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p><p>ControlGet есть даже в русской справке на этом же ресурсе.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2019-02-27T16:56:36Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=132552#p132552</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK : DropDownList]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=132546#p132546" />
			<content type="html"><![CDATA[<p><strong>serzh82saratov</strong><br />Остался вопрос выше.</p>]]></content>
			<author>
				<name><![CDATA[kangar]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39404</uri>
			</author>
			<updated>2019-02-27T10:35:35Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=132546#p132546</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK : DropDownList]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=132544#p132544" />
			<content type="html"><![CDATA[<p><strong>serzh82saratov</strong><br />А вот ещё 1 маленький вопрос.<br /></p><div class="codebox"><pre><code>Gui, Add, DropDownList, vasd gdsa hwndhDDL, Colors|AA|White|Red|Green|Blue</code></pre></div><p>Если элемент в DDL выбран, то<br /></p><div class="codebox"><pre><code>msgbox % asd</code></pre></div><p>показывает этот элемент, а как можно отобразить весь список DDL?</p>]]></content>
			<author>
				<name><![CDATA[kangar]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39404</uri>
			</author>
			<updated>2019-02-27T09:51:28Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=132544#p132544</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK : DropDownList]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=132539#p132539" />
			<content type="html"><![CDATA[<p><strong>serzh82saratov</strong><br />Благодарю, отличный пример!</p>]]></content>
			<author>
				<name><![CDATA[kangar]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39404</uri>
			</author>
			<updated>2019-02-26T21:52:13Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=132539#p132539</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK : DropDownList]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=132528#p132528" />
			<content type="html"><![CDATA[<p>Так нагляднее. <br />Кстати вопрос, как обновить окно со списком, не скрывая его, при удалении строки, чтобы пустой строки не оставалось.<br /></p><div class="codebox"><pre><code>
Gui, Add, DropDownList, hwndhDDL, Colors||White|Red|Green|Blue
Gui, Show
SendMessage, 0x014F, 1, , , ahk_id %hDDL%   ;	CB_SHOWDROPDOWN
	
Sleep 1000 
ItemText = Colors
SendMessage, 0x158, 1, &amp;ItemText, , ahk_id %hDDL%  ;  CB_FINDSTRINGEXACT
SendMessage, 0x0144, ErrorLevel, , , ahk_id %hDDL%  ;  CB_DELETESTRING
GuiControl, +Redraw, %hDDL%

hDDLList := ComboBoxGetList(hDDL)
WinSet, Redraw, , ahk_id %hDDLList% 

Sleep 1000
ItemIndex = 1
ItemText = Colours list
SendMessage, 0x014A, ItemIndex - 1, &amp;ItemText , , ahk_id %hDDL%  ;  CB_INSERTSTRING
GuiControl, Choose, %hDDL%, % ItemIndex

Sleep 1000
ItemText = Black
ItemIndex = 3
SendMessage, 0x014A, ItemIndex - 1, &amp;ItemText , , ahk_id %hDDL%  ;  CB_INSERTSTRING

ItemText = Orange
SendMessage, 0x143, 0, &amp;ItemText , , ahk_id %hDDL%  ;  CB_ADDSTRING 

Sleep 1000
SendMessage, 0x014F, 0, , , ahk_id %hDDL%   ;	CB_SHOWDROPDOWN
SendMessage, 0x0146, 0, 0, , ahk_id %hDDL%  ;  CB_GETCOUNT 
GuiControl, Choose, %hDDL%, % ErrorLevel
Return

ComboBoxGetList(hCombo) {
	Static SizeOfCBI := 40 + (A_PtrSize * 3)
	VarSetCapacity(CBI, SizeOfCBI, 0) ; COMBOBOXINFO structure - msdn.microsoft.com/en-us/library/bb775798(v=vs.85).aspx
	NumPut(SizeOfCBI, CBI, 0, &quot;UInt&quot;)
	DllCall(&quot;GetComboBoxInfo&quot;, &quot;Ptr&quot;, hCombo, &quot;Ptr&quot;, &amp;CBI, &quot;Int&quot;) ; msdn.microsoft.com/en-us/library/bb775939(v=vs.85).aspx
	Return NumGet(CBI, 40 + A_PtrSize*2, &quot;UPtr&quot;)
}
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2019-02-26T13:25:57Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=132528#p132528</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK : DropDownList]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=132527#p132527" />
			<content type="html"><![CDATA[<p>Так это надо весь список переписывать.<br /></p><div class="codebox"><pre><code>
Gui, Add, DropDownList, hwndhDDL, Colors||White|Red|Green|Blue
Gui, Show

Sleep 1000
ItemIndex = 1
SendMessage, 0x0144, ItemIndex - 1, , , ahk_id %hDDL%  ;  CB_DELETESTRING 
GuiControl, +Redraw, %hDDL%
Sleep 1000
ItemText = Colours list
SendMessage, 0x014A, ItemIndex - 1, &amp;ItemText , , ahk_id %hDDL%  ;  CB_INSERTSTRING
GuiControl, Choose, %hDDL%, % ItemIndex
Return
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2019-02-26T13:04:48Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=132527#p132527</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK : DropDownList]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=132526#p132526" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong><br />Да мне не нравится что мы каждый раз переписываем целую DDL, вместо нужного элемента. Но похоже без этого никак.</p>]]></content>
			<author>
				<name><![CDATA[kangar]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39404</uri>
			</author>
			<updated>2019-02-26T13:04:32Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=132526#p132526</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK : DropDownList]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=132525#p132525" />
			<content type="html"><![CDATA[<p>А чем этот вариант не устраивает?</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2019-02-26T12:40:05Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=132525#p132525</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK : DropDownList]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=132524#p132524" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong><br />В общих чертах, если ничего лучше предложить нет конечно.</p>]]></content>
			<author>
				<name><![CDATA[kangar]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39404</uri>
			</author>
			<updated>2019-02-26T12:29:25Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=132524#p132524</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK : DropDownList]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=132523#p132523" />
			<content type="html"><![CDATA[<p>То-есть, всё понятно теперь?</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2019-02-26T12:05:24Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=132523#p132523</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK : DropDownList]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=132522#p132522" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong><br />Я как раз в 3-м сообщении и написал как это реализовывается через guicontrol.</p>]]></content>
			<author>
				<name><![CDATA[kangar]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39404</uri>
			</author>
			<updated>2019-02-26T11:50:24Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=132522#p132522</id>
		</entry>
</feed>
