<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Как добавить Picture на Button в GUI]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=16483&amp;type=atom" />
	<updated>2021-07-13T13:42:34Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=16483</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Как добавить Picture на Button в GUI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=148941#p148941" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2021-07-13T13:42:34Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=148941#p148941</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Как добавить Picture на Button в GUI]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=148939#p148939" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[~incognito]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=41862</uri>
			</author>
			<updated>2021-07-13T12:05:33Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=148939#p148939</id>
		</entry>
</feed>
