<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Как добавить Picture на Button в GUI]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=16483</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=16483&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Как добавить Picture на Button в GUI».]]></description>
		<lastBuildDate>Tue, 13 Jul 2021 13:42:34 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Как добавить Picture на Button в GUI]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=148941#p148941</link>
			<description><![CDATA[<p>Пример:<br /></p><div class="codebox"><pre><code>Gui, Add, Button, w64 h64 hwndhButton1
Gui, Add, Button, x+5 yp+13 w200 h38 hwndhButton2, % &quot;  Этот текст будет виден&quot;

; картинка из png файла
SetImageOnButton(hButton1, &quot;icon.png&quot;, 60, 60)
; иконка из dll
SetImageOnButton(hButton2, &quot;Shell32&quot;, 24, 24, IMAGE_ICON := 1, 44)

Gui, Show
Return

GuiClose:
   ExitApp

SetImageOnButton(hwnd, imageFilePath, w := 16, h := 16, imageType := 0, iconNumber := 0) {
   static BS_ICON      := 0x40
        , BS_BITMAP    := 0x80
        , IMAGE_ICON   := 1
        , IMAGE_BITMAP := 0
        , BM_SETIMAGE  := 0xF7
        
   if !hImage := LoadPicture(imageFilePath, &quot;w&quot; . w . &quot; h&quot; . h . (iconNumber ? &quot; Icon&quot; . iconNumber : &quot;&quot;), imageType)
      throw &quot;Failed to load image&quot;
   ControlGetText, text,, ahk_id %hwnd%
   if (text = &quot;&quot;) {
      WinSet, Style, % &quot;+&quot; . (imageType = IMAGE_ICON ? BS_ICON : BS_BITMAP), ahk_id %hwnd%
      if ErrorLevel
         throw &quot;Failed to assign style&quot;
   }
   SendMessage, BM_SETIMAGE, imageType, hImage,, ahk_id %hwnd%
   if ErrorLevel
      imageType = IMAGE_ICON ? DllCall(&quot;DestroyIcon&quot; , &quot;Ptr&quot;, ErrorLevel)
                             : DllCall(&quot;DeleteObject&quot;, &quot;Ptr&quot;, ErrorLevel)
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Tue, 13 Jul 2021 13:42:34 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=148941#p148941</guid>
		</item>
		<item>
			<title><![CDATA[AHK: Как добавить Picture на Button в GUI]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=148939#p148939</link>
			<description><![CDATA[<p>Как добавить иконку на кнопку в GUI, чтобы при нажатии на кнопку - иконка оставалась на месте.<br /></p><div class="codebox"><pre><code>Gui Add, Button, x17 y5 w64 h64
Gui Add, Picture, x17 y5 w64 h64, icon.png</code></pre></div><p>При наведении на кнопку - кнопка пропадает.<br />Цель - добавить иконку на кнопку, чтобы иконка не меняла верхний слой.</p>]]></description>
			<author><![CDATA[null@example.com (~incognito)]]></author>
			<pubDate>Tue, 13 Jul 2021 12:05:33 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=148939#p148939</guid>
		</item>
	</channel>
</rss>
