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: show caption and close button only while calculator window is active

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

authored by

Marco Maroni
Claude Fable 5
and committed by
Tangled
(Jul 15, 2026, 1:16 PM +0300) a2bbb5fb 0e900bbf

+42
+38
CalculatorWindow.cpp
··· 361 361 return 0; 362 362 } 363 363 364 + LRESULT CCalculatorWindow::OnActivate(UINT, WPARAM wParam, LPARAM, BOOL& bHandled) 365 + { 366 + // Caption + close button only while the window is active. 367 + ApplyFrameStyle(LOWORD(wParam) != WA_INACTIVE); 368 + bHandled = FALSE; // let default activation processing run too 369 + return 0; 370 + } 371 + 372 + void CCalculatorWindow::ApplyFrameStyle(bool visible) 373 + { 374 + if (visible == m_captionVisible) 375 + return; 376 + m_captionVisible = visible; 377 + 378 + // The client rect must not move on screen: capture it before the style change. 379 + RECT rc; GetClientRect(&rc); 380 + ::MapWindowPoints(m_hWnd, NULL, (LPPOINT)&rc, 2); 381 + 382 + LONG_PTR style = GetWindowLongPtr(GWL_STYLE); 383 + if (visible) 384 + style |= (WS_CAPTION | WS_SYSMENU); 385 + else 386 + style &= ~(WS_CAPTION | WS_SYSMENU); 387 + SetWindowLongPtr(GWL_STYLE, style); 388 + 389 + RECT r = rc; 390 + AdjustWindowRectEx(&r, (DWORD)style, FALSE, 391 + (DWORD)GetWindowLongPtr(GWL_EXSTYLE)); 392 + 393 + // Guard: never push the top edge above the work area. 394 + RECT work; SystemParametersInfo(SPI_GETWORKAREA, 0, &work, 0); 395 + if (r.top < work.top) 396 + ::OffsetRect(&r, 0, work.top - r.top); 397 + 398 + SetWindowPos(NULL, r.left, r.top, r.right - r.left, r.bottom - r.top, 399 + SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOACTIVATE); 400 + } 401 + 364 402 void CCalculatorWindow::Paint(HDC hdc, const RECT& rcPaint) const 365 403 { 366 404 m_ptrVisualStyle->DrawBackground(m_hWnd, hdc, rcPaint);
+4
CalculatorWindow.h
··· 42 42 MESSAGE_HANDLER(WM_CLOSE, OnClose) 43 43 MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown) 44 44 MESSAGE_HANDLER(WM_EXITSIZEMOVE, OnExitSizeMove) 45 + MESSAGE_HANDLER(WM_ACTIVATE, OnActivate) 45 46 END_MSG_MAP() 46 47 47 48 // Handler prototypes: ··· 59 60 LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 60 61 LRESULT OnLButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 61 62 LRESULT OnExitSizeMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 63 + LRESULT OnActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 62 64 63 65 void Paint(HDC hdc, const RECT& rcPaint) const; 64 66 // UINT_PTR SetUpdateTimer(); ··· 77 79 BOOL m_fHasFocus; 78 80 bool m_shown = false; 79 81 CAutoPtr<CVisualStyle> m_ptrVisualStyle; 82 + void ApplyFrameStyle(bool visible); 83 + bool m_captionVisible = true; // window is created with WS_CAPTION | WS_SYSMENU 80 84 81 85 //const DateFormat* m_pDateFormat; 82 86 //SYSTEMTIME m_stLocalTime;