1 /*
2 * PROJECT: browseui
3 * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
4 * PURPOSE: ITaskbarList implementation
5 * COPYRIGHT: Copyright 2018 Mark Jansen (mark.jansen@reactos.org)
6 */
7
8 #include "precomp.h"
9
10
11 /***********************************************************************
12 * ITaskbarList2 implementation
13 */
14
15 #define TWM_GETTASKSWITCH (WM_USER + 236)
16
CTaskbarList()17 CTaskbarList::CTaskbarList()
18 : m_hTaskWnd(NULL)
19 {
20 m_ShellHookMsg = RegisterWindowMessageW(L"SHELLHOOK");
21 }
22
~CTaskbarList()23 CTaskbarList::~CTaskbarList()
24 {
25 }
26
TaskWnd()27 HWND CTaskbarList::TaskWnd()
28 {
29 HWND hTrayWnd;
30 if (m_hTaskWnd && ::IsWindow(m_hTaskWnd))
31 return m_hTaskWnd;
32
33 hTrayWnd = FindWindowW(L"Shell_TrayWnd", NULL);
34 if (hTrayWnd)
35 {
36 m_hTaskWnd = (HWND)SendMessageW(hTrayWnd, TWM_GETTASKSWITCH, 0L, 0L);
37 }
38 return m_hTaskWnd;
39 }
40
SendTaskWndShellHook(WPARAM wParam,HWND hWnd)41 void CTaskbarList::SendTaskWndShellHook(WPARAM wParam, HWND hWnd)
42 {
43 HWND hTaskWnd = TaskWnd();
44 if (hTaskWnd && m_ShellHookMsg)
45 ::SendMessageW(hTaskWnd, m_ShellHookMsg, wParam, (LPARAM)hWnd);
46 }
47
48
MarkFullscreenWindow(HWND hwnd,BOOL fFullscreen)49 HRESULT WINAPI CTaskbarList::MarkFullscreenWindow(HWND hwnd, BOOL fFullscreen)
50 {
51 UNIMPLEMENTED;
52 return E_NOTIMPL;
53 }
54
55
56 /***********************************************************************
57 * ITaskbarList implementation
58 */
59
HrInit()60 HRESULT WINAPI CTaskbarList::HrInit()
61 {
62 if (m_ShellHookMsg == NULL)
63 return E_OUTOFMEMORY;
64
65 if (!TaskWnd())
66 return E_HANDLE;
67
68 return S_OK;
69 }
70
AddTab(HWND hwnd)71 HRESULT WINAPI CTaskbarList::AddTab(HWND hwnd)
72 {
73 SendTaskWndShellHook(HSHELL_WINDOWCREATED, hwnd);
74 return S_OK;
75 }
76
DeleteTab(HWND hwnd)77 HRESULT WINAPI CTaskbarList::DeleteTab(HWND hwnd)
78 {
79 SendTaskWndShellHook(HSHELL_WINDOWDESTROYED, hwnd);
80 return S_OK;
81 }
82
ActivateTab(HWND hwnd)83 HRESULT WINAPI CTaskbarList::ActivateTab(HWND hwnd)
84 {
85 SendTaskWndShellHook(HSHELL_WINDOWACTIVATED, hwnd);
86 return S_OK;
87 }
88
SetActiveAlt(HWND hwnd)89 HRESULT WINAPI CTaskbarList::SetActiveAlt(HWND hwnd)
90 {
91 UNIMPLEMENTED;
92 return E_NOTIMPL;
93 }
94
95