<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Making The Cursor Vanish</title>
		<link>http://www.allegro.cc/forums/view/590933</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Tue, 10 Apr 2007 03:42:02 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Making the Windows system cursor vanish when windowed is easy under Allegro. Just call install_mouse() and it automatically happens. No problem.</p><p>My problem however is I want the cursor to disappear but <u>don&#39;t</u> want to call install_mouse() because I don&#39;t want the Allegro mouse drivers to load. (Since the whole point here is to replace them with my own.)</p><p>So far I&#39;ve tried calling each of the various Allegro mouse functions that can make the cursor vanish without success. I&#39;ve also tried using SetClassLong(), SetCursor() and ShowCursor(), all without success.</p><p>So either I&#39;m passing the wrong values to those SDK functions, or Allegro&#39;s internal Window handler is doing something which is preventing my changes from taking hold.</p><p>I haven&#39;t even been able to get the cursor to change to something other than the default Windows arrow.</p><p>For example, you would think this line would change the system cursor to the hourglass while over the Allegro window:
</p><div class="source-code snippet"><div class="inner"><pre><span class="c">// Called AFTER Allegro Window is Initialized</span>
SetClassLong<span class="k2">(</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>,GCL_HCURSOR,<span class="k2">(</span><span class="k1">long</span><span class="k2">)</span>LoadCursor<span class="k2">(</span>NULL, IDC_WAIT<span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>
Except it doesn&#39;t do anything.</p><p>I&#39;m still trying things but while I&#39;m at that, does anyone have any quick solutions?</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>Tue, 10 Apr 2007 02:25:24 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>No idea, but Allegro recent versions offer support for hardware cursors and, between all, you can show the hourglass, so a quick look at that code could help.</p><p>Another opinion I&#39;m having while writing, but for which I&#39;m not 100% sure is that your SetClassLong() could be working with GDI, while you&#39;re using the DirectX driver.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Marco Radaelli)</author>
		<pubDate>Tue, 10 Apr 2007 03:30:26 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
No idea, but Allegro recent versions offer support for hardware cursors and, between all, you can show the hourglass, so a quick look at that code could help.
</p></div></div><p>

I&#39;ve been looking through the Allegro source. All of the Allegro mouse functions do not work unless a mouse driver is installed, due to the nature of Allegro using virtual tables to call everything.</p><p>Beyond that, I&#39;ve discovered that the default Allegro window intercepts WM_SETCURSOR messages as such:</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">if</span> <span class="k2">(</span><span class="k3">!</span>user_wnd_proc <span class="k3">|</span><span class="k3">|</span> _mouse_installed<span class="k2">)</span> <span class="k2">{</span>
            mouse_set_syscursor<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
            <span class="k1">return</span> <span class="n">1</span><span class="k2">;</span>  <span class="c">/* not TRUE */</span>
         <span class="k2">}</span>
</pre></div></div><p>

...and then that function ALWAYS calls SetCursor(), even if the mouse drivers are not installed, and the call to SetCursor() when the mouse drivers are not loaded is <i>always</i> IDC_ARROW:</p><div class="source-code snippet"><div class="inner"><pre><span class="c">/* mouse_set_syscursor: [window thread]</span>
<span class="c"> *  Selects whatever system cursor we should display.</span>
<span class="c"> */</span>
<span class="k1">int</span> mouse_set_syscursor<span class="k2">(</span><span class="k1">void</span><span class="k2">)</span>
<span class="k2">{</span>
   HWND allegro_wnd <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>
   <span class="k1">if</span> <span class="k2">(</span><span class="k2">(</span>mouse_dinput_device <span class="k3">&amp;</span><span class="k3">&amp;</span> _mouse_on<span class="k2">)</span> <span class="k3">|</span><span class="k3">|</span> <span class="k2">(</span>gfx_driver <span class="k3">&amp;</span><span class="k3">&amp;</span> <span class="k3">!</span>gfx_driver-&gt;windowed<span class="k2">)</span><span class="k2">)</span> <span class="k2">{</span>
      SetCursor<span class="k2">(</span>_win_hcursor<span class="k2">)</span><span class="k2">;</span>
      <span class="c">/* Make sure the cursor is removed by the system. */</span>
      PostMessage<span class="k2">(</span>allegro_wnd, WM_MOUSEMOVE, <span class="n">0</span>, <span class="n">0</span><span class="k2">)</span><span class="k2">;</span>
   <span class="k2">}</span>
   <span class="k1">else</span>
      SetCursor<span class="k2">(</span>LoadCursor<span class="k2">(</span>NULL, IDC_ARROW<span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>

   <span class="k1">return</span> <span class="n">0</span><span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p>

So it seems like Allegro overrides all attempts to change the system cursor when the mouse driver isn&#39;t installed. I would almost call this a bug. The else statement in that code should be setting the cursor to the cursor registered in the class object registered by the window and not assuming the cursor will always be IDC_ARROW when not using the mouse drivers.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Another opinion I&#39;m having while writing, but for which I&#39;m not 100% sure is that your SetClassLong() could be working with GDI, while you&#39;re using the DirectX driver.
</p></div></div><p>

DirectX has no cursor support. All work with cursors must be done at the API level under Windows.</p><p>.<b>EDIT:</b> Allegro is very much taking over what cursor shows up. I discovered that the result of the API call GetCursor() does NOT match the cursor that shows up in an Allegro window! (At least, with the mouse drivers disabled.)</p><p>So as it stands, unless I define my own window and override the built-in Allegro one, disabling the mouse cursor without installing the Allegro mouse drivers is impossible. <img src="http://www.allegro.cc/forums/smileys/angry.gif" alt="&gt;:(" /></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>Tue, 10 Apr 2007 03:42:02 +0000</pubDate>
	</item>
</rss>
