<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Добавление иконки на выделенную строку в ListView (GUI)]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=18173</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=18173&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Добавление иконки на выделенную строку в ListView (GUI)».]]></description>
		<lastBuildDate>Tue, 23 Apr 2024 23:03:45 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Добавление иконки на выделенную строку в ListView (GUI)]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=160828#p160828</link>
			<description><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>попроще:</p></blockquote></div><p>Можно ещё проще:<br /></p><div class="codebox"><pre><code>LV() {
    static sel := 1
    if (A_GuiEvent = &quot;DoubleClick&quot;) {
        LV_Modify(sel, &quot;Icon2&quot;)
        LV_Modify(sel := LV_GetNext(), &quot;Icon1&quot;)
    }
}</code></pre></div><div class="quotebox"><cite>serzh82saratov пишет:</cite><blockquote><p>не соображу</p></blockquote></div><p>А что там соображать-то, всё довольно понятно написано.<br /></p><div class="codebox"><pre><code>Gui, Add, ListView, r20 w700 gLV hwndhLV, Name|Size (KB)

imageList := IL_Create()
IL_Add(imageList, &quot;shell32&quot;, 44)
IL_Add(imageList, &quot;shell32&quot;, 50)
LV_SetImageList(imageList)

Loop, Files, %A_MyDocuments%\*.*
{
    LV_Add(&quot;Icon2&quot;, A_LoopFileName, A_LoopFileSizeKB)
}
	
LV_ModifyCol() 
LV_ModifyCol(2, &quot;Integer 70&quot;)

SetHeaderItemIcon(hLV, 1, imageList, 1)

Gui, Show
return

LV() {
    static sel := 1
    if (A_GuiEvent = &quot;DoubleClick&quot;) {
        LV_Modify(sel, &quot;Icon2&quot;)
        LV_Modify(sel := LV_GetNext(), &quot;Icon1&quot;)
    }
}

GuiClose() {
    ExitApp
}

SetHeaderItemIcon(hListView, item, imageList, imageNum) {
    static LVM_GETHEADER := 0x101F, HDM_SETIMAGELIST := 0x1208
         , HDM_GETITEM := 0x1200 + (A_IsUnicode ? 3 : 11)
         , HDM_SETITEM := HDM_GETITEM + 1
         , HDI_FORMAT := 0x4, HDI_IMAGE := 0x20, HDF_IMAGE := 0x800
         , fmt_offset := 12 + A_PtrSize * 2

    SendMessage, LVM_GETHEADER,,,, ahk_id %hListView%
    WinExist(&quot;ahk_id &quot; . ErrorLevel)
    SendMessage, HDM_SETIMAGELIST,, imageList
    VarSetCapacity(HDITEM, 24 + A_PtrSize * 6, 0)
    NumPut(HDI_FORMAT|HDI_IMAGE, HDITEM)
    SendMessage, HDM_GETITEM, --item, &amp;HDITEM
    fmt := NumGet(HDITEM, fmt_offset, &quot;Int&quot;)
    NumPut(--imageNum, HDITEM, 16 + A_PtrSize * 3)
    NumPut(fmt|HDF_IMAGE, HDITEM, fmt_offset)
    SendMessage, HDM_SETITEM, item, &amp;HDITEM
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Tue, 23 Apr 2024 23:03:45 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=160828#p160828</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Добавление иконки на выделенную строку в ListView (GUI)]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=160827#p160827</link>
			<description><![CDATA[<p>Про чекбокс в первой колонке знаю, но вот про иконки в колонках всё таки подобным образом не соображу.</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Tue, 23 Apr 2024 21:16:45 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=160827#p160827</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Добавление иконки на выделенную строку в ListView (GUI)]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=160826#p160826</link>
			<description><![CDATA[<p>Вот чекбокс, иконку по идее как-то подобным образом можно:<br /></p><div class="codebox"><pre><code>Gui, Add, Listview, x0 y0 h200 w400 hwndhLV, Title1|Title2
header := SetHeaderItemCheckBox(hLV, 1)
OnMessage(0x4E, Func(&quot;WM_NOTIFY&quot;).Bind(header, 1))
Gui, Show, h200 w400

Loop 2 {
   LV_Add(, 111, 222)
   LV_ModifyCol(A_Index, &quot;autohdr&quot;)
}
return

GuiClose() {
   ExitApp
}

SetHeaderItemCheckBox(hListView, item) {
   static LVM_GETHEADER := 0x101F, HDS_CHECKBOXES := 0x400, HDI_FORMAT := 0x4
        , HDM_FIRST := 0x1200, HDM_GETITEM := HDM_FIRST + (A_IsUnicode ? 3 : 11)
        , HDM_SETITEM := HDM_GETITEM + 1, HDF_CHECKBOX := 0x40
        , HDITEM_SIZE := 4*6 + A_PtrSize*6, fmt_offset := 4*3 + A_PtrSize*2
        
   SendMessage, LVM_GETHEADER,,,, ahk_id %hListView%
   WinExist(&quot;ahk_id&quot; header := ErrorLevel)
   WinSet, Style, +%HDS_CHECKBOXES%
   VarSetCapacity(HDITEM, HDITEM_SIZE, 0)
   NumPut(HDI_FORMAT, HDITEM)
   SendMessage, HDM_GETITEM, --item, &amp;HDITEM
   fmt := NumGet(HDITEM, fmt_offset, &quot;Int&quot;)
   NumPut(fmt|HDF_CHECKBOX, HDITEM, fmt_offset)
   SendMessage, HDM_SETITEM, item, &amp;HDITEM
   Return header
}

WM_NOTIFY(header, item, wp, lp) {
   static HDN_ITEMSTATEICONCLICK := -16, HDI_FORMAT := 0x4, HDF_CHECKED := 0x80
        , HDM_FIRST := 0x1200, HDM_GETITEM := HDM_FIRST + (A_IsUnicode ? 3 : 11)
        , HDITEM_SIZE := 4*6 + A_PtrSize*6, fmt_offset := 4*3 + A_PtrSize*2
        , prevChecked := 0
        
   if NumGet(lp+0) = header &amp;&amp; NumGet(lp + A_PtrSize*2, &quot;Int&quot;) = HDN_ITEMSTATEICONCLICK {
      VarSetCapacity(HDITEM, HDITEM_SIZE, 0)
      NumPut(HDI_FORMAT, HDITEM)
      SendMessage, HDM_GETITEM, --item, &amp;HDITEM,, ahk_id %header%
      checked := NumGet(HDITEM, fmt_offset, &quot;Int&quot;) &amp; HDF_CHECKED
      if (checked != prevChecked) {
         prevChecked := checked
         ToolTip, % &quot;Header&#039;s checkbox is &quot; . (checked ? &quot;&quot; : &quot;un&quot;) . &quot;checked&quot;
      }
   }
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Tue, 23 Apr 2024 18:34:48 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=160826#p160826</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Добавление иконки на выделенную строку в ListView (GUI)]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=160825#p160825</link>
			<description><![CDATA[<p>В заголовке что то вставлять, не припомню такого.</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Tue, 23 Apr 2024 18:26:05 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=160825#p160825</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Добавление иконки на выделенную строку в ListView (GUI)]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=160824#p160824</link>
			<description><![CDATA[<p>У меня в заголовке добавлены пробелы в качестве отступа, но если заморочиться, туда вроде тоже иконку можно вставить, по крайней мере чекбокс вставлялся точно.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Tue, 23 Apr 2024 18:23:32 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=160824#p160824</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Добавление иконки на выделенную строку в ListView (GUI)]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=160823#p160823</link>
			<description><![CDATA[<p>Ну супер, красава!<br />Я и сказал что вариант не очень, ну и пустой значок не искал.</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Tue, 23 Apr 2024 18:21:26 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=160823#p160823</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Добавление иконки на выделенную строку в ListView (GUI)]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=160822#p160822</link>
			<description><![CDATA[<p>Как-то сложно у тебя вышло, попроще:<br /></p><div class="codebox"><pre><code>Gui, Add, ListView, r20 w700 gLV vLV, % &quot;     Name|Size (KB)&quot;

imageList := IL_Create()
IL_Add(imageList, &quot;shell32&quot;, 44)
IL_Add(imageList, &quot;shell32&quot;, 50)
LV_SetImageList(imageList) 

Loop, Files, %A_MyDocuments%\*.*
{
    LV_Add(&quot;Icon2&quot;, A_LoopFileName, A_LoopFileSizeKB)
}
	
LV_ModifyCol() 
LV_ModifyCol(2, &quot;Integer 70&quot;)

Gui, Show
return

LV() {
    if (A_GuiEvent = &quot;DoubleClick&quot;) {
        sel := LV_GetNext()
        Loop % LV_GetCount() {
            LV_Modify(A_Index, &quot;Icon&quot; . (A_Index = sel ? &quot;1&quot; : &quot;2&quot;))
        }
    }
}

GuiClose() {
    ExitApp
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Tue, 23 Apr 2024 17:36:01 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=160822#p160822</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Добавление иконки на выделенную строку в ListView (GUI)]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=160821#p160821</link>
			<description><![CDATA[<p>Думаю не лучший вариант.<br /></p><div class="codebox"><pre><code>Gui, Add, ListView, r20 w700 gLV vLV, Name|Size (KB)


Loop, %A_MyDocuments%\*.*
    LV_Add(&quot;&quot;, A_LoopFileName, A_LoopFileSizeKB)
	
LV_ModifyCol() 
LV_ModifyCol(2, &quot;Integer&quot;)  

Gui, Show
return 

LV:
if (A_GuiEvent = &quot;DoubleClick&quot;)
{ 
	IL_Destroy(ImageListID) 
	ImageListID := IL_Create(LV_GetCount())
	sel := LV_GetNext()
	Loop % LV_GetCount()
	{ 	 
		IL_Add(ImageListID, &quot;shell32.dll&quot;, A_Index = sel ? 147 : 0) 
		LV_Modify(A_Index, &quot;Icon&quot; A_Index) 
	}
	LV_SetImageList(ImageListID) 
}
return</code></pre></div><p>Вместо нулевой иконки можно подставить свою картинку в виде фона, типа что картинки и нет.</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Tue, 23 Apr 2024 16:13:10 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=160821#p160821</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Добавление иконки на выделенную строку в ListView (GUI)]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=160820#p160820</link>
			<description><![CDATA[<p><strong>inseption86</strong><br />Если думаете, что стало лучше, то нет. Из заголовка должно быть понятно, в чём вопрос.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Tue, 23 Apr 2024 15:53:19 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=160820#p160820</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Добавление иконки на выделенную строку в ListView (GUI)]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=160819#p160819</link>
			<description><![CDATA[<p>Он не отражает вопрос.</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Tue, 23 Apr 2024 15:43:13 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=160819#p160819</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Добавление иконки на выделенную строку в ListView (GUI)]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=160818#p160818</link>
			<description><![CDATA[<p><strong>teadrinker</strong> заголовком?</p>]]></description>
			<author><![CDATA[null@example.com (inseption86)]]></author>
			<pubDate>Tue, 23 Apr 2024 15:11:22 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=160818#p160818</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Добавление иконки на выделенную строку в ListView (GUI)]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=160817#p160817</link>
			<description><![CDATA[<p>А что с заголовком?</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Tue, 23 Apr 2024 13:49:05 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=160817#p160817</guid>
		</item>
		<item>
			<title><![CDATA[AHK: Добавление иконки на выделенную строку в ListView (GUI)]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=160816#p160816</link>
			<description><![CDATA[<p>Добрый день! Как добавить иконку только на определённую строку?</p><div class="codebox"><pre><code>
Gui, Add, ListView, r20 w700 gLV vLV, Name|Size (KB)

ImageListID := IL_Create(1)
IL_Add(ImageListID, &quot;shell32.dll&quot;, 147) 

Loop, %A_MyDocuments%\*.*
    LV_Add(&quot;&quot;, A_LoopFileName, A_LoopFileSizeKB)
	
LV_ModifyCol() 
LV_ModifyCol(2, &quot;Integer&quot;)  

Gui, Show
return


LV:
if (A_GuiEvent = &quot;DoubleClick&quot;)
{
	LV_SetImageList(ImageListID)
	LV_Modify(LV_GetNext(), &quot;Icon1&quot;)
}
return

</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (inseption86)]]></author>
			<pubDate>Tue, 23 Apr 2024 13:13:04 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=160816#p160816</guid>
		</item>
	</channel>
</rss>
