Windows SDL 1.x: Add menu item to system menu to allow restoring the menu bar if you've hidden it.

This commit is contained in:
Jonathan Campbell
2018-01-06 22:08:33 -08:00
parent 13564f6321
commit 1bcc2e6f4f
3 changed files with 40 additions and 4 deletions

View File

@@ -715,3 +715,6 @@
#define ID_GLIDE_EMU_AUTO 819
#define ID_ALWAYS_ON_TOP 820
#if defined(WIN32)
# define ID_WIN_SYSMENU_RESTOREMENU 0x0F00
#endif

View File

@@ -738,6 +738,32 @@ void Mount_Img(char drive, std::string realpath) {
}
}
void DOSBox_SetSysMenu(void) {
MENUITEMINFO mii;
HMENU sysmenu;
BOOL s;
sysmenu = GetSystemMenu(GetHWND(), TRUE); // revert, so we can reapply menu items
sysmenu = GetSystemMenu(GetHWND(), FALSE);
if (sysmenu == NULL) return;
s = AppendMenu(sysmenu, MF_SEPARATOR, -1, "");
{
const char *msg = "Show menu &bar";
memset(&mii, 0, sizeof(mii));
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_ID | MIIM_STRING | MIIM_STATE;
mii.fState = MFS_ENABLED;
mii.wID = ID_WIN_SYSMENU_RESTOREMENU;
mii.dwTypeData = (LPTSTR)(msg);
mii.cch = strlen(msg)+1;
s = InsertMenuItem(sysmenu, GetMenuItemCount(sysmenu), TRUE, &mii);
}
}
void DOSBox_SetMenu(void) {
if(!menu.gui) return;
@@ -791,6 +817,7 @@ void DOSBox_RefreshMenu(void) {
DrawMenuBar(GetHWND());
return;
}
DOSBox_SetSysMenu();
if(menu.toggle)
DOSBox_SetMenu();
else
@@ -835,6 +862,7 @@ void ToggleMenu(bool pressed) {
menu.toggle=false;
DOSBox_NoMenu();
}
DOSBox_SetSysMenu();
}
void MENU_Check_Drive(HMENU handle, int cdrom, int floppy, int local, int image, int automount, int umount, char drive) {

View File

@@ -3624,7 +3624,6 @@ void GFX_Events() {
switch (event.type) {
#ifdef __WIN32__
case SDL_SYSWMEVENT : {
if(menu_compatible) break;
switch( event.syswm.msg->msg ) {
case WM_SYSCOMMAND:
switch (event.syswm.msg->wParam) {
@@ -3639,6 +3638,9 @@ void GFX_Events() {
GFX_SwitchFullScreen();
menu.maxwindow=false;
break;
case ID_WIN_SYSMENU_RESTOREMENU:
DOSBox_SetMenu();
break;
}
case WM_MOVE:
break;
@@ -3664,6 +3666,7 @@ void GFX_Events() {
if (sdl.mouse.locked) GFX_CaptureMouse();
#if defined(WIN32)
if (sdl.desktop.fullscreen)
GFX_ForceFullscreenExit();
#endif
@@ -5056,6 +5059,8 @@ int main(int argc, char* argv[]) {
#if !defined(C_SDL2)
/* -- -- decide whether to set menu */
void DOSBox_SetSysMenu(void);
DOSBox_SetSysMenu();
if (menu_gui && !control->opt_nomenu)
DOSBox_SetMenu();
#endif