<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: GDI+ нарисовать прозрачный элемент поверх другого]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=14413&amp;type=atom" />
	<updated>2018-12-19T15:11:07Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=14413</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: GDI+ нарисовать прозрачный элемент поверх другого]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=130476#p130476" />
			<content type="html"><![CDATA[<p>Я эти операции опустил, а так, спасибо большое за помощь. На офф. форуме тоже самое посоветовали. (передавать pGraphics в функцию)</p>]]></content>
			<author>
				<name><![CDATA[MandarinKa02]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34409</uri>
			</author>
			<updated>2018-12-19T15:11:07Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=130476#p130476</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: GDI+ нарисовать прозрачный элемент поверх другого]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=130437#p130437" />
			<content type="html"><![CDATA[<p>Ваш код очень неаккуратный, созданные объекты не удаляются.<br /></p><div class="codebox"><pre><code>Gui, -Caption +hwndhGui +E0x80000
Gui, Show, NA
w := h := 100

pToken := Gdip_Startup()
hbm := CreateDIBSection(w, h)
hdc := CreateCompatibleDC()
obm := SelectObject(hdc, hbm)
G := Gdip_GraphicsFromHDC(hdc)
Gdip_SetSmoothingMode(G, 4)
FillRectangle(G, 0xffeeeeee, 0, 0, w, h)
FillRectangle(G, 0xffbbeeaa, 0, 0, w, 30)
FillRectangle(G, 0x20000000, 40, 0, 50, 30)
UpdateLayeredWindow(hGui, hdc, (A_ScreenWidth - w)//2, (A_ScreenHeight - h)//2, w, h)

SelectObject(hdc, obm)
DeleteObject(hbm)
DeleteDC(hdc)
Gdip_DeleteGraphics(G)
Gdip_Shutdown(pToken)

FillRectangle(G, color, x, y, w, h)  {
   pBrush := Gdip_BrushCreateSolid(color)
   Gdip_FillRectangle(G, pBrush, x, y, w, h)
   Gdip_DeleteBrush(pBrush)
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2018-12-17T09:23:44Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=130437#p130437</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: GDI+ нарисовать прозрачный элемент поверх другого]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=130418#p130418" />
			<content type="html"><![CDATA[<p>Вопрос к знатокам графики.<br />Следующий код заполняет окно серым цветом и рисует два прямоугольника.<br />Как нарисовать второй прямоугольник прозрачным относительно первого прямоугольника?<br />Чтобы, по итогу, получилось так.<br /><span class="postimg"><img src="https://i.imgur.com/Te7bC05.png" alt="https://i.imgur.com/Te7bC05.png" /></span><br /></p><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header" data-lang-open="открыть спойлер" data-lang-close="скрыть спойлер"><strong>+</strong>&nbsp;открыть спойлер</div><div class="fancy_spoiler"><div class="codebox"><pre><code>#include Gdip.ahk

if(!Gdip_Startup())
	msgbox % &quot;Can&#039;t start GDI+&quot;

Gui, -Caption +hwndhwnd +E0x80000 ; WS_EX_LAYERED
Gui, Show, W1 H1 Hide


w:=100,h:=100
x:=(A_ScreenWidth-w)//2
y:=(A_ScreenHeight-h)//2

hdc:=CreateCompatibleDC()
hbm:=CreateDIBSection(w, h)
obm:=SelectObject(hdc, hbm)



;Background
;=======================================
bkg_hdc1:=DrawNewPoly(w,h,0xFFeeeeee)
BitBlt(hdc, 0,0, w, h, bkg_hdc1, 0,0,0)
;=======================================


;Green
;=======================================
figure_hdc1:=DrawNewPoly(w,30,0xFFbbeeaa)
BitBlt(hdc, 0,0, w, 30, figure_hdc1, 0,0,0)
;=======================================


;Black
;=======================================
figure_hdc2:=DrawNewPoly(50,30,0x20000000)
BitBlt(hdc, 40,0, 50, 30, figure_hdc2, 0,0,0)
;=======================================


UpdateLayeredWindow(hwnd, hdc, x, y, w, h)
Gui, Show
return


DrawNewPoly(w,h,argb) {
	hbm:=CreateDIBSection(w, h)
	hdc:=CreateCompatibleDC()
	obm:=SelectObject(hdc, hbm)
	g:=Gdip_GraphicsFromHDC(hdc)

	brush:=Gdip_BrushCreateSolid(argb)

	res:=Gdip_FillRectangle(g,brush,0,0,w,h)

	Gdip_DeleteBrush(brush)
	return hdc
}
f1::reload</code></pre></div></div></div>]]></content>
			<author>
				<name><![CDATA[MandarinKa02]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34409</uri>
			</author>
			<updated>2018-12-15T18:47:56Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=130418#p130418</id>
		</entry>
</feed>
