xref: /reactos/base/shell/explorer/traydeskbtn.h (revision 898cc566)
1 /*
2  * PROJECT:     ReactOS Explorer
3  * LICENSE:     LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
4  * PURPOSE:     Show Desktop tray button header file
5  * COPYRIGHT:   Copyright 2006-2007 Thomas Weidenmueller <w3seek@reactos.org>
6  *              Copyright 2018-2022 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
7  *              Copyright 2023 Ethan Rodensky <splitwirez@gmail.com>
8  */
9 
10 #pragma once
11 
12 // This window class name is CONFIRMED on Win10 by WinHier.
13 static const WCHAR szTrayShowDesktopButton[] = L"TrayShowDesktopButtonWClass";
14 #define TSDB_CLICK (WM_USER + 100)
15 
16 // The 'Show Desktop' button at the end of the taskbar
17 class CTrayShowDesktopButton :
18     public CWindowImpl<CTrayShowDesktopButton, CWindow, CControlWinTraits>
19 {
20     LONG m_nClickedTime;
21     HTHEME m_hTheme;
22     HTHEME m_hFallbackTheme;
23     MARGINS m_ContentMargins;
24     SIZE m_inset;
25     HICON m_icon;
26     SIZE m_szIcon;
27     BOOL m_highContrastMode;
28     BOOL m_drawWithDedicatedBackground;
29     BOOL m_bHovering;
30     HWND m_hWndTaskbar;
31     CTooltips m_tooltip;
32 
33 public:
34     BOOL m_bPressed;
35     BOOL m_bHorizontal;
36 
37     DECLARE_WND_CLASS_EX(szTrayShowDesktopButton, CS_HREDRAW | CS_VREDRAW, COLOR_3DFACE)
38 
39     BEGIN_MSG_MAP(CTrayShowDesktopButton)
40         MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
41         MESSAGE_HANDLER(WM_NCLBUTTONDOWN, OnLButtonDown)
42         MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp)
43         MESSAGE_HANDLER(WM_NCLBUTTONUP, OnLButtonUp)
44         MESSAGE_HANDLER(WM_SETTINGCHANGE, OnSettingChanged)
45         MESSAGE_HANDLER(WM_THEMECHANGED, OnThemeChanged)
46         MESSAGE_HANDLER(WM_WINDOWPOSCHANGED, OnWindowPosChanged)
47         MESSAGE_HANDLER(WM_PAINT, OnPaint)
48         MESSAGE_HANDLER(WM_PRINTCLIENT, OnPrintClient)
49         MESSAGE_HANDLER(WM_TIMER, OnTimer)
50         MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove)
51         MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
52         MESSAGE_HANDLER(TSDB_CLICK, OnClick)
53     END_MSG_MAP()
54 
55     CTrayShowDesktopButton();
56     INT WidthOrHeight() const;
57     HRESULT DoCreate(HWND hwndParent);
58     VOID Click();
59     BOOL PtInButton(LPPOINT pt) const;
60     VOID StartHovering();
61     LRESULT OnLButtonUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
62     LRESULT OnLButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
63 
64 private:
65     // This function is called from OnPaint and parent.
66     VOID OnDraw(HDC hdc, LPRECT prc);
67     LRESULT OnClick(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
68     LRESULT OnSettingChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
69     LRESULT OnThemeChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
70     LRESULT OnWindowPosChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
71     VOID EnsureWindowTheme(BOOL setTheme);
72     LRESULT OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
73     LRESULT OnPrintClient(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
74     LRESULT OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
75     LRESULT OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
76     LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
77 };
78