summaryrefslogtreecommitdiff
path: root/shared/Taskbar_Seven
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 17:07:15 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 17:07:15 +0200
commit8318453bf9d4fd50b137ff6c6fc8d1fd22aa6395 (patch)
tree975c6e590c31e56007006a23e7b15d0245d75b08 /shared/Taskbar_Seven
parent3.6 (diff)
downloadFreeFileSync-8318453bf9d4fd50b137ff6c6fc8d1fd22aa6395.tar.gz
FreeFileSync-8318453bf9d4fd50b137ff6c6fc8d1fd22aa6395.tar.bz2
FreeFileSync-8318453bf9d4fd50b137ff6c6fc8d1fd22aa6395.zip
3.7
Diffstat (limited to 'shared/Taskbar_Seven')
-rw-r--r--shared/Taskbar_Seven/Taskbar_Seven.vcproj409
-rw-r--r--shared/Taskbar_Seven/dllmain.cpp27
-rw-r--r--shared/Taskbar_Seven/taskbar.cpp160
-rw-r--r--shared/Taskbar_Seven/taskbar.h70
4 files changed, 666 insertions, 0 deletions
diff --git a/shared/Taskbar_Seven/Taskbar_Seven.vcproj b/shared/Taskbar_Seven/Taskbar_Seven.vcproj
new file mode 100644
index 00000000..bf8e0993
--- /dev/null
+++ b/shared/Taskbar_Seven/Taskbar_Seven.vcproj
@@ -0,0 +1,409 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="Taskbar_Seven"
+ ProjectGUID="{70394AEF-5897-4911-AFA1-82EAF0581EFA}"
+ RootNamespace="ShadowDll"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ <Platform
+ Name="x64"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\"
+ IntermediateDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\"
+ ConfigurationType="2"
+ CharacterSet="1"
+ BuildLogFile="$(IntDir)\Build.html"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="_DEBUG;_WINDOWS;_USRDLL;TASKBAR_SEVEN_DLL_EXPORTS"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ SuppressStartupBanner="false"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="Taskbar7_$(PlatformName).dll"
+ LinkIncremental="1"
+ SuppressStartupBanner="false"
+ GenerateDebugInformation="true"
+ ProgramDatabaseFile="$(IntDir)$(TargetName).pdb"
+ SubSystem="2"
+ ProfileGuidedDatabase=""
+ ImportLibrary="$(IntDir)$(TargetName).lib"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug|x64"
+ OutputDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\"
+ IntermediateDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\"
+ ConfigurationType="2"
+ CharacterSet="1"
+ BuildLogFile="$(IntDir)\Build.html"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TargetEnvironment="3"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="_DEBUG;_WINDOWS;_USRDLL;TASKBAR_SEVEN_DLL_EXPORTS"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ SuppressStartupBanner="false"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="Taskbar7_$(PlatformName).dll"
+ LinkIncremental="1"
+ SuppressStartupBanner="false"
+ GenerateDebugInformation="true"
+ ProgramDatabaseFile="$(IntDir)$(TargetName).pdb"
+ SubSystem="2"
+ ProfileGuidedDatabase=""
+ ImportLibrary="$(IntDir)$(TargetName).lib"
+ TargetMachine="17"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\"
+ IntermediateDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\"
+ ConfigurationType="2"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ BuildLogFile="$(IntDir)\Build.html"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ PreprocessorDefinitions="NDEBUG;_WINDOWS;_USRDLL;TASKBAR_SEVEN_DLL_EXPORTS"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ SuppressStartupBanner="false"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="Taskbar7_$(PlatformName).dll"
+ LinkIncremental="1"
+ SuppressStartupBanner="false"
+ GenerateDebugInformation="false"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ LinkTimeCodeGeneration="1"
+ ProfileGuidedDatabase=""
+ ImportLibrary="$(IntDir)$(TargetName).lib"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|x64"
+ OutputDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\"
+ IntermediateDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\"
+ ConfigurationType="2"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ BuildLogFile="$(IntDir)\Build.html"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TargetEnvironment="3"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ PreprocessorDefinitions="NDEBUG;_WINDOWS;_USRDLL;TASKBAR_SEVEN_DLL_EXPORTS"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ SuppressStartupBanner="false"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="Taskbar7_$(PlatformName).dll"
+ LinkIncremental="1"
+ SuppressStartupBanner="false"
+ GenerateDebugInformation="false"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ LinkTimeCodeGeneration="1"
+ ProfileGuidedDatabase=""
+ ImportLibrary="$(IntDir)$(TargetName).lib"
+ TargetMachine="17"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Quelldateien"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\dllmain.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ CompileAsManaged="0"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ CompileAsManaged="0"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ CompileAsManaged="0"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ CompileAsManaged="0"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath=".\taskbar.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Headerdateien"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath=".\taskbar.h"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/shared/Taskbar_Seven/dllmain.cpp b/shared/Taskbar_Seven/dllmain.cpp
new file mode 100644
index 00000000..7db39bff
--- /dev/null
+++ b/shared/Taskbar_Seven/dllmain.cpp
@@ -0,0 +1,27 @@
+// **************************************************************************
+// * This file is part of the FreeFileSync project. It is distributed under *
+// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
+// * Copyright (C) 2008-2010 ZenJu (zhnmju123 AT gmx.de) *
+// **************************************************************************
+//
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+
+BOOL APIENTRY DllMain( HMODULE hModule,
+ DWORD ul_reason_for_call,
+ LPVOID lpReserved
+ )
+{
+ switch (ul_reason_for_call)
+ {
+ case DLL_PROCESS_ATTACH:
+ case DLL_THREAD_ATTACH:
+ case DLL_THREAD_DETACH:
+ case DLL_PROCESS_DETACH:
+ break;
+ }
+ return TRUE;
+}
+
diff --git a/shared/Taskbar_Seven/taskbar.cpp b/shared/Taskbar_Seven/taskbar.cpp
new file mode 100644
index 00000000..4baf2392
--- /dev/null
+++ b/shared/Taskbar_Seven/taskbar.cpp
@@ -0,0 +1,160 @@
+// **************************************************************************
+// * This file is part of the FreeFileSync project. It is distributed under *
+// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
+// * Copyright (C) 2008-2010 ZenJu (zhnmju123 AT gmx.de) *
+// **************************************************************************
+//
+#include "taskbar.h"
+
+#define WIN32_LEAN_AND_MEAN
+#include "windows.h"
+#include <ShObjIdl.h>
+
+#include <map>
+#include <string>
+#include <comdef.h>
+
+
+namespace
+{
+void writeString(const std::wstring& input, wchar_t* output, size_t outputBufferLen)
+{
+ const size_t newSize = min(input.length() + 1, outputBufferLen); //including null-termination
+ memcpy(output, input.c_str(), newSize * sizeof(wchar_t));
+ output[newSize-1] = 0; //if output buffer is too small...
+}
+
+
+std::wstring numberToHexString(const long number)
+{
+ wchar_t result[100];
+ swprintf(result, 100, L"0x%08x", number);
+ return std::wstring(result);
+}
+
+
+std::wstring writeErrorMsg(const wchar_t* input, HRESULT hr)
+{
+ std::wstring output(input);
+ output += L" (";
+ output += numberToHexString(hr);
+ output += L": ";
+ output += _com_error(hr).ErrorMessage();
+ output += L")";
+ return output;
+}
+
+
+using TaskbarSeven::TBHandle;
+typedef std::map<TBHandle, ITaskbarList3*> TaskBarHandleMap;
+
+TaskbarSeven::TBHandle generateHandle()
+{
+ static TBHandle handle = 0;
+ return ++handle; //don't return 0! 0 is reserved for indicating failure
+}
+
+TaskBarHandleMap taskBarHandles;
+
+std::wstring lastErrorMessage;
+}
+//##################################################################################################
+
+
+TaskbarSeven::TBHandle TaskbarSeven::init() //call on app initializaiton; returns handle
+{
+ ITaskbarList3* pto = NULL;
+ HRESULT hr = CoCreateInstance(CLSID_TaskbarList,
+ NULL,
+ CLSCTX_ALL,
+ IID_PPV_ARGS(&pto));
+ if (FAILED(hr))
+ {
+ lastErrorMessage = writeErrorMsg(L"Error calling \"CoCreateInstance\".", hr);
+ return 0;
+ }
+
+ TBHandle newHandle = ::generateHandle();
+ taskBarHandles[newHandle] = pto;
+ return newHandle;
+}
+
+
+void TaskbarSeven::release(TBHandle handle) //release handle on app exit
+{
+ TaskBarHandleMap::const_iterator iter = taskBarHandles.find(handle);
+ if (iter != taskBarHandles.end())
+ {
+ if (iter->second != NULL)
+ iter->second->Release();
+ taskBarHandles.erase(iter);
+ }
+}
+
+
+bool TaskbarSeven::setStatus(TBHandle handle,
+ void* hwnd, //HWND: window assciated to the taskbar icon
+ TaskBarStatus status)
+{
+ TBPFLAG flag = TBPF_NORMAL;
+ switch (status)
+ {
+ case STATUS_NOPROGRESS:
+ flag = TBPF_NOPROGRESS;
+ break;
+ case STATUS_INDETERMINATE:
+ flag = TBPF_INDETERMINATE;
+ break;
+ case STATUS_NORMAL:
+ flag = TBPF_NORMAL;
+ break;
+ case STATUS_ERROR:
+ flag = TBPF_ERROR;
+ break;
+ case STATUS_PAUSED:
+ flag = TBPF_PAUSED;
+ break;
+ }
+
+ ITaskbarList3* pto = taskBarHandles[handle];
+ if (pto)
+ {
+ HRESULT hr = pto->SetProgressState(static_cast<HWND>(hwnd), //[in] HWND hwnd,
+ flag); //[in] TBPFLAG tbpFlags
+ if (FAILED(hr))
+ {
+ lastErrorMessage = writeErrorMsg(L"Error calling \"SetProgressState\".", hr);
+ return false;
+ }
+ }
+ return true;
+}
+
+
+bool TaskbarSeven::setProgress(TBHandle handle,
+ void* hwnd, //HWND: window assciated to the taskbar icon
+ size_t current,
+ size_t total)
+{
+ ITaskbarList3* pto = taskBarHandles[handle];
+
+ if (pto)
+ {
+ HRESULT hr = pto->SetProgressValue(
+ static_cast<HWND>(hwnd), //[in] HWND hwnd,
+ current, //[in] ULONGLONG ullCompleted,
+ total); //[in] ULONGLONG ullTotal
+ if (FAILED(hr))
+ {
+ lastErrorMessage = writeErrorMsg(L"Error calling \"SetProgressValue\".", hr);
+ return false;
+ }
+ }
+ return true;
+}
+
+
+void TaskbarSeven::getLastError(wchar_t* errorMessage, size_t errorBufferLen)
+{
+ writeString(lastErrorMessage, errorMessage, errorBufferLen);
+}
diff --git a/shared/Taskbar_Seven/taskbar.h b/shared/Taskbar_Seven/taskbar.h
new file mode 100644
index 00000000..3b7abc51
--- /dev/null
+++ b/shared/Taskbar_Seven/taskbar.h
@@ -0,0 +1,70 @@
+// **************************************************************************
+// * This file is part of the FreeFileSync project. It is distributed under *
+// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
+// * Copyright (C) 2008-2010 ZenJu (zhnmju123 AT gmx.de) *
+// **************************************************************************
+//
+#ifndef TASKBAR_SEVEN_DLL_H
+#define TASKBAR_SEVEN_DLL_H
+
+#ifdef TASKBAR_SEVEN_DLL_EXPORTS
+#define DLL_FUNCTION_DECLARATION extern "C" __declspec(dllexport)
+#else
+#define DLL_FUNCTION_DECLARATION extern "C" __declspec(dllimport)
+#endif
+
+
+namespace TaskbarSeven
+{
+enum TaskBarStatus
+{
+ STATUS_NOPROGRESS,
+ STATUS_INDETERMINATE,
+ STATUS_NORMAL,
+ STATUS_ERROR,
+ STATUS_PAUSED
+};
+
+typedef size_t TBHandle;
+
+
+//COM needs to be initialized before calling any of these functions! CoInitializeEx/CoUninitialize
+DLL_FUNCTION_DECLARATION
+TBHandle init(); //returns handle; 0 on failure
+
+DLL_FUNCTION_DECLARATION
+void release(TBHandle handle); //release taskbar handle
+
+DLL_FUNCTION_DECLARATION
+bool setStatus(TBHandle handle,
+ void* hwnd, //HWND: window assciated to the taskbar icon
+ TaskBarStatus status);
+
+
+DLL_FUNCTION_DECLARATION
+bool setProgress(TBHandle handle,
+ void* hwnd, //HWND: window assciated to the taskbar icon
+ size_t current,
+ size_t total);
+
+//if any of the functions above returns 'false', this message returns last error
+DLL_FUNCTION_DECLARATION
+void getLastError(wchar_t* errorMessage, size_t errorBufferLen);
+
+
+//function typedefs
+typedef TBHandle (*initFct)();
+typedef void (*releaseFct)(TBHandle handle);
+typedef bool (*setStatusFct)(TBHandle handle, void* hwnd, TaskBarStatus status);
+typedef bool (*setProgressFct)(TBHandle handle, void* hwnd, size_t current, size_t total);
+typedef void (*getLastErrorFct)(wchar_t* errorMessage, size_t errorBufferLen);
+
+//function names (use const pointers to ensure internal linkage)
+const char* const initFctName = "init";
+const char* const releaseFctName = "release";
+const char* const setStatusFctName = "setStatus";
+const char* const setProgressFctName = "setProgress";
+const char* const getLastErrorFctName = "getLastError";
+}
+
+#endif //TASKBAR_SEVEN_DLL_H \ No newline at end of file
bgstack15