<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Кнопка с иконкой Class_ImageButton.ahk]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=12207&amp;type=atom" />
	<updated>2016-12-06T17:31:37Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=12207</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Кнопка с иконкой Class_ImageButton.ahk]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=109663#p109663" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2016-12-06T17:31:37Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=109663#p109663</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Кнопка с иконкой Class_ImageButton.ahk]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=109662#p109662" />
			<content type="html"><![CDATA[<p>День добрый, опять выхожу на связь.<br />На этот раз пишу GUI и застрял вот на чем. Сделал кнопки какие хотел с помощью Class_ImageButton.ahk (нашел на забугорном форуме), но как добавить в кнопку иконку (из dll, exe или просто отдельно иконку, с прозрачностью, конечно) не нашел и сам не догадался.<br />Застрял на этом.</p>]]></content>
			<author>
				<name><![CDATA[upsi_daezium]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34120</uri>
			</author>
			<updated>2016-12-06T14:39:57Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=109662#p109662</id>
		</entry>
</feed>
