<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Добавление иконки на выделенную строку в ListView (GUI)]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=18173&amp;type=atom" />
	<updated>2024-04-23T23:03:45Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=18173</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Добавление иконки на выделенную строку в ListView (GUI)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=160828#p160828" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2024-04-23T23:03:45Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=160828#p160828</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Добавление иконки на выделенную строку в ListView (GUI)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=160827#p160827" />
			<content type="html"><![CDATA[<p>Про чекбокс в первой колонке знаю, но вот про иконки в колонках всё таки подобным образом не соображу.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2024-04-23T21:16:45Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=160827#p160827</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Добавление иконки на выделенную строку в ListView (GUI)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=160826#p160826" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2024-04-23T18:34:48Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=160826#p160826</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Добавление иконки на выделенную строку в ListView (GUI)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=160825#p160825" />
			<content type="html"><![CDATA[<p>В заголовке что то вставлять, не припомню такого.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2024-04-23T18:26:05Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=160825#p160825</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Добавление иконки на выделенную строку в ListView (GUI)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=160824#p160824" />
			<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>2024-04-23T18:23:32Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=160824#p160824</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Добавление иконки на выделенную строку в ListView (GUI)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=160823#p160823" />
			<content type="html"><![CDATA[<p>Ну супер, красава!<br />Я и сказал что вариант не очень, ну и пустой значок не искал.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2024-04-23T18:21:26Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=160823#p160823</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Добавление иконки на выделенную строку в ListView (GUI)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=160822#p160822" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2024-04-23T17:36:01Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=160822#p160822</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Добавление иконки на выделенную строку в ListView (GUI)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=160821#p160821" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2024-04-23T16:13:10Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=160821#p160821</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Добавление иконки на выделенную строку в ListView (GUI)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=160820#p160820" />
			<content type="html"><![CDATA[<p><strong>inseption86</strong><br />Если думаете, что стало лучше, то нет. Из заголовка должно быть понятно, в чём вопрос.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2024-04-23T15:53:19Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=160820#p160820</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Добавление иконки на выделенную строку в ListView (GUI)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=160819#p160819" />
			<content type="html"><![CDATA[<p>Он не отражает вопрос.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2024-04-23T15:43:13Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=160819#p160819</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Добавление иконки на выделенную строку в ListView (GUI)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=160818#p160818" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong> заголовком?</p>]]></content>
			<author>
				<name><![CDATA[inseption86]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=38818</uri>
			</author>
			<updated>2024-04-23T15:11:22Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=160818#p160818</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Добавление иконки на выделенную строку в ListView (GUI)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=160817#p160817" />
			<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>2024-04-23T13:49:05Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=160817#p160817</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Добавление иконки на выделенную строку в ListView (GUI)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=160816#p160816" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[inseption86]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=38818</uri>
			</author>
			<updated>2024-04-23T13:13:04Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=160816#p160816</id>
		</entry>
</feed>
