A simple, small calculator placed discreetly near the Windows Taskbar or anywhere on the screen
0

Configure Feed

Select the types of activity you want to include in your feed.

feat: add Settings module (registry-backed window position and visibility)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Marco Maroni (Jul 14, 2026, 3:10 PM +0200) fd8bfe98 78d95c64

+62
+49
Settings.cpp
··· 1 + #include "stdafx.h" 2 + #include "Settings.h" 3 + 4 + namespace { 5 + const wchar_t* kKey = L"Software\\TaskbarCalculator"; 6 + 7 + bool ReadDword(const wchar_t* name, DWORD& out) { 8 + HKEY h; 9 + if (RegOpenKeyExW(HKEY_CURRENT_USER, kKey, 0, KEY_QUERY_VALUE, &h) != ERROR_SUCCESS) 10 + return false; 11 + DWORD type = 0, val = 0, size = sizeof(val); 12 + LONG r = RegQueryValueExW(h, name, nullptr, &type, (LPBYTE)&val, &size); 13 + RegCloseKey(h); 14 + if (r != ERROR_SUCCESS || type != REG_DWORD) return false; 15 + out = val; 16 + return true; 17 + } 18 + 19 + void WriteDword(const wchar_t* name, DWORD val) { 20 + HKEY h; 21 + if (RegCreateKeyExW(HKEY_CURRENT_USER, kKey, 0, nullptr, 0, 22 + KEY_SET_VALUE, nullptr, &h, nullptr) != ERROR_SUCCESS) 23 + return; 24 + RegSetValueExW(h, name, 0, REG_DWORD, (const BYTE*)&val, sizeof(val)); 25 + RegCloseKey(h); 26 + } 27 + } 28 + 29 + namespace Settings { 30 + bool LoadWindowPos(POINT& pt) { 31 + DWORD x, y; 32 + if (ReadDword(L"PosX", x) && ReadDword(L"PosY", y)) { 33 + pt.x = (LONG)(INT)x; pt.y = (LONG)(INT)y; 34 + return true; 35 + } 36 + return false; 37 + } 38 + void SaveWindowPos(POINT pt) { 39 + WriteDword(L"PosX", (DWORD)pt.x); 40 + WriteDword(L"PosY", (DWORD)pt.y); 41 + } 42 + bool LoadVisible(bool def) { 43 + DWORD v; 44 + return ReadDword(L"Visible", v) ? (v != 0) : def; 45 + } 46 + void SaveVisible(bool visible) { 47 + WriteDword(L"Visible", visible ? 1 : 0); 48 + } 49 + }
+9
Settings.h
··· 1 + #pragma once 2 + #include <windows.h> 3 + 4 + namespace Settings { 5 + bool LoadWindowPos(POINT& pt); // true if a saved position exists 6 + void SaveWindowPos(POINT pt); 7 + bool LoadVisible(bool def); // returns saved visibility or `def` 8 + void SaveVisible(bool visible); 9 + }
+2
TaskbarCalculator.vcxproj
··· 97 97 <ClCompile Include="Calculator.cpp"> 98 98 <PrecompiledHeader>NotUsing</PrecompiledHeader> 99 99 </ClCompile> 100 + <ClCompile Include="Settings.cpp" /> 100 101 <ClCompile Include="Utils.cpp" /> 101 102 <ClCompile Include="VisualStyle.cpp" /> 102 103 <ClCompile Include="stdafx.cpp"> ··· 106 107 <ItemGroup> 107 108 <ClInclude Include="Calculator.h" /> 108 109 <ClInclude Include="CalculatorWindow.h" /> 110 + <ClInclude Include="Settings.h" /> 109 111 <ClInclude Include="resource.h" /> 110 112 <ClInclude Include="stdafx.h" /> 111 113 <ClInclude Include="targetver.h" />
+2
TaskbarCalculator.vcxproj.filters
··· 17 17 <ItemGroup> 18 18 <ClCompile Include="App.cpp"><Filter>Source Files</Filter></ClCompile> 19 19 <ClCompile Include="Calculator.cpp"><Filter>Source Files</Filter></ClCompile> 20 + <ClCompile Include="Settings.cpp"><Filter>Source Files</Filter></ClCompile> 20 21 <ClCompile Include="Utils.cpp"><Filter>Source Files</Filter></ClCompile> 21 22 <ClCompile Include="VisualStyle.cpp"><Filter>Source Files</Filter></ClCompile> 22 23 <ClCompile Include="stdafx.cpp"><Filter>Source Files</Filter></ClCompile> 23 24 </ItemGroup> 24 25 <ItemGroup> 25 26 <ClInclude Include="Calculator.h"><Filter>Header Files</Filter></ClInclude> 27 + <ClInclude Include="Settings.h"><Filter>Header Files</Filter></ClInclude> 26 28 <ClInclude Include="CalculatorWindow.h"><Filter>Header Files</Filter></ClInclude> 27 29 <ClInclude Include="resource.h"><Filter>Header Files</Filter></ClInclude> 28 30 <ClInclude Include="stdafx.h"><Filter>Header Files</Filter></ClInclude>