Skip to content

Commit

Permalink
Windows SDL 1.x: Add menu item to system menu to allow restoring the …
Browse files Browse the repository at this point in the history
…menu bar if you've hidden it.
  • Loading branch information
joncampbell123 committed Jan 7, 2018
1 parent 13564f6 commit 1bcc2e6
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
5 changes: 4 additions & 1 deletion include/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -714,4 +714,7 @@
#define ID_GLIDE_EMU_OPENGL 818
#define ID_GLIDE_EMU_AUTO 819
#define ID_ALWAYS_ON_TOP 820


#if defined(WIN32)
# define ID_WIN_SYSMENU_RESTOREMENU 0x0F00
#endif
28 changes: 28 additions & 0 deletions src/gui/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -791,6 +817,7 @@ void DOSBox_RefreshMenu(void) {
DrawMenuBar(GetHWND());
return;
}
DOSBox_SetSysMenu();
if(menu.toggle)
DOSBox_SetMenu();
else
Expand Down Expand Up @@ -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) {
Expand Down
11 changes: 8 additions & 3 deletions src/gui/sdlmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand All @@ -3654,7 +3656,7 @@ void GFX_Events() {
}
#endif
case SDL_ACTIVEEVENT:
if (event.active.state & (SDL_APPINPUTFOCUS | SDL_APPACTIVE)) {
if (event.active.state & (SDL_APPINPUTFOCUS | SDL_APPACTIVE)) {
if (event.active.gain) {
if (sdl.desktop.fullscreen && !sdl.mouse.locked)
GFX_CaptureMouse();
Expand All @@ -3664,7 +3666,8 @@ void GFX_Events() {
if (sdl.mouse.locked) GFX_CaptureMouse();

#if defined(WIN32)
GFX_ForceFullscreenExit();
if (sdl.desktop.fullscreen)
GFX_ForceFullscreenExit();
#endif

SetPriority(sdl.priority.nofocus);
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1bcc2e6

Please sign in to comment.