<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Windows Menus and Allegro 5</title>
		<link>http://www.allegro.cc/forums/view/607657</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Fri, 24 Jun 2011 23:31:45 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I am messing about testing to see weather I can add a menu with allegro 5&#39;s displays and it turns out that I can. However I have no idea on how I can interact with it :/</p><p>Screenshot of the menu.<br /><span class="remote-thumbnail"><span class="json">{"name":"604334","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/7\/b\/7bb82cebd2746f0c51d3cf92a43e1675.png","w":646,"h":508,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/7\/b\/7bb82cebd2746f0c51d3cf92a43e1675"}</span><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/7/b/7bb82cebd2746f0c51d3cf92a43e1675-240.jpg" alt="604334" width="240" height="188" /></span></p><p>Code for menu creation.
</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">  7</span>    HMENU hMenuBar<span class="k2">;</span>
<span class="number">  8</span>    HMENU hMenu<span class="k2">;</span>
<span class="number">  9</span>
<span class="number"> 10</span>    hMenuBar <span class="k3">=</span> CreateMenu<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 11</span>    hMenu <span class="k3">=</span> CreateMenu<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 12</span>
<span class="number"> 13</span>    <span class="p">#define IDM_FILE_NEW 1</span>
<span class="number"> 14</span>    <span class="p">#define IDM_FILE_OPEN 2</span>
<span class="number"> 15</span>    <span class="p">#define IDM_FILE_QUIT 3</span>
<span class="number"> 16</span>
<span class="number"> 17</span>    AppendMenu<span class="k2">(</span> hMenu, MF_STRING, IDM_FILE_NEW, <span class="s">"&amp;New"</span> <span class="k2">)</span><span class="k2">;</span>
<span class="number"> 18</span>    AppendMenu<span class="k2">(</span> hMenu, MF_STRING, IDM_FILE_OPEN, <span class="s">"&amp;Open"</span> <span class="k2">)</span><span class="k2">;</span>
<span class="number"> 19</span>    AppendMenu<span class="k2">(</span> hMenu, MF_SEPARATOR, <span class="n">0</span>, NULL <span class="k2">)</span><span class="k2">;</span>
<span class="number"> 20</span>    AppendMenu<span class="k2">(</span> hMenu, MF_STRING, IDM_FILE_QUIT, <span class="s">"&amp;Quit"</span> <span class="k2">)</span><span class="k2">;</span>
<span class="number"> 21</span>
<span class="number"> 22</span>    AppendMenu<span class="k2">(</span> hMenuBar, MF_POPUP, <span class="k2">(</span>UINT_PTR<span class="k2">)</span>hMenu, <span class="s">"&amp;File"</span> <span class="k2">)</span><span class="k2">;</span>
<span class="number"> 23</span>
<span class="number"> 24</span>    HWND hWnd <span class="k3">=</span> engine-&gt;GetHWND<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 25</span>    SetMenu<span class="k2">(</span> hWnd, hMenuBar <span class="k2">)</span><span class="k2">;</span>
</div></div><p>

Is it possible to do this?</p><p>Edit: I have looked around the MSDN and I have found this.
</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>UINT WINAPI GetMenuState<span class="k2">(</span>
<span class="number"> 2</span>  __in  HMENU hMenu,
<span class="number"> 3</span>  __in  UINT uId,
<span class="number"> 4</span>  __in  UINT uFlags
<span class="number"> 5</span><span class="k2">)</span><span class="k2">;</span>
</div></div><p>

I am just about to go out so I cannot test it yet but fingers crossed this is what I was looking for.</p><p>I shall edit this post or reply when I get back and have tested it. I shall be a few hours though.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Desmond Taylor)</author>
		<pubDate>Sun, 19 Jun 2011 15:41:30 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Usually the way you interact with it is via the WNDPROC function, when the window gets a WM_COMMAND message, you respond to it. I don&#39;t think you can access it though since Allegro is the one that accesses it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (jmasterx)</author>
		<pubDate>Sun, 19 Jun 2011 20:12:33 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Nope, my idea didn&#39;t work. Oh well, Back to messing with something else instead.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Desmond Taylor)</author>
		<pubDate>Sun, 19 Jun 2011 21:37:32 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I just committed to SVN a function that would help:
</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">bool</span> al_add_win_window_callback<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,
   <span class="k1">bool</span> <span class="k2">(</span><span class="k3">*</span>callback<span class="k2">)</span><span class="k2">(</span><a href="http://www.allegro.cc/manual/ALLEGRO_DISPLAY"><span class="a">ALLEGRO_DISPLAY</span></a> <span class="k3">*</span>, UINT, WPARAM, LPARAM<span class="k2">)</span><span class="k2">)</span>
</pre></div></div><p>

It could be used to intercept the messages that the menu generates:</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">bool</span> handle_menu_message<span class="k2">(</span><a href="http://www.allegro.cc/manual/ALLEGRO_DISPLAY"><span class="a">ALLEGRO_DISPLAY</span></a> <span class="k3">*</span>d, UINT m, WPARAM w, LPARAM l<span class="k2">)</span>
<span class="k2">{</span>
  <span class="k1">if</span> <span class="k2">(</span>m <span class="k3">=</span><span class="k3">=</span> WM_COMMAND<span class="k2">)</span>
  <span class="k2">{</span>
    <span class="k1">int</span> id <span class="k3">=</span> LOWORD<span class="k2">(</span>w<span class="k2">)</span><span class="k2">;</span>
    <span class="c">// generate some event</span>
    <span class="k1">return</span> <span class="k1">true</span><span class="k2">;</span> <span class="c">// tells Allegro not to process message</span>
  <span class="k2">}</span>
  <span class="k1">return</span> <span class="k1">false</span><span class="k2">;</span>
<span class="k2">}</span>

al_add_win_window_callback<span class="k2">(</span>display, handle_menu_message<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

There&#39;s also a good chance that the native dialogs addon will support cross platform menus in SVN/5.2 within the next couple of weeks.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Fri, 24 Jun 2011 21:58:17 +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/607657/922544#target">Matthew Leverton</a> said:</div><div class="quote"><p>There&#39;s also a good chance that the native dialogs addon will support cross platform menus in SVN/5.2 within the next couple of weeks.</p></div></div><p>
About that, it occurred to me that it might be a good idea to look at cross-platform APIs like Qt or GTK and see how they handle the per application/per window issue on different platforms to get some pointers on how to do this (if GTK now has a proper OS X port, the last time I looked at it I could only get the X11 port to work).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Fri, 24 Jun 2011 22:33:50 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p><a href="http://doc.qt.nokia.com/4.7-snapshot/mac-differences.html#menu-bar">http://doc.qt.nokia.com/4.7-snapshot/mac-differences.html#menu-bar</a></p><p>It sounds as if it updates the main system menu as you switch windows. That probably involves &quot;deleting&quot; the current system menu and rebuilding it from scratch on every display switch. If that&#39;s doable on OS X/Allegro, then I think it makes the most sense from a cross platform standpoint.</p><p>If a person wants the same menu on every window, then he should call <span class="source-code">al_set_window_menu<span class="k2">(</span>display, menu<span class="k2">)</span></span> after every time he creates a display.</p><p>Somewhere else it states that if one window has multiple menus (a case we wouldn&#39;t support in Allegro), only the outermost/first menu is uses.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Fri, 24 Jun 2011 22:52:43 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I so want to test this out but my machine has broken so now I&#39;m stuck on Puppy Linux with no compiling tools or anything. I tried using Windows XP on here and it just crashes and so does Debian 6.0.</p><p>Looks like there will be a good update when I get my new PC in about 4-5 weeks.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Desmond Taylor)</author>
		<pubDate>Fri, 24 Jun 2011 23:31:45 +0000</pubDate>
	</item>
</rss>
