![]() |
|
Windows Menu Bar in Allegro 5 |
ph03nix
Member #15,028
April 2013
![]() |
I want to add a windows menu bar (the one directly under the title bar) to an Allegro 5 application I'm working on. I can use SetMenu from Win32 API to add the menu to the window, but to set the callback for the menu options I need access to the WindowProc callback and allegro doesn't seem to allow this. |
Trent Gamblin
Member #261
April 2000
![]() |
The native dialogs addon has native menu support, can't you use that?
|
ph03nix
Member #15,028
April 2013
![]() |
Is it 5.1 only? I'm using 5.0.8 |
Matthew Leverton
Supreme Loser
January 1999
![]() |
The al_win_add_window_callback() function was added for this purpose (the native dialog addon uses it), although it may not have been backported to 5.0 either. |
ph03nix
Member #15,028
April 2013
![]() |
Matthew Leverton said: it may not have been backported to 5.0 either I'm fairly certain it wasn't. Either way, I didn't know about the native dialog in 5.1. I just upgraded and it's doing just what I need! EDIT: Got everything to work, except one thing I need that allegro doesn't seem to offer. I want to know when a menu item with a submenu has been clicked, but it seems you can only check the click event of a menu item without a submenu. It would be even better if I could check whether or not the submenu is opened. How can I achieve this? |
Matthew Leverton
Supreme Loser
January 1999
![]() |
If all three main platforms support that, then I don't see any reason not to allow for it (via a regular menu item click event). But why do you want to do that? |
ph03nix
Member #15,028
April 2013
![]() |
My application hides the mouse automatically, and I don't want it to do so when the menus are being selected. There doesn't seem to be a way to detect when the menus are expanded though, since ALLEGRO_EVENT_MENU_CLICK isn't called on menu items with sub menus. |
Matthew Leverton
Supreme Loser
January 1999
![]() |
Do you get a "display lost focus" event? |
ph03nix
Member #15,028
April 2013
![]() |
The display doesn't lose focus. Oddly enough, if a menu is expanded and the mouse was hidden prior to opening the menu, calling al_show_mouse_cursor() doesn't do anything. That's why I was hoping I could show the mouse before it happens somehow... |
Thomas Fjellstrom
Member #476
June 2000
![]() |
It's probably just a bug that needs to be fixed. The mouse should always show itself when the menu pops up. Would also be nice if it hid itself again after if it was hidden before. -- |
ph03nix
Member #15,028
April 2013
![]() |
In my case the mouse shows when it's moved, and hides after a timer increments while it's stationary, and it always shows when its outside of the application's frame (it shows when over the menu, title bar, etc. Because of that, the mouse is always showing when you open the menu (as it should be, would be incredibly annoying to select it with an invisible mouse). Calling al_show_mouse_cursor() doesn't do anything when a menu is open, but al_hide_mouse_cursor() still does, which is why I'd like to know whether or not a menu has been opened (with an event possibly) so I can skip calling al_hide_mouse_cursor() until the menu is closed. |
Matthew Leverton
Supreme Loser
January 1999
![]() |
Thomas Fjellstrom said: The mouse should always show itself when the menu pops up. Agreed, although probably isn't very straightforward to implement. |
ph03nix
Member #15,028
April 2013
![]() |
I thought perhaps using GetMenu to get the HMENU (since allegro doesn't allow this), and then using GetMenuItemInfo would give me info about the menu I could use to determine the state of the menu, however GetMenuItemInfo requires an integer for position of the menu item, and it seems that the integer passed to al_insert_menu_item representing position doesn't match up with the one windows uses. |
|