<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Изменение цвета Hotkey в GUI]]></title>
	<link rel="self" href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=15117&amp;type=atom" />
	<updated>2020-01-06T16:28:35Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=15117</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Изменение цвета Hotkey в GUI]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=137176#p137176" />
			<content type="html"><![CDATA[<p>Костыль вроде ничего работает. </p><div class="codebox"><pre><code>

#NoEnv
#SingleInstance Force   
 
Gui, Font, s16, Comic Sans MS

Gui, Add, Text, Center hwndhText1 gText vTextHotkey1 w222, Нет
Gui, Add, Text, Center hwndhText2 gText vTextHotkey2 wp, Нет

Gui, Add, Hotkey, vHotkey1 gHotkey  w0 h0
Gui, Add, Hotkey, vHotkey2 gHotkey wp hp

SetStaticColor(hText1, 0x0000FF, 0xFFFFFF) 
SetStaticColor(hText2, 0d0d0d, 0xFFFFFF) 

Gui, Show
Return
 
Text() {  
	GuiControl, Focus, % SubStr(A_GuiControl, 5)
}

Hotkey() {   
	Instr(%A_GuiControl%, &quot;^&quot;) &amp;&amp; (str .= &quot;Ctrl + &quot;)
	Instr(%A_GuiControl%, &quot;+&quot;) &amp;&amp; (str .= &quot;Shift + &quot;)
	Instr(%A_GuiControl%, &quot;!&quot;) &amp;&amp; (str .= &quot;Alt + &quot;)
	HK := str RegExReplace(Format(&quot;{:U}&quot;, %A_GuiControl%), &quot;[\+!\^]&quot;) 
	GuiControl, , Text%A_GuiControl%, % HK = &quot;&quot; ? &quot;Нет&quot; : HK
} 

GuiClose() {
    ExitApp
}


;  http://forum.script-coding.com/viewtopic.php?pid=101917#p101917

SetStaticColor(hStatic, b_color, f_color)
{
	static arr := [], GWL_WNDPROC := -4
	hGui := DllCall(&quot;GetParent&quot;, Ptr, hStatic, Ptr)
	if !arr.HasKey(hGui)  {
		arr[hGui] := {}, arr[hGui].Statics := []
		arr[hGui].ProcOld := DllCall(&quot;SetWindowLong&quot; . (A_PtrSize = 8 ? &quot;Ptr&quot; : &quot;&quot;), Ptr, hGui, Int, GWL_WNDPROC
												, Ptr, RegisterCallback(&quot;WindowProc&quot;, &quot;&quot;, 4, Object(arr[hGui])), Ptr)
	}
	else if arr[hGui].Statics.HasKey(hStatic)
		DllCall(&quot;DeleteObject&quot;, Ptr, arr[hGui].Statics[hStatic].hBrush)
	arr[hGui].Statics[hStatic] := { b_color: Rgb2Bgr(b_color), f_color: Rgb2Bgr(f_color)
											, hBrush: DllCall(&quot;CreateSolidBrush&quot;, UInt, Rgb2Bgr(b_color), Ptr) }
	WinSet, Redraw,, ahk_id %hGui%
}

WindowProc(hwnd, uMsg, wParam, lParam)
{
	Critical
	static WM_CTLCOLORSTATIC := 0x138
	obj := Object(A_EventInfo)
	if (uMsg = WM_CTLCOLORSTATIC &amp;&amp; k := obj.Statics[lParam])  {
		DllCall(&quot;SetBkColor&quot;, Ptr, wParam, UInt, k.b_color)
		DllCall(&quot;SetTextColor&quot;, Ptr, wParam, UInt, k.f_color)
		Return k.hBrush
	}
	Return DllCall(&quot;CallWindowProc&quot;, Ptr, obj.ProcOld, Ptr, hwnd, UInt, uMsg, Ptr, wParam, Ptr, lParam)
}
	
Rgb2Bgr(color)
{
	Return (color &amp; 0xff) &lt;&lt; 16 | ((color &gt;&gt; 8) &amp; 0xff) &lt;&lt; 8 | color &gt;&gt; 16
}
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2020-01-06T16:28:35Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=137176#p137176</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Изменение цвета Hotkey в GUI]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=137172#p137172" />
			<content type="html"><![CDATA[<p>Может через NET можно?<br /><a href="https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.control.backcolor?view=netframework-4.8#System_Windows_Forms_Control_BackColor">https://docs.microsoft.com/en-us/dotnet … _BackColor</a></p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2020-01-06T15:44:33Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=137172#p137172</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Изменение цвета Hotkey в GUI]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=137170#p137170" />
			<content type="html"><![CDATA[<p>У Hotkey фон так просто не изменить. Можно попробовать спрятать Hotkey и сделать Text, который будет дублировать его содержимое. А уже у Text можно изменять фон.</p>]]></content>
			<author>
				<name><![CDATA[ypppu]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=5974</uri>
			</author>
			<updated>2020-01-06T15:02:00Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=137170#p137170</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Изменение цвета Hotkey в GUI]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=137169#p137169" />
			<content type="html"><![CDATA[<p>По этой ссылке тяжело будет найти. Но даже если покопаться, там есть пример для Edit со стилем ReadOnly, но это не подойдёт для контрола Hotkey, если это вообще возможно.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2020-01-06T14:46:29Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=137169#p137169</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Изменение цвета Hotkey в GUI]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=137166#p137166" />
			<content type="html"><![CDATA[<p><a href="http://forum.script-coding.com/viewtopic.php?id=8104">http://forum.script-coding.com/viewtopic.php?id=8104</a><br />И точку уберите в названии темы, а то нагорит.</p>]]></content>
			<author>
				<name><![CDATA[Foma]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=31521</uri>
			</author>
			<updated>2020-01-05T20:18:36Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=137166#p137166</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Изменение цвета Hotkey в GUI]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=137165#p137165" />
			<content type="html"><![CDATA[<p>Искал изменение цвета хоткея в гуи, нашёл только изменение цвета edit, пришлось обратится сюда.<br />Дело в том, что мне нужно заменить стандартный белый цвет <span class="postimg"><img src="https://www.autohotkey.com/docs/static/ctrl_hotkey.png" alt="https://www.autohotkey.com/docs/static/ctrl_hotkey.png" /></span> на чёрный (0d0d0d) в моём гуи.<br />Заранее спасибо!</p>]]></content>
			<author>
				<name><![CDATA[Dozilius]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=40446</uri>
			</author>
			<updated>2020-01-05T20:13:07Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=137165#p137165</id>
		</entry>
</feed>
