[MSPAINT] Save ToolBox visibility (#5167)
authorKatayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
Sat, 18 Mar 2023 08:19:56 +0000 (17:19 +0900)
committerKatayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
Sat, 18 Mar 2023 08:20:43 +0000 (17:20 +0900)
According to my registry analysis, the target value is HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Applets\Paint\General-Bar3:Visible.
- Add ShowToolBox registry setting.
CORE-18867

base/applications/mspaint/main.cpp
base/applications/mspaint/registry.cpp
base/applications/mspaint/registry.h
base/applications/mspaint/winproc.cpp

index 75e8075..933ef86 100644 (file)
@@ -193,7 +193,9 @@ _tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR lpszArgument
     haccel = LoadAccelerators(hThisInstance, MAKEINTRESOURCE(800));
 
     RECT toolBoxContainerPos = {2, 2, 2 + 52, 2 + 350};
     haccel = LoadAccelerators(hThisInstance, MAKEINTRESOURCE(800));
 
     RECT toolBoxContainerPos = {2, 2, 2 + 52, 2 + 350};
-    toolBoxContainer.Create(hwnd, toolBoxContainerPos, NULL, WS_CHILD | WS_VISIBLE);
+    toolBoxContainer.Create(hwnd, toolBoxContainerPos, NULL, WS_CHILD);
+    if (registrySettings.ShowToolBox)
+        toolBoxContainer.ShowWindow(SW_SHOWNOACTIVATE);
     /* creating the tool settings child window */
     RECT toolSettingsWindowPos = {5, 208, 5 + 42, 208 + 140};
     toolSettingsWindow.Create(toolBoxContainer.m_hWnd, toolSettingsWindowPos, NULL, WS_CHILD | WS_VISIBLE);
     /* creating the tool settings child window */
     RECT toolSettingsWindowPos = {5, 208, 5 + 42, 208 + 140};
     toolSettingsWindow.Create(toolBoxContainer.m_hWnd, toolSettingsWindowPos, NULL, WS_CHILD | WS_VISIBLE);
index f23ce12..bb97301 100644 (file)
@@ -73,6 +73,7 @@ void RegistrySettings::LoadPresets(INT nCmdShow)
     ShowTextTool = TRUE;
     ShowStatusBar = TRUE;
     ShowPalette = TRUE;
     ShowTextTool = TRUE;
     ShowStatusBar = TRUE;
     ShowPalette = TRUE;
+    ShowToolBox = TRUE;
 
     LOGFONT lf;
     GetObject(GetStockObject(DEFAULT_GUI_FONT), sizeof(lf), &lf);
 
     LOGFONT lf;
     GetObject(GetStockObject(DEFAULT_GUI_FONT), sizeof(lf), &lf);
@@ -139,6 +140,12 @@ void RegistrySettings::Load(INT nCmdShow)
         ReadString(text, _T("TypeFaceName"), strFontName, strFontName);
     }
 
         ReadString(text, _T("TypeFaceName"), strFontName, strFontName);
     }
 
+    CRegKey bar3;
+    if (bar3.Open(paint, _T("General-Bar3"), KEY_READ) == ERROR_SUCCESS)
+    {
+        ReadDWORD(bar3, _T("Visible"), ShowToolBox);
+    }
+
     CRegKey bar4;
     if (bar4.Open(paint, _T("General-Bar4"), KEY_READ) == ERROR_SUCCESS)
     {
     CRegKey bar4;
     if (bar4.Open(paint, _T("General-Bar4"), KEY_READ) == ERROR_SUCCESS)
     {
@@ -202,6 +209,12 @@ void RegistrySettings::Store()
         text.SetStringValue(_T("TypeFaceName"), strFontName);
     }
 
         text.SetStringValue(_T("TypeFaceName"), strFontName);
     }
 
+    CRegKey bar3;
+    if (bar3.Create(paint, _T("General-Bar3")) == ERROR_SUCCESS)
+    {
+        bar3.SetDWORDValue(_T("Visible"), ShowToolBox);
+    }
+
     CRegKey bar4;
     if (bar4.Create(paint, _T("General-Bar4")) == ERROR_SUCCESS)
     {
     CRegKey bar4;
     if (bar4.Create(paint, _T("General-Bar4")) == ERROR_SUCCESS)
     {
index ce932a1..d70e82e 100644 (file)
@@ -42,6 +42,7 @@ public:
     DWORD ShowTextTool;
     DWORD ShowStatusBar;
     DWORD ShowPalette;
     DWORD ShowTextTool;
     DWORD ShowStatusBar;
     DWORD ShowPalette;
+    DWORD ShowToolBox;
 
     enum WallpaperStyle {
         TILED,
 
     enum WallpaperStyle {
         TILED,
index fc99822..e121a4f 100644 (file)
@@ -749,7 +749,8 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
             break;
 
         case IDM_VIEWTOOLBOX:
             break;
 
         case IDM_VIEWTOOLBOX:
-            toolBoxContainer.ShowWindow(::IsWindowVisible(toolBoxContainer) ? SW_HIDE : SW_SHOW);
+            registrySettings.ShowToolBox = !toolBoxContainer.IsWindowVisible();
+            toolBoxContainer.ShowWindow(registrySettings.ShowToolBox ? SW_SHOWNOACTIVATE : SW_HIDE);
             alignChildrenToMainWindow();
             break;
         case IDM_VIEWCOLORPALETTE:
             alignChildrenToMainWindow();
             break;
         case IDM_VIEWCOLORPALETTE: