Something went wrong. Try again.
A simple, small calculator placed discreetly near the Windows Taskbar or anywhere on the screen taskbar-calculator.marcomaroni.it
Something went wrong. Try again.
taskbar-calculator CalculatorWindow.h
3.8 kB · 107 lines
C
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108#pragma once
using namespace ATL;
////////////////////////////////////////////////////////////////////////////////// CCalculatorWindow class CVisualStyle;
class CCalculatorWindow : public CWindowImpl<CCalculatorWindow>{public: CCalculatorWindow(); ~CCalculatorWindow();
BOOL CreateStandalone(); void ToggleVisible(); bool IsShown() const { return m_shown; } void PlaceInitial(); void RebuildForDpi(UINT dpi);
POINTL CalcMinimalSize() const; POINTL CalcIdealSize() const; LONG MinClientWidth(UINT dpi) const; BOOL HasFocus() const;
LRESULT OnEditKeyDown(HWND hWnd, WPARAM wParam, LPARAM lParam); LRESULT OnEditChar(HWND hWnd, WPARAM wParam, LPARAM lParam); void ProcessChar(HWND hWnd, TCHAR c); bool FormatString(LPCTSTR strInput, LPTSTR strOutput);
bool ReadRegionalSettings();
BEGIN_MSG_MAP(CCalculatorWindow) MESSAGE_HANDLER(WM_DESTROY, OnDestroy) MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground) MESSAGE_HANDLER(WM_PAINT, OnPaint) MESSAGE_HANDLER(WM_SETFOCUS, OnFocus) MESSAGE_HANDLER(WM_KILLFOCUS, OnFocus) MESSAGE_HANDLER(WM_POWERBROADCAST, OnPowerBroadcast) MESSAGE_HANDLER(WM_THEMECHANGED, OnThemeChanged) MESSAGE_HANDLER(WM_CLOSE, OnClose) MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown) MESSAGE_HANDLER(WM_EXITSIZEMOVE, OnExitSizeMove) MESSAGE_HANDLER(WM_ACTIVATE, OnActivate) MESSAGE_HANDLER(WM_DPICHANGED, OnDpiChanged) MESSAGE_HANDLER(WM_ENTERSIZEMOVE, OnEnterSizeMove) MESSAGE_HANDLER(WM_SIZING, OnSizing)END_MSG_MAP()
// Handler prototypes:// LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);// LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);// LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
private: LRESULT OnFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnEraseBackground(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnPowerBroadcast(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnThemeChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnLButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnExitSizeMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnDpiChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnEnterSizeMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnSizing(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
void Paint(HDC hdc, const RECT& rcPaint) const; SIZE MeasureString(LPCTSTR text) const;// UINT_PTR SetUpdateTimer();
calc m_calc; CString m_unformatInputString; CString m_unformatOutputString;
TCHAR m_cDecSepStandard; TCHAR m_cMigSepStandard;
UINT m_numDecimalDigit;
private: BOOL m_fHasFocus; bool m_shown = false; UINT m_dpi = 96; int m_fixedFrameHeight = 0; int m_minResizeWidth = 0; bool m_didResize = false; // a WM_SIZING happened in the current move/size loop CAutoPtr<CVisualStyle> m_ptrVisualStyle; void ApplyFrameStyle(bool visible); void ClampToWorkArea(); bool m_captionVisible = true; // window is created with WS_CAPTION | WS_SYSMENU
//const DateFormat* m_pDateFormat; //SYSTEMTIME m_stLocalTime; //mutable CString m_sDateString;
HWND m_hwndEdit;};
////////////////////////////////////////////////////////////////////////////////