<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Кнопка с иконкой Class_ImageButton.ahk]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=12207</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=12207&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Кнопка с иконкой Class_ImageButton.ahk».]]></description>
		<lastBuildDate>Tue, 06 Dec 2016 17:31:37 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Кнопка с иконкой Class_ImageButton.ahk]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=109663#p109663</link>
			<description><![CDATA[<div class="codebox"><pre><code>IcoPath := A_ScriptDir &quot;\google.ico&quot;
if !FileExist(IcoPath)
   URLDownloadToFile, https://goo.gl/DFVH4Y, % A_ScriptDir &quot;\google.ico&quot;

DllPath := &quot;Shell32.dll&quot;
IcoIdentifier := 23 ; это не порядковый номер, это идентификатор ресурса

Gui, Add, Button, hwndhButton1 w120 h44
Gui, Add, Button, hwndhButton2 wp hp
SetIconToButton(hButton1, IcoPath, 24)
SetIconToButton(hButton2, DllPath, 32, IcoIdentifier)
Gui, Show
Return

Esc::
GuiClose:
   ExitApp

SetIconToButton(hButton, IconFile, IconSize, IcoIdentifier := &quot;&quot;)  {
   static BS_ICON := 0x40, IMAGE_ICON := 1, BM_SETIMAGE := 0xF7, LR_LOADFROMFILE := 0x10
   
   WinSet, Style, % &quot;+&quot; BS_ICON, ahk_id %hButton%
   if (IcoIdentifier = &quot;&quot;)
      hModule := 0, IcoIdentifier := IconFile, flag := LR_LOADFROMFILE
   else  {
      hModule := DllCall(&quot;GetModuleHandle&quot;, Str, IconFile, Ptr)
      if RegExMatch(IcoIdentifier, &quot;^\d+$&quot;)
         IcoIdentifier := &quot;#&quot; . IcoIdentifier
      flag := 0
   }
      
   hIcon := DllCall(&quot;LoadImage&quot;, Ptr, hModule, Str, IcoIdentifier, UInt, IMAGE_ICON, Int, IconSize, Int, IconSize, UInt, flag)
   PostMessage, BM_SETIMAGE, IMAGE_ICON, hIcon,, ahk_id %hButton%
}
</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Tue, 06 Dec 2016 17:31:37 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=109663#p109663</guid>
		</item>
		<item>
			<title><![CDATA[AHK: Кнопка с иконкой Class_ImageButton.ahk]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=109662#p109662</link>
			<description><![CDATA[<p>День добрый, опять выхожу на связь.<br />На этот раз пишу GUI и застрял вот на чем. Сделал кнопки какие хотел с помощью Class_ImageButton.ahk (нашел на забугорном форуме), но как добавить в кнопку иконку (из dll, exe или просто отдельно иконку, с прозрачностью, конечно) не нашел и сам не догадался.<br />Застрял на этом.</p>]]></description>
			<author><![CDATA[null@example.com (upsi_daezium)]]></author>
			<pubDate>Tue, 06 Dec 2016 14:39:57 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=109662#p109662</guid>
		</item>
	</channel>
</rss>
