<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>window icon</title>
		<link>http://www.allegro.cc/forums/view/618660</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Fri, 27 May 2022 00:48:52 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Is there no way to specify an icon BEFORE the window is displayed for the first time? I see the default window icon, then I change it to a desired icon, then just before the window closes, I see the default icon again. It&#39;s a little thing but it&#39;s visual annoyance.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (tinyBigGAMES)</author>
		<pubDate>Wed, 11 May 2022 22:57:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I load the icon immediately after display creation. I can&#39;t even tell the difference. And the window closes so quickly as well. What are you doing different that you even notice it?</p><p>easy answer, no.</p><p>harder answer, probably. Normally windows programs include a compiled resource.rc file. How to get Allegro to load your icon from that file is unknown. You could probably add a resource.rc file to the library itself then load the icon from it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (DanielH)</author>
		<pubDate>Thu, 12 May 2022 02:00:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>How do you change to the desired icon, can you show us the code?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (torhu)</author>
		<pubDate>Thu, 12 May 2022 02:36:54 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>the Allegro way or the Windows way? I was assuming Windows. Maybe you meant Linux.</p><p>The Allegro way<br /><span class="source-code"><span class="k1">void</span> <a href="http://www.allegro.cc/manual/al_set_display_icon"><span class="a">al_set_display_icon</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/ALLEGRO_DISPLAY"><span class="a">ALLEGRO_DISPLAY</span></a> <span class="k3">*</span>display, <a href="http://www.allegro.cc/manual/ALLEGRO_BITMAP"><span class="a">ALLEGRO_BITMAP</span></a> <span class="k3">*</span>icon<span class="k2">)</span><span class="k2">;</span></span></p><p>As for Windows, that&#39;s a bit more complicated.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (DanielH)</author>
		<pubDate>Thu, 12 May 2022 02:43:53 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="source-code"><div class="toolbar"><span class="button numbers"><b>#</b></span><span class="button select">Select</span><span class="button expand">Expand</span></div><div class="inner"><span class="number">  1</span>function TGVWindow.Open<span class="k2">(</span>aWidth: Integer<span class="k2">;</span> aHeight: Integer<span class="k2">;</span> aTitle: string<span class="k2">)</span><span class="k2">:</span> Boolean<span class="k2">;</span>
<span class="number">  2</span>var
<span class="number">  3</span>  LMarshaller: TMarshaller<span class="k2">;</span>
<span class="number">  4</span>begin
<span class="number">  5</span>  Result <span class="k2">:</span><span class="k3">=</span> False<span class="k2">;</span>
<span class="number">  6</span>  <span class="k1">if</span> FHandle <span class="k3">&lt;</span><span class="k3">&gt;</span> nil then Exit<span class="k2">;</span>
<span class="number">  7</span>  <a href="http://www.allegro.cc/manual/al_set_new_display_flags"><span class="a">al_set_new_display_flags</span></a><span class="k2">(</span>ALLEGRO_OPENGL_3_0 <span class="k1">or</span> ALLEGRO_RESIZABLE <span class="k1">or</span> ALLEGRO_PROGRAMMABLE_PIPELINE<span class="k2">)</span><span class="k2">;</span>
<span class="number">  8</span>  <a href="http://www.allegro.cc/manual/al_set_new_display_option"><span class="a">al_set_new_display_option</span></a><span class="k2">(</span>ALLEGRO_COMPATIBLE_DISPLAY, <span class="n">1</span>, ALLEGRO_REQUIRE<span class="k2">)</span><span class="k2">;</span>
<span class="number">  9</span>  <a href="http://www.allegro.cc/manual/al_set_new_display_option"><span class="a">al_set_new_display_option</span></a><span class="k2">(</span>ALLEGRO_VSYNC, <span class="n">2</span>, ALLEGRO_SUGGEST<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 10</span>  <a href="http://www.allegro.cc/manual/al_set_new_display_option"><span class="a">al_set_new_display_option</span></a><span class="k2">(</span>ALLEGRO_CAN_DRAW_INTO_BITMAP, <span class="n">1</span>, ALLEGRO_REQUIRE<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 11</span>  <a href="http://www.allegro.cc/manual/al_set_new_display_option"><span class="a">al_set_new_display_option</span></a><span class="k2">(</span>ALLEGRO_SAMPLE_BUFFERS, <span class="n">1</span>, ALLEGRO_SUGGEST<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 12</span>  <a href="http://www.allegro.cc/manual/al_set_new_display_option"><span class="a">al_set_new_display_option</span></a><span class="k2">(</span>ALLEGRO_SAMPLES, <span class="n">8</span>, ALLEGRO_SUGGEST<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 13</span>  al_set_new_window_title<span class="k2">(</span>LMarshaller.AsUtf8<span class="k2">(</span>aTitle<span class="k2">)</span>.ToPointer<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 14</span>  FHandle <span class="k2">:</span><span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_create_display"><span class="a">al_create_display</span></a><span class="k2">(</span>aWidth, aHeight<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 15</span>  <span class="k1">if</span> FHandle <span class="k3">=</span> nil then Exit<span class="k2">;</span>
<span class="number"> 16</span>  FHWnd <span class="k2">:</span><span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_get_win_window_handle"><span class="a">al_get_win_window_handle</span></a><span class="k2">(</span>FHandle<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 17</span>  SetWindowLong<span class="k2">(</span>FHwnd, GWL_STYLE, GetWindowLong<span class="k2">(</span>FHWnd, GWL_STYLE<span class="k2">)</span> <span class="k1">and</span> <span class="k2">(</span><span class="k1">not</span> WS_MAXIMIZEBOX<span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 18</span>  GV.Util.LoadDefaultIcon<span class="k2">(</span><a href="http://www.allegro.cc/manual/al_get_win_window_handle"><span class="a">al_get_win_window_handle</span></a><span class="k2">(</span>FHandle<span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 19</span>  FWidth <span class="k2">:</span><span class="k3">=</span> aWidth<span class="k2">;</span>
<span class="number"> 20</span>  FHeight <span class="k2">:</span><span class="k3">=</span> aHeight<span class="k2">;</span>
<span class="number"> 21</span>  FScale <span class="k2">:</span><span class="k3">=</span> <span class="n">1</span><span class="k2">;</span>
<span class="number"> 22</span>  FRenderTarget <span class="k2">:</span><span class="k3">=</span> nil<span class="k2">;</span>
<span class="number"> 23</span>  <a href="http://www.allegro.cc/manual/al_register_event_source"><span class="a">al_register_event_source</span></a><span class="k2">(</span>GV.Queue, <a href="http://www.allegro.cc/manual/al_get_display_event_source"><span class="a">al_get_display_event_source</span></a><span class="k2">(</span>FHandle<span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 24</span>  ScaleToDPI<span class="k2">;</span>
<span class="number"> 25</span>end<span class="k2">;</span>
</div></div><p>

after al_create_display, there is a small delay, enough to see the icon, after al_create_display, everything else runs quickly. LoadDefaultIcon will use the main icon that in the EXE. On shutdown, my custom icon goes away, I see the default icon for a moment. You would not notice it for the most part, but once you do notice it, you can&#39;t unnotice the fact that it shows the default icon, then my custom one. Visual annoyance. </p><p>Here is a video showing what I mean:<br /><a href="https://www.youtube.com/watch?v=DzkC3DXn37o">https://www.youtube.com/watch?v=DzkC3DXn37o</a></p><p>And what is going on with the forums today. It takes forever for the page to show. Here is the message I get: Page generated in 170.773603 seconds. This is an eternity <img src="http://www.allegro.cc/forums/smileys/shocked.gif" alt=":o" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (tinyBigGAMES)</author>
		<pubDate>Thu, 12 May 2022 04:16:34 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I think the only way to acheive that is to actually build the resource into the executable. I get the same behaviour if I change the icon after creating the display. The only way to make the icon persistent is to actually compile it as a resource, but I only know how to do this in CodeBlocks....</p><p>(Ps the site has been misbehaving for a long time now!)</p><p>[EDIT] actually I just tested that, and the icon only appears for the console window, not the allegro_display. Back to the drawing board!!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Dizzy Egg)</author>
		<pubDate>Thu, 12 May 2022 16:56:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>that exe has an embedded icon. I get the icon from the exe resource. The problem is the allegro does not look for it by default or there is no way to set an icon for a new window. If it would just look for a default group icon inside the exe would solve the problem. SDL now does this. You only need to have a &quot;main&quot; icon resource in the executable, and it will pick it up. If I knew enough about the working of the project and where to make the changes, I would attempt to make the modification. Since I do not code in c/c++ (only dabble enough to get the repo compiled), I don&#39;t know where to go in and do it else I surely would. I may have to try at some point. Now when my app starts up, I&#39;m drawn to that default icon, arrrrrrg. <img src="http://www.allegro.cc/forums/smileys/cheesy.gif" alt=";D" border="0" />. Maybe someone in the know can add this support?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (tinyBigGAMES)</author>
		<pubDate>Thu, 12 May 2022 23:47:57 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Windows Explorer will load the first icon resource from the executable and display it as the file&#39;s icon. You can use the same icon for the window icon, but you have to load the resource yourself, and set it as the window icon using the Windows API functions for this.</p><p>RC file:
</p><div class="source-code snippet"><div class="inner"><pre>IDI_ICON1               ICON    DISCARDABLE     <span class="s">"something.ico"</span>
</pre></div></div><p>

Relevant code:
</p><div class="source-code snippet"><div class="inner"><pre>  HWND winhandle<span class="k2">;</span>
  HICON icon<span class="k2">;</span>

  icon <span class="k3">=</span> LoadIcon<span class="k2">(</span>GetModuleHandle<span class="k2">(</span>NULL<span class="k2">)</span>, <span class="s">"IDI_ICON1"</span><span class="k2">)</span><span class="k2">;</span>
  <span class="k1">if</span> <span class="k2">(</span>icon<span class="k2">)</span> <span class="k2">{</span>
    winhandle <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_get_win_window_handle"><span class="a">al_get_win_window_handle</span></a><span class="k2">(</span>display<span class="k2">)</span><span class="k2">;</span>
    SetClassLongPtr<span class="k2">(</span>winhandle, GCLP_HICON, <span class="k2">(</span>LONG_PTR<span class="k2">)</span>icon<span class="k2">)</span><span class="k2">;</span>
    SetClassLongPtr<span class="k2">(</span>winhandle, GCLP_HICONSM, <span class="k2">(</span>LONG_PTR<span class="k2">)</span>icon<span class="k2">)</span><span class="k2">;</span>
  <span class="k2">}</span>
</pre></div></div><p>

EDIT: Saw your reply now, don&#39;t know if this info is of much use, then...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (torhu)</author>
		<pubDate>Thu, 12 May 2022 23:51:57 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I don’t think there’s much can be done, aside from editing the allegro source, but I’m open to being wrong…
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Dizzy Egg)</author>
		<pubDate>Fri, 13 May 2022 01:29:44 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>cmon, your duck duck fu is weak</p><p><a href="https://duckduckgo.com/?kl=us-en&amp;q=embed+icon+file+gcc+msvc&amp;t=seamonkey&amp;ia=web">https://duckduckgo.com/?kl=us-en&amp;q=embed+icon+file+gcc+msvc&amp;t=seamonkey&amp;ia=web</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Fri, 13 May 2022 01:37:03 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Meh, I think that’s ok for the console/exe window, but I think the allegro display that zooms in/out on windows still flashes the default icon…that being said. I’ve had a few beers and am contemplating a donor kebab, so…
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Dizzy Egg)</author>
		<pubDate>Fri, 13 May 2022 01:40:41 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It might need a tweak to Allegro, but could be as simple as setting hIcon to something in this <a href="https://github.com/liballeg/allegro5/blob/0e94a88b990ad4d013e0a7186f751635b6b159b4/src/win/wwindow.c#L1004-L1026">code</a>.
</p><div class="source-code"><div class="toolbar"><span class="button numbers"><b>#</b></span><span class="button select">Select</span><span class="button expand">Expand</span></div><div class="inner"><span class="number">  1</span><span class="k1">int</span> _al_win_init_window<span class="k2">(</span><span class="k2">)</span>
<span class="number">  2</span><span class="k2">{</span>
<span class="number">  3</span>   <span class="c">// Create A Window Class Structure</span>
<span class="number">  4</span>   window_class.cbClsExtra <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span>
<span class="number">  5</span>   window_class.cbWndExtra <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span>
<span class="number">  6</span>   window_class.hbrBackground <span class="k3">=</span> NULL<span class="k2">;</span>
<span class="number">  7</span>   window_class.hCursor <span class="k3">=</span> NULL<span class="k2">;</span>
<span class="number">  8</span>   window_class.hIcon <span class="k3">=</span> NULL<span class="k2">;</span>
<span class="number">  9</span>   window_class.hInstance <span class="k3">=</span> GetModuleHandle<span class="k2">(</span>NULL<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 10</span>   window_class.lpfnWndProc <span class="k3">=</span> window_callback<span class="k2">;</span>
<span class="number"> 11</span>   window_class.lpszClassName <span class="k3">=</span> TEXT<span class="k2">(</span><span class="s">"ALEX"</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 12</span>   window_class.lpszMenuName <span class="k3">=</span> NULL<span class="k2">;</span>
<span class="number"> 13</span>   window_class.style <span class="k3">=</span> CS_VREDRAW<span class="k3">|</span>CS_HREDRAW<span class="k3">|</span>CS_OWNDC<span class="k2">;</span>
<span class="number"> 14</span>
<span class="number"> 15</span>
<span class="number"> 16</span>   RegisterClass<span class="k2">(</span><span class="k3">&amp;</span>window_class<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 17</span>
<span class="number"> 18</span>
<span class="number"> 19</span>   <span class="k1">if</span> <span class="k2">(</span>_al_win_msg_call_proc <span class="k3">=</span><span class="k3">=</span> <span class="n">0</span> <span class="k3">&amp;</span><span class="k3">&amp;</span> _al_win_msg_suicide <span class="k3">=</span><span class="k3">=</span> <span class="n">0</span><span class="k2">)</span> <span class="k2">{</span>
<span class="number"> 20</span>      _al_win_msg_call_proc <span class="k3">=</span> RegisterWindowMessage<span class="k2">(</span>TEXT<span class="k2">(</span><span class="s">"Allegro call proc"</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 21</span>      _al_win_msg_suicide <span class="k3">=</span> RegisterWindowMessage<span class="k2">(</span>TEXT<span class="k2">(</span><span class="s">"Allegro window suicide"</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 22</span>   <span class="k2">}</span>
<span class="number"> 23</span>
<span class="number"> 24</span>
<span class="number"> 25</span>   <span class="k1">return</span> <span class="k1">true</span><span class="k2">;</span>
<span class="number"> 26</span><span class="k2">}</span>
</div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Peter Hull)</author>
		<pubDate>Fri, 13 May 2022 10:56:00 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I tried these:</p><div class="source-code snippet"><div class="inner"><pre>window_class.hIcon <span class="k3">=</span> <span class="k2">(</span>HICON<span class="k2">)</span>LoadImage<span class="k2">(</span>GetModuleHandle<span class="k2">(</span>NULL<span class="k2">)</span>, <span class="s">"MAINICON"</span>, IMAGE_ICON, <span class="n">32</span>, <span class="n">32</span>, LR_SHARED<span class="k2">)</span><span class="k2">;</span>
window_class.hIcon <span class="k3">=</span> LoadIcon<span class="k2">(</span>GetModuleHandle<span class="k2">(</span>NULL<span class="k2">)</span>, <span class="s">"MAINICON"</span><span class="k2">)</span><span class="k2">;</span>
window_class.hIcon <span class="k3">=</span> LoadIcon<span class="k2">(</span>GetModuleHandle<span class="k2">(</span>NULL<span class="k2">)</span>, IDI_HAND<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

In Delphi, if you add an ICON to an EXE the default icon resource name will be MAINICON, but it&#39;s still showing the default windows icon. I even tried IDE_HAND which is at should be something different, but still shows the default one.</p><p>GetModuleHandle(NULL), should get the handle of the EXE therefore it should be picking up the resource from the EXE, correct?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (tinyBigGAMES)</author>
		<pubDate>Fri, 13 May 2022 20:08:29 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The first argument should be NULL when loading a standard icon.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (torhu)</author>
		<pubDate>Fri, 13 May 2022 20:37:57 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I can&#39;t test myself but maybe try <span class="source-code">TEXT<span class="k2">(</span><span class="s">"MAINICON"</span><span class="k2">)</span></span> instead of just <span class="source-code"><span class="s">"MAINICON"</span></span>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Peter Hull)</author>
		<pubDate>Fri, 13 May 2022 22:54:50 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p><span class="source-code">window_class.hIcon <span class="k3">=</span> LoadIcon<span class="k2">(</span>GetModuleHandle<span class="k2">(</span>NULL<span class="k2">)</span>, TEXT<span class="k2">(</span><span class="s">"MAINICON"</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span></span></p><p>YES! That was it, now it will pick up a resource name MAINICON from the calling process.</p><p>Many thanks to all that helped.👍
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (tinyBigGAMES)</author>
		<pubDate>Sat, 14 May 2022 09:47:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Right, TEXT will turn &quot;string&quot; into L&quot;string&quot; for you. I think the compiler was supposed to warn you about the type mismatch there. <img src="http://www.allegro.cc/forums/smileys/lipsrsealed.gif" alt=":-X" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (torhu)</author>
		<pubDate>Thu, 26 May 2022 19:23:43 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Torhu, do you know, is there a way to specify &#39;the first icon&#39; in an exe file without knowing its name - if so this could be something we could add to Allegro itself.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Peter Hull)</author>
		<pubDate>Thu, 26 May 2022 21:55:49 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/618660/1052394#target">Peter Hull</a> said:</div><div class="quote"><p> Torhu, do you know, is there a way to specify &#39;the first icon&#39; in an exe file without knowing its name - if so this could be something we could add to Allegro itself.</p></div></div><p>It seems you have to enumerate the resource types until you find the icons, then grab the first resource of that type:<br /><a href="https://docs.microsoft.com/en-us/windows/win32/menurc/using-resources#creating-a-resource-list">https://docs.microsoft.com/en-us/windows/win32/menurc/using-resources#creating-a-resource-list</a></p><p>The docs don&#39;t say whether the order of the resources of each type is the same as their order in the .rc files, though. Would probably have to test that.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (torhu)</author>
		<pubDate>Thu, 26 May 2022 22:15:11 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I think it should look for the 1st icon, which will be the numbered icon &quot;1&quot;. MAINICON just points to this as why SDL2 will pick up MAINCON in Delphi. It&#39;s the 1st numbered icon that it&#39;s picking up.</p><p>edit: yeah what torhu said.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (tinyBigGAMES)</author>
		<pubDate>Thu, 26 May 2022 22:50:11 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I think looking for an icon with a specific name is reasonable, makes it more explicit. Allegro 4 used &quot;allegro_icon&quot; as the name.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (torhu)</author>
		<pubDate>Fri, 27 May 2022 00:48:52 +0000</pubDate>
	</item>
</rss>
