<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Quick Question: HINSTANCE of Allegro</title>
		<link>http://www.allegro.cc/forums/view/590865</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Thu, 05 Apr 2007 07:04:40 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Under Windows, with Allegro, I know how to get the HWND property of the Allegro window, I know how to get the HDC property of Allegro bitmaps...</p><p>...but how do I get the HINSTANCE property of the application while using Allegro&#39;s magic main?</p><p>I know, it&#39;s probably a stupid question, but every so often they come up...</p><p>--- Kris Asick (Gemini)<br />--- <a href="http://www.pixelships.com">http://www.pixelships.com</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kris Asick)</author>
		<pubDate>Wed, 04 Apr 2007 20:21:23 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Google! &quot;get hinstance from hwnd&quot;</p><p><a href="http://cboard.cprogramming.com/archive/index.php/t-60642.html">http://cboard.cprogramming.com/archive/index.php/t-60642.html</a></p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Use GetModuleHandle() (<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/getmodulehandle.asp">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/getmodulehandle.asp</a>) to get a handle to the process (GetModuleHandle() returns a HMODULE, but it&#39;s the same as HINSTANCE on 32 bit windows).
</p></div></div><p>

[append]</p><p>Another Google result says <tt>(HINSTANCE)GetWindowLongA(hWnd, GWL_HINSTANCE), 0L);</tt>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (CGamesPlay)</author>
		<pubDate>Wed, 04 Apr 2007 20:23:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I think the GetWindowLong() approach will work best, seeing as how in the future, HMODULE and HINSTANCE may not be the same thing.</p><p>Thanks! <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" /></p><p>--- Kris Asick (Gemini)<br />--- <a href="http://www.pixelships.com">http://www.pixelships.com</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kris Asick)</author>
		<pubDate>Wed, 04 Apr 2007 20:30:13 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="source-code snippet"><div class="inner"><pre>HWND hWnd           <span class="k3">=</span> NULL<span class="k2">;</span>
HWND hParent        <span class="k3">=</span> NULL<span class="k2">;</span>
HINSTANCE hInstance <span class="k3">=</span> NULL<span class="k2">;</span>

hWnd <span class="k3">=</span> <a href="http://www.allegro.cc/manual/win_get_window" target="_blank"><span class="a">win_get_window</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
hInstance <span class="k3">=</span> <span class="k2">(</span>HINSTANCE<span class="k2">)</span>GetWindowLong<span class="k2">(</span> hWnd, GWL_HINSTANCE <span class="k2">)</span><span class="k2">;</span>
hParent <span class="k3">=</span> <span class="k2">(</span>HWND<span class="k2">)</span>GetWindowLong<span class="k2">(</span> hWnd, GWL_HWNDPARENT <span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (DanielH)</author>
		<pubDate>Wed, 04 Apr 2007 21:12:07 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yep. Figured that out as I looked up GetWindowLong in the MSDN libraries.</p><p>I&#39;m writing my own input handler to override the Allegro one, since I ran into a barricade trying to fix the one in Allegro under the Windows build without breaking Allegro in the process and couldn&#39;t do it. To access DirectInput though, I needed a handle to the application instance, which Allegro didn&#39;t have a built-in command for, but didn&#39;t want to switch from the magic main to WinMain.</p><p>--- Kris Asick (Gemini)<br />--- <a href="http://www.pixelships.com">http://www.pixelships.com</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kris Asick)</author>
		<pubDate>Thu, 05 Apr 2007 07:04:40 +0000</pubDate>
	</item>
</rss>
