I ended up implementing a menu much like yours, but with a couple extra goodies. I imagine your source code looks something like:
HWND hwnd = win_get_window();
HMENU menu_bar = CreateMenu();
// ...
AppendMenu( ... );
SetMenu(hwnd, menu_bar);
And of course the callbacks for WM_COMMAND need to be setup through WNDPROC. In case you, or anyone else was curious, this is actually easy to setup even when using SDL2 via
SDL_SetWindowsMessageHook. It looks like the equivalent for winallegro.h would be: win_set_msg_pre_proc.
I take it then your games only run on Windows then? For my own code I'll have to figure something out for Mac/Linux... I was thinking of just using a .ini file instead of writing code to support the menu bar on other platforms. A simple .ini files is cross platform. Most people play games on Windows, so the OSX/Linux users can just deal with a .ini file.
Here are the points I improved after I implemented a menu very similar to yours:
- Changing the pixel ratio from a lower to a higher ratio can place the window outside of the user's screen. This can be really annoying. I implemented a window position clamper; when the ratio is changed the window is clamped within the screen boundaries. I used AdjustWindowRect. It's actually pretty easy; create a RECT on the stack, initialize it to zero, hand it to AdjustWindowRect, use for style WS_OVERLAPPEDWINDOW (it's a good default). The returned RECT will contain border + menu width/height. Add the rect width/height to your game's current pixel resolution, and clamp the position within bounds of the screen.
- Changing the pixel resolution does not retain the window's center position. The scaling happens from the upper left corner of the window. This is annoying as user will typically center the window on their screen manually, and then adjust the pixel ratio. Then the center of the window moves, and the user must manually adjust the position again. I implemented the scaling ratio callbacks so they scale the window from the center, instead of default top left.
Edit: I also noticed you seem to prefer the check marks for your pixel resolution? Did you use a bunch of CheckMenuItem to manually mark each resolution (1:1, 1:2, 1:3, 1:4) to check/unchecked? I was surprised to see that, since there is already CheckMenuRadioItem. It doesn't use the checkmark visual effect, and instead a circle.
Also I noticed you added in a bunch of MF_SEPARATOR with AppendMenu. Any reason? Did you just think it looked cool? Haha
Edit2: Wow I just noticed you already have your own .ini file setup. Funny