[BROWSEUI] Add ITaskbarList implementation 1141/head
authorMark Jansen <mark.jansen@reactos.org>
Sat, 15 Dec 2018 15:23:22 +0000 (16:23 +0100)
committerMark Jansen <mark.jansen@reactos.org>
Mon, 17 Dec 2018 19:38:38 +0000 (20:38 +0100)
CORE-15424

dll/win32/browseui/CMakeLists.txt
dll/win32/browseui/CTaskbarList.cpp [new file with mode: 0644]
dll/win32/browseui/CTaskbarList.h [new file with mode: 0644]
dll/win32/browseui/browseui.cpp
dll/win32/browseui/browseui.rc
dll/win32/browseui/precomp.h
dll/win32/browseui/res/taskbarlist.rgs [new file with mode: 0644]
dll/win32/browseui/resource.h

index 677544b..8c0de76 100644 (file)
@@ -23,6 +23,8 @@ list(APPEND SOURCE
     browseui.cpp
     browseuiord.cpp
     CAutoComplete.cpp
+    CTaskbarList.cpp
+    CTaskbarList.h
     commonbrowser.cpp
     desktopipc.cpp
     explorerband.cpp
diff --git a/dll/win32/browseui/CTaskbarList.cpp b/dll/win32/browseui/CTaskbarList.cpp
new file mode 100644 (file)
index 0000000..24f6f34
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * PROJECT:     browseui
+ * LICENSE:     LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
+ * PURPOSE:     ITaskbarList implementation
+ * COPYRIGHT:   Copyright 2018 Mark Jansen (mark.jansen@reactos.org)
+ */
+
+#include "precomp.h"
+
+
+/***********************************************************************
+ *   ITaskbarList2 implementation
+ */
+
+#define TWM_GETTASKSWITCH (WM_USER + 236)
+
+CTaskbarList::CTaskbarList()
+    : m_hTaskWnd(NULL)
+{
+    m_ShellHookMsg = RegisterWindowMessageW(L"SHELLHOOK");
+}
+
+CTaskbarList::~CTaskbarList()
+{
+}
+
+HWND CTaskbarList::TaskWnd()
+{
+    HWND hTrayWnd;
+    if (m_hTaskWnd && ::IsWindow(m_hTaskWnd))
+        return m_hTaskWnd;
+
+    hTrayWnd = FindWindowW(L"Shell_TrayWnd", NULL);
+    if (hTrayWnd)
+    {
+        m_hTaskWnd = (HWND)SendMessageW(hTrayWnd, TWM_GETTASKSWITCH, 0L, 0L);
+    }
+    return m_hTaskWnd;
+}
+
+void CTaskbarList::SendTaskWndShellHook(WPARAM wParam, HWND hWnd)
+{
+    HWND hTaskWnd = TaskWnd();
+    if (hTaskWnd && m_ShellHookMsg)
+        ::SendMessageW(hTaskWnd, m_ShellHookMsg, wParam, (LPARAM)hWnd);
+}
+
+
+HRESULT WINAPI CTaskbarList::MarkFullscreenWindow(HWND hwnd, BOOL fFullscreen)
+{
+    UNIMPLEMENTED;
+    return E_NOTIMPL;
+}
+
+
+/***********************************************************************
+ *   ITaskbarList implementation
+ */
+
+HRESULT WINAPI CTaskbarList::HrInit()
+{
+    if (m_ShellHookMsg == NULL)
+        return E_OUTOFMEMORY;
+
+    if (!TaskWnd())
+        return E_HANDLE;
+
+    return S_OK;
+}
+
+HRESULT WINAPI CTaskbarList::AddTab(HWND hwnd)
+{
+    SendTaskWndShellHook(HSHELL_WINDOWCREATED, hwnd);
+    return S_OK;
+}
+
+HRESULT WINAPI CTaskbarList::DeleteTab(HWND hwnd)
+{
+    SendTaskWndShellHook(HSHELL_WINDOWDESTROYED, hwnd);
+    return S_OK;
+}
+
+HRESULT WINAPI CTaskbarList::ActivateTab(HWND hwnd)
+{
+    SendTaskWndShellHook(HSHELL_WINDOWACTIVATED, hwnd);
+    return S_OK;
+}
+
+HRESULT WINAPI CTaskbarList::SetActiveAlt(HWND hwnd)
+{
+    UNIMPLEMENTED;
+    return E_NOTIMPL;
+}
+
diff --git a/dll/win32/browseui/CTaskbarList.h b/dll/win32/browseui/CTaskbarList.h
new file mode 100644 (file)
index 0000000..60cc51a
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * PROJECT:     browseui
+ * LICENSE:     LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
+ * PURPOSE:     ITaskbarList header
+ * COPYRIGHT:   Copyright 2018 Mark Jansen (mark.jansen@reactos.org)
+ */
+
+#ifndef _CTASKBARLIST_H_
+#define _CTASKBARLIST_H_
+
+class CTaskbarList :
+    public CComCoClass<CTaskbarList, &CLSID_TaskbarList>,
+    public CComObjectRootEx<CComMultiThreadModelNoCS>,
+    public ITaskbarList2
+{
+    HWND m_hTaskWnd;
+    UINT m_ShellHookMsg;
+
+    HWND TaskWnd();
+    void SendTaskWndShellHook(WPARAM wParam, HWND hWnd);
+
+public:
+    CTaskbarList();
+    virtual ~CTaskbarList();
+
+    /*** ITaskbarList2 methods ***/
+    virtual HRESULT WINAPI MarkFullscreenWindow(HWND hwnd, BOOL fFullscreen);
+
+    /*** ITaskbarList methods ***/
+    virtual HRESULT STDMETHODCALLTYPE HrInit();
+    virtual HRESULT STDMETHODCALLTYPE AddTab(HWND hwnd);
+    virtual HRESULT STDMETHODCALLTYPE DeleteTab(HWND hwnd);
+    virtual HRESULT STDMETHODCALLTYPE ActivateTab(HWND hwnd);
+    virtual HRESULT STDMETHODCALLTYPE SetActiveAlt(HWND hwnd);
+
+
+    DECLARE_REGISTRY_RESOURCEID(IDR_TASKBARLIST)
+    DECLARE_NOT_AGGREGATABLE(CTaskbarList)
+
+    DECLARE_PROTECT_FINAL_CONSTRUCT()
+
+    BEGIN_COM_MAP(CTaskbarList)
+        COM_INTERFACE_ENTRY_IID(IID_ITaskbarList2, ITaskbarList2)
+        COM_INTERFACE_ENTRY_IID(IID_ITaskbarList, ITaskbarList)
+    END_COM_MAP()
+};
+
+
+#endif // _CTASKBARLIST_H_
index 98a94c2..46272d4 100644 (file)
@@ -141,6 +141,7 @@ OBJECT_ENTRY(CLSID_CCommonBrowser, CCommonBrowser)
 OBJECT_ENTRY(CLSID_GlobalFolderSettings, CGlobalFolderSettings)
 OBJECT_ENTRY(CLSID_InternetToolbar, CInternetToolbar)
 OBJECT_ENTRY(CLSID_CRegTreeOptions, CRegTreeOptions)
+OBJECT_ENTRY(CLSID_TaskbarList, CTaskbarList)
 OBJECT_ENTRY(CLSID_ExplorerBand, CExplorerBand)
 OBJECT_ENTRY(CLSID_ProgressDialog, CProgressDialog)
 OBJECT_ENTRY(CLSID_ISFBand, CISFBand)
index aa8c343..28899d1 100644 (file)
@@ -47,6 +47,7 @@ IDR_AUTOCOMPLETE REGISTRY "res/autocomplete.rgs"
 IDR_ACLISTISF REGISTRY "res/shellautocomplete.rgs"
 IDR_ISFBAND REGISTRY "res/isfband.rgs"
 IDR_ACLCUSTOMMRU REGISTRY "res/custommru.rgs"
+IDR_TASKBARLIST REGISTRY "res/taskbarlist.rgs"
 
 #include <reactos/manifest_dll.rc>
 
index 5ee3ee0..e646759 100644 (file)
@@ -51,6 +51,7 @@
 #include "commonbrowser.h"
 #include "globalfoldersettings.h"
 #include "regtreeoptions.h"
+#include "CTaskbarList.h"
 #include "explorerband.h"
 #include "CProgressDialog.h"
 #include "browseui.h"
diff --git a/dll/win32/browseui/res/taskbarlist.rgs b/dll/win32/browseui/res/taskbarlist.rgs
new file mode 100644 (file)
index 0000000..607b407
--- /dev/null
@@ -0,0 +1,13 @@
+HKCR
+{
+       NoRemove CLSID
+       {
+               ForceRemove {56FDF344-FD6D-11D0-958A-006097C9A090} = s 'Task bar communication'
+               {
+                       InprocServer32 = s '%MODULE%'
+                       {
+                               val ThreadingModel = s 'Apartment'
+                       }
+               }
+       }
+}
index dc0d8e6..1d9f96a 100644 (file)
 #define IDR_ACLISTISF            142
 #define IDR_ISFBAND              143
 #define IDR_ACLCUSTOMMRU         144
+#define IDR_TASKBARLIST          145
 
 #define IDS_SMALLICONS           12301
 #define IDS_LARGEICONS           12302