From 3b85d4f0c7ef0ee1490a2d5583838f4c090baf1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hrdli=C4=8Dka?= Date: Thu, 23 Apr 2020 12:58:19 +0200 Subject: [PATCH 1/2] win: Add a placeholder menuitem for the Media menu This makes it possible to change the position of the menu by only editing the resource script itself. --- src/include/86box/resource.h | 2 ++ src/win/86Box.rc | 1 + src/win/win_stbar.c | 29 +++++++++++++++++++++++------ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/include/86box/resource.h b/src/include/86box/resource.h index 60990f691..59dc27d0d 100644 --- a/src/include/86box/resource.h +++ b/src/include/86box/resource.h @@ -300,6 +300,8 @@ #define IDM_VID_GRAY_GREEN 40083 #define IDM_VID_GRAY_WHITE 40084 +#define IDM_MEDIA 40085 + #ifdef USE_DISCORD #define IDM_DISCORD 40090 #endif diff --git a/src/win/86Box.rc b/src/win/86Box.rc index 214dd945a..caba77e71 100644 --- a/src/win/86Box.rc +++ b/src/win/86Box.rc @@ -112,6 +112,7 @@ BEGIN MENUITEM "CGA/PCjr/Tandy/E&GA/(S)VGA overscan", IDM_VID_OVERSCAN MENUITEM "Change contrast for &monochrome display", IDM_VID_CGACON END + MENUITEM "&Media", IDM_MEDIA POPUP "&Tools" BEGIN MENUITEM "&Settings...", IDM_CONFIG diff --git a/src/win/win_stbar.c b/src/win/win_stbar.c index 0dfd7af1d..080afad72 100644 --- a/src/win/win_stbar.c +++ b/src/win/win_stbar.c @@ -1215,6 +1215,27 @@ StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) } +void +MediaMenuCreate(HWND hwndParent, uintptr_t idStatus, HINSTANCE hInst) +{ + HMENU hmenu; + LPWSTR lpMenuName; + + hmenu = GetMenu(hwndParent); + hmenuMedia = CreatePopupMenu(); + + int len = GetMenuString(hmenu, IDM_MEDIA, NULL, 0, MF_BYCOMMAND); + lpMenuName = malloc((len + 1) * sizeof(WCHAR)); + GetMenuString(hmenu, IDM_MEDIA, lpMenuName, len + 1, MF_BYCOMMAND); + + InsertMenu(hmenu, IDM_MEDIA, MF_BYCOMMAND | MF_STRING | MF_POPUP, (UINT_PTR)hmenuMedia, lpMenuName); + RemoveMenu(hmenu, IDM_MEDIA, MF_BYCOMMAND); + DrawMenuBar(hwndParent); + + free(lpMenuName); +} + + /* API: Create and set up the Status Bar window. */ void StatusBarCreate(HWND hwndParent, uintptr_t idStatus, HINSTANCE hInst) @@ -1222,7 +1243,6 @@ StatusBarCreate(HWND hwndParent, uintptr_t idStatus, HINSTANCE hInst) RECT rectDialog; int dw, dh; uint8_t i; - HMENU hmenu; /* Load our icons into the cache for faster access. */ for (i = 16; i < 18; i++) @@ -1305,11 +1325,8 @@ StatusBarCreate(HWND hwndParent, uintptr_t idStatus, HINSTANCE hInst) SendMessage(hwndSBAR, SB_SETTEXT, 0 | SBT_NOBORDERS, (LPARAM)L"Welcome to 86Box !"); - hmenu = GetMenu(hwndParent); - hmenuMedia = CreatePopupMenu(); - InsertMenu(hmenu, 2, MF_BYPOSITION | MF_STRING | MF_POPUP, (UINT_PTR)hmenuMedia, plat_get_string(IDS_2126)); - DrawMenuBar(hwndParent); - + MediaMenuCreate(hwndParent, idStatus, hInst); + sb_ready = 1; } From cab0bb845ad375d9f83318161c939ed7c950061f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hrdli=C4=8Dka?= Date: Thu, 23 Apr 2020 13:02:14 +0200 Subject: [PATCH 2/2] win: Move the statusbar initial text to resources --- src/include/86box/language.h | 2 +- src/win/86Box.rc | 2 +- src/win/win_stbar.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/include/86box/language.h b/src/include/86box/language.h index 7aa2e17ee..9b3065be9 100644 --- a/src/include/86box/language.h +++ b/src/include/86box/language.h @@ -99,7 +99,7 @@ #define IDS_2123 2123 // "Unable to initialize Ghostscript..." #define IDS_2124 2124 // "MO %i (%03i): %ls" #define IDS_2125 2125 // "MO images (*.IM?)\0*.IM..." -#define IDS_2126 2126 // "Media" +#define IDS_2126 2126 // "Welcome to 86Box!" #define IDS_4096 4096 // "Hard disk (%s)" #define IDS_4097 4097 // "%01i:%01i" diff --git a/src/win/86Box.rc b/src/win/86Box.rc index caba77e71..c71fb8b43 100644 --- a/src/win/86Box.rc +++ b/src/win/86Box.rc @@ -916,7 +916,7 @@ BEGIN IDS_2123 "Unable to initialize Ghostscript, gsdll32.dll is required for automatic convertion of PostScript files to PDF.\n\nAny documents sent to the generic PostScript printer will be saved as PostScript files (.ps)." IDS_2124 "MO %i (%03i): %ls" IDS_2125 "MO images (*.IM?)\0*.IM?\0All files (*.*)\0*.*\0" - IDS_2126 "&Media" + IDS_2126 "Welcome to 86Box!" END STRINGTABLE DISCARDABLE diff --git a/src/win/win_stbar.c b/src/win/win_stbar.c index 080afad72..bdbd13f87 100644 --- a/src/win/win_stbar.c +++ b/src/win/win_stbar.c @@ -1323,7 +1323,7 @@ StatusBarCreate(HWND hwndParent, uintptr_t idStatus, HINSTANCE hInst) sb_parts++; SendMessage(hwndSBAR, SB_SETPARTS, (WPARAM)sb_parts, (LPARAM)iStatusWidths); SendMessage(hwndSBAR, SB_SETTEXT, 0 | SBT_NOBORDERS, - (LPARAM)L"Welcome to 86Box !"); + (LPARAM)plat_get_string(IDS_2126)); MediaMenuCreate(hwndParent, idStatus, hInst);