├── src ├── ReadMe.txt ├── res │ ├── icon.pdn │ ├── demohelper256.png │ └── GitHub-socialpreview.png ├── DemoHelper.ico ├── DemoHelper.rc2 ├── last │ └── version.h ├── stdafx.cpp ├── version.in ├── compatibility.manifest ├── DemoHelper.h ├── stdafx.h ├── ColorDlg.h ├── MagnifierWindow.h ├── KeyboardOverlay.h ├── MouseOverlay.h ├── KeyboardOverlayD2D.h ├── RectSelectionWnd.h ├── ColorButton.h ├── ColorDlg.cpp ├── resource.h ├── DemoHelper.cpp ├── Graphics.cpp ├── MagnifierWindow.cpp ├── KeyboardOverlay.cpp ├── MemDC.h ├── MainWindow.h ├── DemoHelper.vcxproj.filters ├── OptionsDlg.cpp ├── MouseOverlay.cpp ├── ColorButton.cpp ├── KeyboardOverlayD2D.cpp ├── RectSelectionWnd.cpp ├── DemoHelper.rc ├── Commands.cpp └── DemoHelper.vcxproj ├── choco ├── demohelper.nuspec └── chocolateyInstall.ps1 ├── .gitmodules ├── .tgitconfig ├── .editorconfig ├── .gitignore ├── versioninfo.build ├── version.build.in ├── CODE_OF_CONDUCT.md ├── azure-pipelines.yml ├── README.md ├── DemoHelper.sln ├── default.build.user.tmpl ├── .github └── workflows │ └── codeql-analysis.yml ├── tools └── checkyear.js ├── .clang-format ├── default.build └── LICENSE /src/ReadMe.txt: -------------------------------------------------------------------------------- 1 | DemoHelper: a small application for presentations -------------------------------------------------------------------------------- /src/res/icon.pdn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stefankueng/demohelper/HEAD/src/res/icon.pdn -------------------------------------------------------------------------------- /src/DemoHelper.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stefankueng/demohelper/HEAD/src/DemoHelper.ico -------------------------------------------------------------------------------- /src/DemoHelper.rc2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stefankueng/demohelper/HEAD/src/DemoHelper.rc2 -------------------------------------------------------------------------------- /choco/demohelper.nuspec: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stefankueng/demohelper/HEAD/choco/demohelper.nuspec -------------------------------------------------------------------------------- /src/res/demohelper256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stefankueng/demohelper/HEAD/src/res/demohelper256.png -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "sktoolslib"] 2 | path = sktoolslib 3 | url = https://github.com/stefankueng/sktoolslib.git 4 | -------------------------------------------------------------------------------- /src/res/GitHub-socialpreview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stefankueng/demohelper/HEAD/src/res/GitHub-socialpreview.png -------------------------------------------------------------------------------- /.tgitconfig: -------------------------------------------------------------------------------- 1 | [hook "precommit"] 2 | cmdline = WScript %root%\\\\tools\\\\checkyear.js 3 | wait = true 4 | show = false 5 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | [*.{cpp,cxx,h,hpp,c,txt,build}] 2 | end_of_line = crlf 3 | indent_style = space 4 | indent_size = 4 5 | charset = utf-8-bom 6 | -------------------------------------------------------------------------------- /src/last/version.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define FILEVER 1, 0, 0, 0 4 | #define PRODUCTVER 1, 0, 0, 0 5 | #define STRFILEVER "1.0.0.0\0" 6 | #define STRPRODUCTVER "1.0.0.0\0" 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.vs 2 | /obj 3 | /src/DemoHelper.vcxproj.user 4 | /src/*.aps 5 | /bin 6 | /default.build.user 7 | /choco/package 8 | /src/version.h 9 | /version.build 10 | /signinfo.txt 11 | /_ReSharper.Caches 12 | -------------------------------------------------------------------------------- /src/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // DemoHelper.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | -------------------------------------------------------------------------------- /versioninfo.build: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /version.build.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/version.in: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define FILEVER $MajorVersion$, $MinorVersion$, $MicroVersion$, $WCLOGCOUNT$ 4 | #define PRODUCTVER $MajorVersion$, $MinorVersion$, $MicroVersion$, $WCLOGCOUNT$ 5 | #define STRFILEVER "$MajorVersion$.$MinorVersion$.$MicroVersion$.$WCLOGCOUNT$\0" 6 | #define STRPRODUCTVER "$MajorVersion$.$MinorVersion$.$MicroVersion$.$WCLOGCOUNT$\0" 7 | 8 | #define DH_VERMAJOR $MajorVersion$ 9 | #define DH_VERMINOR $MinorVersion$ 10 | #define DH_VERMICRO $MicroVersion$ 11 | #define DH_VERBUILD $WCLOGCOUNT$ 12 | #define DH_VERDATE "$WCDATE$" 13 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code of Conduct 2 | 3 | Don't have one. Don't want one. 4 | 5 | That's the short version. 6 | 7 | Now the _long version_: 8 | 9 | 1. Having a code of conduct means forcing rules on our community. We don't want that. We want to be free of restrictions and just get the project going. 10 | 2. We don't care about your political views, your race, gender, hair color, tatoos or whatever. We just don't. And we don't ask. Because it has nothing to do with this project. 11 | 3. We do care about the project, and the code. And nothing else. 12 | 13 | If we can't be civil among each other, then having a code of conduct won't help either. 14 | -------------------------------------------------------------------------------- /choco/chocolateyInstall.ps1: -------------------------------------------------------------------------------- 1 | $ErrorActionPreference = 'Stop'; 2 | $packageName = 'demohelper' 3 | $url64 = 'https://github.com/stefankueng/demohelper/releases/download/$MajorVersion$.$MinorVersion$.$MicroVersion$/DemoHelper-$MajorVersion$.$MinorVersion$.$MicroVersion$.zip' 4 | $checksum64 = '$checksum64$' 5 | $checksumType64 = 'sha256' 6 | $toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)" 7 | 8 | Install-ChocolateyZipPackage -PackageName '$packageName' ` 9 | -UnzipLocation "$toolsDir" ` 10 | -Url64bit "$url64" ` 11 | -Checksum64 "$checksum64" ` 12 | -ChecksumType64 "$checksumType64" 13 | -------------------------------------------------------------------------------- /src/compatibility.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /azure-pipelines.yml: -------------------------------------------------------------------------------- 1 | # .NET Desktop 2 | # Build and run tests for .NET Desktop or Windows classic desktop solutions. 3 | # Add steps that publish symbols, save build artifacts, and more: 4 | # https://docs.microsoft.com/azure/devops/pipelines/apps/windows/dot-net 5 | 6 | trigger: 7 | - master 8 | 9 | pool: 10 | vmImage: 'windows-latest' 11 | 12 | variables: 13 | solution: '**/*.sln' 14 | buildPlatform: 'x64' 15 | buildConfiguration: 'Release' 16 | 17 | steps: 18 | - checkout: self 19 | submodules: recursive 20 | - task: NuGetToolInstaller@1 21 | 22 | - task: NuGetCommand@2 23 | inputs: 24 | restoreSolution: '$(solution)' 25 | 26 | - task: VSBuild@1 27 | inputs: 28 | solution: '$(solution)' 29 | platform: '$(buildPlatform)' 30 | configuration: '$(buildConfiguration)' 31 | 32 | - task: VSTest@2 33 | inputs: 34 | platform: '$(buildPlatform)' 35 | configuration: '$(buildConfiguration)' 36 | -------------------------------------------------------------------------------- /src/DemoHelper.h: -------------------------------------------------------------------------------- 1 | // demoHelper - screen drawing and presentation tool 2 | 3 | // Copyright (C) 2007-2008, 2015, 2021 - Stefan Kueng 4 | 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | 15 | // You should have received a copy of the GNU General Public License 16 | // along with this program; if not, write to the Free Software Foundation, 17 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | // 19 | 20 | #pragma once 21 | 22 | 23 | extern HINSTANCE g_hInstance; // current instance 24 | extern HINSTANCE g_hResource; // the resource dll 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DemoHelper 2 | A tool which helps in demonstrations, presentations or if you just need to explain 3 | someone something on your computer. 4 | 5 | [![Build Status](https://tortoisesvn.visualstudio.com/tortoisesvnGitHub/_apis/build/status/stefankueng.demohelper?branchName=main)](https://tortoisesvn.visualstudio.com/tortoisesvnGitHub/_build/latest?definitionId=11&branchName=main) 6 | 7 | *DemoHelper* is an annotation and screen zoom tool you can use for technical 8 | presentations that include application demonstrations. 9 | 10 | It can also show an overlay indicating which key-shortcut you entered or which mousebutton you clicked, 11 | which is also useful when recording screencasts. 12 | 13 | *DemoHelper* runs unobtrusively in the system tray and is activated by either customizable 14 | otkeys or the context menu of the tray icon. 15 | 16 | You can draw on the screen to mark special areas, or you can zoom in on an area on the screen. 17 | 18 | Please visit the [homepage](https://tools.stefankueng.com/DemoHelper.html) of *DemoHelper* for more information. 19 | -------------------------------------------------------------------------------- /src/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include 9 | 10 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 11 | #include 12 | #include 13 | 14 | // C RunTime Header Files 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #pragma comment(linker, "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") 22 | 23 | #pragma warning(push) 24 | #pragma warning(disable: 4458) // declaration of 'xxx' hides class member 25 | #include 26 | #pragma warning(pop) 27 | #pragma comment(lib, "gdiplus.lib") 28 | 29 | #undef min 30 | #undef max 31 | #include "OnOutOfScope.h" 32 | 33 | #define DEBUGOUTPUTREGPATH L"Software\\DemoHelper\\Debug" 34 | -------------------------------------------------------------------------------- /DemoHelper.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 12.00 2 | # Visual Studio Version 16 3 | VisualStudioVersion = 16.0.30204.135 4 | MinimumVisualStudioVersion = 10.0.40219.1 5 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DemoHelper", "src\DemoHelper.vcxproj", "{644720B5-9DD2-4FAB-A531-142C2D89BBCB}" 6 | EndProject 7 | Global 8 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 9 | Debug|x64 = Debug|x64 10 | Release|x64 = Release|x64 11 | EndGlobalSection 12 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 13 | {644720B5-9DD2-4FAB-A531-142C2D89BBCB}.Debug|x64.ActiveCfg = Debug|x64 14 | {644720B5-9DD2-4FAB-A531-142C2D89BBCB}.Debug|x64.Build.0 = Debug|x64 15 | {644720B5-9DD2-4FAB-A531-142C2D89BBCB}.Release|x64.ActiveCfg = Release|x64 16 | {644720B5-9DD2-4FAB-A531-142C2D89BBCB}.Release|x64.Build.0 = Release|x64 17 | EndGlobalSection 18 | GlobalSection(SolutionProperties) = preSolution 19 | HideSolutionNode = FALSE 20 | EndGlobalSection 21 | GlobalSection(ExtensibilityGlobals) = postSolution 22 | SolutionGuid = {640F00B7-A5B8-40D1-91A5-491A80BD205C} 23 | EndGlobalSection 24 | EndGlobal 25 | -------------------------------------------------------------------------------- /src/ColorDlg.h: -------------------------------------------------------------------------------- 1 | // demoHelper - screen drawing and presentation tool 2 | 3 | // Copyright (C) 2020-2021 - Stefan Kueng 4 | 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | 15 | // You should have received a copy of the GNU General Public License 16 | // along with this program; if not, write to the Free Software Foundation, 17 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | // 19 | #pragma once 20 | #include "BaseDialog.h" 21 | #include "ColorButton.h" 22 | 23 | /** 24 | * about dialog. 25 | */ 26 | class CColorDlg : public CDialog 27 | { 28 | public: 29 | CColorDlg(HWND hParent); 30 | ~CColorDlg(); 31 | 32 | protected: 33 | LRESULT CALLBACK DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) override; 34 | LRESULT DoCommand(int id); 35 | 36 | private: 37 | HWND m_hParent; 38 | CColorButton m_mvLColor; 39 | CColorButton m_mvMColor; 40 | CColorButton m_mvRColor; 41 | }; 42 | -------------------------------------------------------------------------------- /src/MagnifierWindow.h: -------------------------------------------------------------------------------- 1 | // demoHelper - screen drawing and presentation tool 2 | 3 | // Copyright (C) 2021 - Stefan Kueng 4 | 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | 15 | // You should have received a copy of the GNU General Public License 16 | // along with this program; if not, write to the Free Software Foundation, 17 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | // 19 | #pragma once 20 | #include "magnification.h" 21 | 22 | #pragma comment(lib, "Magnification.lib") 23 | 24 | class CMagnifierWindow 25 | { 26 | public: 27 | CMagnifierWindow() 28 | : m_hWnd(nullptr) 29 | , m_magFactor(1.0f) 30 | , m_sourceRect({}) 31 | { 32 | } 33 | ~CMagnifierWindow() {} 34 | 35 | BOOL Create(HINSTANCE hInst, HWND hwndHost, BOOL visible); 36 | 37 | BOOL SetMagnification(POINT mousePt, float magnification); 38 | BOOL SetSourceRect(RECT rc); 39 | BOOL UpdateMagnifier() const; 40 | float GetMagnification() const { return m_magFactor; } 41 | BOOL Reset(); 42 | 43 | operator HWND() { return m_hWnd; } 44 | operator HWND() const { return m_hWnd; } 45 | 46 | private: 47 | HWND m_hWnd; 48 | float m_magFactor; 49 | RECT m_sourceRect; 50 | }; 51 | -------------------------------------------------------------------------------- /src/KeyboardOverlay.h: -------------------------------------------------------------------------------- 1 | // demoHelper - screen drawing and presentation tool 2 | 3 | // Copyright (C) 2020-2021 - Stefan Kueng 4 | 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | 15 | // You should have received a copy of the GNU General Public License 16 | // along with this program; if not, write to the Free Software Foundation, 17 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | // 19 | #pragma once 20 | #include "BaseWindow.h" 21 | #include "AnimationManager.h" 22 | #include 23 | 24 | class CKeyboardOverlayWnd : public CWindow 25 | { 26 | public: 27 | explicit CKeyboardOverlayWnd(HINSTANCE hInst, const WNDCLASSEX* wcx = nullptr) 28 | : CWindow(hInst, wcx) 29 | { 30 | RegisterAndCreateWindow(); 31 | } 32 | ~CKeyboardOverlayWnd(void); 33 | 34 | void Show(const std::wstring& text); 35 | 36 | private: 37 | protected: 38 | virtual void OnPaint(HDC hDC, LPRECT pRect); 39 | /** 40 | * Registers the window class and creates the window. 41 | */ 42 | bool RegisterAndCreateWindow(); 43 | /// the message handler for this window 44 | LRESULT CALLBACK WinMsgHandler(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) override; 45 | 46 | private: 47 | std::wstring m_text; 48 | AnimationVariable m_animVar; 49 | }; 50 | -------------------------------------------------------------------------------- /src/MouseOverlay.h: -------------------------------------------------------------------------------- 1 | // demoHelper - screen drawing and presentation tool 2 | 3 | // Copyright (C) 2020-2021 - Stefan Kueng 4 | 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | 15 | // You should have received a copy of the GNU General Public License 16 | // along with this program; if not, write to the Free Software Foundation, 17 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | // 19 | #pragma once 20 | #include "BaseWindow.h" 21 | #include "AnimationManager.h" 22 | 23 | class CMouseOverlayWnd : public CWindow 24 | { 25 | public: 26 | explicit CMouseOverlayWnd(HINSTANCE hInst, const WNDCLASSEX* wcx = nullptr) 27 | : CWindow(hInst, wcx) 28 | , m_color(0) 29 | { 30 | RegisterAndCreateWindow(); 31 | } 32 | ~CMouseOverlayWnd(); 33 | 34 | void Show(POINT screenPos, COLORREF color, double fadeTo); 35 | void UpdatePos(POINT screenPos); 36 | void Fade(); 37 | 38 | private: 39 | protected: 40 | virtual void OnPaint(HDC hDC, LPRECT pRect); 41 | /** 42 | * Registers the window class and creates the window. 43 | */ 44 | bool RegisterAndCreateWindow(); 45 | /// the message handler for this window 46 | LRESULT CALLBACK WinMsgHandler(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) override; 47 | 48 | private: 49 | AnimationVariable m_animVar; 50 | COLORREF m_color; 51 | }; 52 | -------------------------------------------------------------------------------- /src/KeyboardOverlayD2D.h: -------------------------------------------------------------------------------- 1 | // demoHelper - screen drawing and presentation tool 2 | 3 | // Copyright (C) 2020-2021 - Stefan Kueng 4 | 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | 15 | // You should have received a copy of the GNU General Public License 16 | // along with this program; if not, write to the Free Software Foundation, 17 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | // 19 | #pragma once 20 | #include "BaseWindowD2D.h" 21 | #include "AnimationManager.h" 22 | #include 23 | 24 | class CKeyboardOverlayWndD2D : public CWindowD2D 25 | { 26 | public: 27 | explicit CKeyboardOverlayWndD2D(HINSTANCE hInst, const WNDCLASSEX* wcx = nullptr) 28 | : CWindowD2D(hInst, wcx) 29 | , m_animVar(nullptr) 30 | , m_bShown(false) 31 | { 32 | RegisterAndCreateWindow(); 33 | } 34 | ~CKeyboardOverlayWndD2D(void); 35 | 36 | SIZE GetRequiredHeight(const std::wstring& text); 37 | void Show(const std::wstring& text); 38 | bool IsAnimationFinished(); 39 | bool HasWindowBeenShown() const; 40 | 41 | private: 42 | protected: 43 | /** 44 | * Registers the window class and creates the window. 45 | */ 46 | bool RegisterAndCreateWindow(); 47 | 48 | private: 49 | std::wstring m_text; 50 | AnimationVariable m_animVar; 51 | 52 | // Inherited via CWindowD2D 53 | virtual LRESULT WinMsgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) override; 54 | virtual HRESULT OnRender(ID2D1DeviceContext* dc) override; 55 | virtual HRESULT CreateDeviceResources() override; 56 | virtual HRESULT DiscardDeviceResources() override; 57 | 58 | ComPtr m_textFormat; 59 | ComPtr m_gaussianBlurEffect; 60 | bool m_bShown; 61 | }; 62 | -------------------------------------------------------------------------------- /src/RectSelectionWnd.h: -------------------------------------------------------------------------------- 1 | // demoHelper - screen drawing and presentation tool 2 | 3 | // Copyright (C) 2020-2021 - Stefan Kueng 4 | 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | 15 | // You should have received a copy of the GNU General Public License 16 | // along with this program; if not, write to the Free Software Foundation, 17 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | // 19 | #pragma once 20 | #include "BaseWindowD2D.h" 21 | 22 | class CRectSelectionWnd : public CWindowD2D 23 | { 24 | public: 25 | explicit CRectSelectionWnd(HINSTANCE hInst, const WNDCLASSEX* wcx = nullptr) 26 | : CWindowD2D(hInst, wcx) 27 | , m_bRunning(false) 28 | , m_selectedRect{} 29 | , m_startPt{} 30 | , m_endPt{} 31 | , m_selectionInProgress(false) 32 | , m_aspectRatio(1.0f) 33 | { 34 | RegisterAndCreateWindow(); 35 | } 36 | ~CRectSelectionWnd(); 37 | 38 | RECT Show(HWND hWndParent, RECT wndRect, float aspectRatio); 39 | 40 | private: 41 | protected: 42 | /** 43 | * Registers the window class and creates the window. 44 | */ 45 | bool RegisterAndCreateWindow(); 46 | 47 | private: 48 | // Inherited via CWindowD2D 49 | LRESULT WinMsgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) override; 50 | HRESULT OnRender(ID2D1DeviceContext* dc) override; 51 | HRESULT CreateDeviceResources() override; 52 | HRESULT DiscardDeviceResources() override; 53 | void AdjustEndPoint(); 54 | 55 | ComPtr m_textFormat; 56 | ComPtr m_gaussianBlurEffect; 57 | bool m_bRunning; 58 | RECT m_selectedRect; 59 | POINT m_startPt; 60 | POINT m_endPt; 61 | bool m_selectionInProgress; 62 | float m_aspectRatio; 63 | }; 64 | -------------------------------------------------------------------------------- /src/ColorButton.h: -------------------------------------------------------------------------------- 1 | // demoHelper - screen drawing and presentation tool 2 | 3 | // Copyright (C) 2020 - Stefan Kueng 4 | 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | 15 | // You should have received a copy of the GNU General Public License 16 | // along with this program; if not, write to the Free Software Foundation, 17 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | // 19 | #pragma once 20 | #include 21 | #include 22 | 23 | enum class ColorButtonDialogResult 24 | { 25 | None, 26 | Cancel, 27 | Ok 28 | }; 29 | 30 | class CColorButton 31 | { 32 | public: 33 | CColorButton(); 34 | virtual ~CColorButton(); 35 | 36 | BOOL ConvertToColorButton(HWND hwndParent, UINT uiCtlId); 37 | 38 | void SetColor(COLORREF clr); 39 | COLORREF GetColor() const { return m_color; } 40 | COLORREF GetLastColor() const { return m_lastColor; } 41 | ColorButtonDialogResult GetDialogResult() const { return m_dialogResult; } 42 | void Reset() 43 | { 44 | m_hasLastColor = false; 45 | } 46 | 47 | protected: 48 | 49 | private: 50 | WNDPROC m_pfnOrigCtlProc = nullptr; 51 | COLORREF m_color = 0; 52 | HWND m_hwnd = nullptr; 53 | UINT m_ctlId = 0; 54 | bool m_hasLastColor = false; 55 | COLORREF m_lastColor = 0; 56 | std::vector m_colorEdits; 57 | ColorButtonDialogResult m_dialogResult = ColorButtonDialogResult::None; 58 | 59 | private: 60 | bool ConvertToColorButton(HWND hwndCtl); 61 | inline static CColorButton* GetObjectFromWindow(HWND hWnd) 62 | { 63 | return reinterpret_cast(GetWindowLongPtr(hWnd, GWLP_USERDATA)); 64 | } 65 | static LRESULT CALLBACK _ColorButtonProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); 66 | static UINT_PTR CALLBACK CCHookProc( 67 | _In_ HWND hdlg, 68 | _In_ UINT uiMsg, 69 | _In_ WPARAM wParam, 70 | _In_ LPARAM lParam 71 | ); 72 | }; 73 | -------------------------------------------------------------------------------- /default.build.user.tmpl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | You must first call "%VS140COMNTOOLS%\vsvars32.bat" 24 | 25 | 26 | 27 | 28 | 29 | 30 | 36 | 37 | 38 | 39 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 55 | 56 | 57 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /src/ColorDlg.cpp: -------------------------------------------------------------------------------- 1 | // demoHelper - screen drawing and presentation tool 2 | 3 | // Copyright (C) 2020-2021 - Stefan Kueng 4 | 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | 15 | // You should have received a copy of the GNU General Public License 16 | // along with this program; if not, write to the Free Software Foundation, 17 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | // 19 | #include "stdafx.h" 20 | #include "ColorDlg.h" 21 | #include "IniSettings.h" 22 | #include "resource.h" 23 | #include 24 | 25 | CColorDlg::CColorDlg(HWND hParent) 26 | : m_hParent(hParent) 27 | { 28 | } 29 | 30 | CColorDlg::~CColorDlg() 31 | { 32 | } 33 | 34 | LRESULT CColorDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) 35 | { 36 | UNREFERENCED_PARAMETER(lParam); 37 | switch (uMsg) 38 | { 39 | case WM_INITDIALOG: 40 | { 41 | InitDialog(hwndDlg, IDI_DEMOHELPER); 42 | m_mvLColor.ConvertToColorButton(hwndDlg, IDC_MOUSEVISUAL_LEFT); 43 | m_mvMColor.ConvertToColorButton(hwndDlg, IDC_MOUSEVISUAL_MIDDLE); 44 | m_mvRColor.ConvertToColorButton(hwndDlg, IDC_MOUSEVISUAL_RIGHT); 45 | auto mvLClr = static_cast(CIniSettings::Instance().GetInt64(L"Misc", L"mousevisualLcolor", RGB(255, 0, 0))); 46 | auto mvMClr = static_cast(CIniSettings::Instance().GetInt64(L"Misc", L"mousevisualMcolor", RGB(0, 0, 255))); 47 | auto mvRClr = static_cast(CIniSettings::Instance().GetInt64(L"Misc", L"mousevisualRcolor", RGB(0, 255, 0))); 48 | m_mvLColor.SetColor(mvLClr); 49 | m_mvMColor.SetColor(mvMClr); 50 | m_mvRColor.SetColor(mvRClr); 51 | } 52 | return TRUE; 53 | case WM_COMMAND: 54 | return DoCommand(LOWORD(wParam)); 55 | default: 56 | return FALSE; 57 | } 58 | } 59 | 60 | LRESULT CColorDlg::DoCommand(int id) 61 | { 62 | switch (id) 63 | { 64 | case IDOK: 65 | CIniSettings::Instance().SetInt64(L"Misc", L"mousevisualLcolor", m_mvLColor.GetColor()); 66 | CIniSettings::Instance().SetInt64(L"Misc", L"mousevisualMcolor", m_mvMColor.GetColor()); 67 | CIniSettings::Instance().SetInt64(L"Misc", L"mousevisualRcolor", m_mvRColor.GetColor()); 68 | [[fallthrough]]; 69 | case IDCANCEL: 70 | EndDialog(*this, id); 71 | break; 72 | } 73 | return 1; 74 | } 75 | -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | # 7 | # ******** NOTE ******** 8 | # We have attempted to detect the languages in your repository. Please check 9 | # the `language` matrix defined below to confirm you have the correct set of 10 | # supported CodeQL languages. 11 | # 12 | name: "CodeQL" 13 | 14 | on: 15 | push: 16 | branches: [ main ] 17 | paths-ignore: 18 | - "choco/**" 19 | - "*.md" 20 | pull_request: 21 | # The branches below must be a subset of the branches above 22 | branches: [ main ] 23 | schedule: 24 | - cron: '44 20 * * 5' 25 | 26 | jobs: 27 | analyze: 28 | name: Analyze 29 | runs-on: windows-latest 30 | 31 | strategy: 32 | fail-fast: false 33 | matrix: 34 | language: [ 'cpp' ] 35 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] 36 | # Learn more: 37 | # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed 38 | 39 | steps: 40 | - name: Checkout repository 41 | uses: actions/checkout@v3.2.0 42 | with: 43 | fetch-depth: 2 44 | submodules: recursive 45 | 46 | - name: nuget-restore 47 | uses: nuget/setup-nuget@v1 48 | with: 49 | nuget-version: "latest" 50 | 51 | - name: nuget-sln-restore 52 | run: nuget restore DemoHelper.sln 53 | 54 | # Initializes the CodeQL tools for scanning. 55 | - name: Initialize CodeQL 56 | uses: github/codeql-action/init@v1 57 | with: 58 | languages: ${{ matrix.language }} 59 | # If you wish to specify custom queries, you can do so here or in a config file. 60 | # By default, queries listed here will override any specified in a config file. 61 | # Prefix the list here with "+" to use these queries and those in the config file. 62 | # queries: ./path/to/local/query, your-org/your-repo/queries@main 63 | 64 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 65 | # If this step fails, then you should remove it and run the build manually (see below) 66 | #- name: Autobuild 67 | # uses: github/codeql-action/autobuild@v1 68 | 69 | # ℹ️ Command-line programs to run using the OS shell. 70 | # 📚 https://git.io/JvXDl 71 | 72 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines 73 | # and modify them (or add more) to build your code if your project 74 | # uses a compiled language 75 | 76 | - name: setup-msbuild 77 | uses: microsoft/setup-msbuild@v1.1.3 78 | 79 | - name: Build Solution 80 | run: MSBuild.exe DemoHelper.sln /p:Configuration=Release /p:Platform=x64 -nologo 81 | 82 | - name: Perform CodeQL Analysis 83 | uses: github/codeql-action/analyze@v1 84 | -------------------------------------------------------------------------------- /tools/checkyear.js: -------------------------------------------------------------------------------- 1 | /* This script is a local pre-commit hook script. 2 | * It's used to check whether the copyright year of modified files has been 3 | * bumped up to the current year. 4 | * 5 | * Only *.cpp, *.h and *.idl files are checked 6 | * 7 | * Set the local hook scripts like this (pre-commit hook): 8 | * WScript path/to/this/script/file.js 9 | * and set "Wait for the script to finish" 10 | */ 11 | 12 | var forReading = 1; 13 | var objArgs = WScript.Arguments; 14 | var num = objArgs.length; 15 | 16 | if (num !== 4 && num !== 3) 17 | { 18 | WScript.Echo("Usage: [CScript | WScript] checkyear.js path/to/pathsfile depth path/to/messagefile path/to/CWD"); 19 | WScript.Quit(1); 20 | } 21 | 22 | var currentyear = new Date().getFullYear(); 23 | var re = new RegExp('^(\\\/\\\/|#) Copyright.+(' + currentyear + ')(.*)'); 24 | var basere = /^\/\/ Copyright(.*)/; 25 | var filere = /(\.cpp$)|(\.h$)|(\.idl$)/; 26 | 27 | // readFileLines 28 | function readPaths(path) 29 | { 30 | var retPaths = []; 31 | var fileSystem = new ActiveXObject("Scripting.FileSystemObject"); 32 | 33 | if (fileSystem.FileExists(path)) 34 | { 35 | var textFile = fileSystem.OpenTextFile(path, forReading); 36 | 37 | while (!textFile.AtEndOfStream) 38 | { 39 | var line = textFile.ReadLine(); 40 | 41 | retPaths.push(line); 42 | } 43 | textFile.Close(); 44 | } 45 | return retPaths; 46 | } 47 | 48 | var found = true; 49 | var files = readPaths(objArgs(0)); 50 | var fileIndex = files.length; 51 | var errorMessage = ""; 52 | 53 | while (fileIndex--) 54 | { 55 | var f = files[fileIndex]; 56 | var fso = new ActiveXObject("Scripting.FileSystemObject"); 57 | 58 | if (f.match(filere) !== null) 59 | { 60 | if (fso.FileExists(f)) 61 | { 62 | var a = fso.OpenTextFile(f, forReading, false); 63 | var copyrightFound = false; 64 | var yearFound = false; 65 | 66 | while (!a.AtEndOfStream && !yearFound) 67 | { 68 | var r = a.ReadLine(); 69 | var rv = r.match(basere); 70 | 71 | if (rv !== null) 72 | { 73 | rv = r.match(re); 74 | if (rv !== null) 75 | { 76 | yearFound = true; 77 | } 78 | 79 | copyrightFound = true; 80 | } 81 | } 82 | a.Close(); 83 | 84 | if (copyrightFound && !yearFound) 85 | { 86 | if (errorMessage !== "") 87 | { 88 | errorMessage += "\n"; 89 | } 90 | errorMessage += f; 91 | found = false; 92 | } 93 | } 94 | } 95 | } 96 | 97 | if (found === false) 98 | { 99 | errorMessage = "the file(s):\n" + errorMessage + "\nhave not the correct copyright year!"; 100 | WScript.stderr.writeLine(errorMessage); 101 | } 102 | 103 | WScript.Quit(!found); 104 | -------------------------------------------------------------------------------- /src/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by DemoHelper.rc 4 | // 5 | #define IDC_MYICON2 3 6 | #define IDD_DEMOHELPER_DIALOG 102 7 | #define IDS_APP_TITLE 103 8 | #define IDM_ABOUT 104 9 | #define IDS_WEBLINK 104 10 | #define IDM_EXIT 105 11 | #define IDI_DEMOHELPER 107 12 | #define IDC_DEMOHELPER 109 13 | #define IDR_DEMOHELPER 109 14 | #define IDR_MAINFRAME 128 15 | #define IDD_OPTIONS 129 16 | #define IDD_COLORS 131 17 | #define IDR_HELP 132 18 | #define IDC_WEBLINK 1002 19 | #define IDC_HOTKEY_ZOOMMODE 1003 20 | #define IDC_HOTKEY_DRAWMODE 1004 21 | #define IDC_CURSORCHECK 1005 22 | #define IDC_HOTKEY_LENSMODE 1005 23 | #define IDC_FADESECONDS 1006 24 | #define IDC_CURRENTMONITOR 1008 25 | #define IDC_ALLMONITORS 1009 26 | #define IDC_KEYHOOK 1010 27 | #define IDC_MOUSEHOOK 1011 28 | #define IDC_SYSLINK1 1012 29 | #define IDC_MOUSEVISUALS 1013 30 | #define IDC_MOUSEVISUAL_LEFT 1013 31 | #define IDC_MOUSEVISUAL_MIDDLE 1014 32 | #define IDC_BUTTON1 1014 33 | #define IDC_CONF_COLORS 1014 34 | #define IDC_MOUSEVISUAL_RIGHT 1015 35 | #define IDC_POS_TOPLEFT 1015 36 | #define IDC_POS_TOPRIGHT 1016 37 | #define IDC_POS_BOTTOMLEFT 1017 38 | #define IDC_POS_BOTTOMRIGHT 1018 39 | #define ID_TRAYCONTEXT_OPTIONS 32771 40 | #define ID_TRAYCONTEXT_ABOUT 32772 41 | #define ID_TRAYCONTEXT_ZOOM 32773 42 | #define ID_TRAYCONTEXT_DRAW 32774 43 | #define ID_CMD_UNDOLINE 32775 44 | #define ID_CMD_QUITMODE 32776 45 | #define ID_CMD_INCREASE 32777 46 | #define ID_CMD_DECREASE 32778 47 | #define ID_CMD_NEXTCOLOR 32779 48 | #define ID_CMD_PREVCOLOR 32780 49 | #define ID_CMD_CLEARLINES 32781 50 | #define ID_CMD_QUICKTOMARKER 32782 51 | #define ID_CMD_ACCEPT 32783 52 | #define ID_CMD_TOGGLEROP 32785 53 | #define ID_CMD_INLINEZOOM 32787 54 | #define ID_TRAYCONTEXT_HELP 32790 55 | #define ID_CMD_CLEARSCREEN 32791 56 | #define ID_CMD_COLOR1 32793 57 | #define ID_CMD_COLOR2 32794 58 | #define ID_CMD_COLOR3 32795 59 | #define ID_CMD_COLOR4 32796 60 | #define ID_CMD_COLOR5 32797 61 | #define ID_CMD_COLOR6 32798 62 | #define ID_CMD_COLOR7 32799 63 | #define ID_CMD_COLOR8 32800 64 | #define ID_CMD_COLOR9 32801 65 | #define ID_CMD_COLOR0 32802 66 | #define ID_CMD_REMOVEFIRST 32804 67 | #define IDC_STATIC -1 68 | 69 | // Next default values for new objects 70 | // 71 | #ifdef APSTUDIO_INVOKED 72 | #ifndef APSTUDIO_READONLY_SYMBOLS 73 | #define _APS_NO_MFC 1 74 | #define _APS_NEXT_RESOURCE_VALUE 133 75 | #define _APS_NEXT_COMMAND_VALUE 32806 76 | #define _APS_NEXT_CONTROL_VALUE 1016 77 | #define _APS_NEXT_SYMED_VALUE 110 78 | #endif 79 | #endif 80 | -------------------------------------------------------------------------------- /src/DemoHelper.cpp: -------------------------------------------------------------------------------- 1 | // demoHelper - screen drawing and presentation tool 2 | 3 | // Copyright (C) 2007-2008, 2015, 2020-2021 - Stefan Kueng 4 | 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | 15 | // You should have received a copy of the GNU General Public License 16 | // along with this program; if not, write to the Free Software Foundation, 17 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | // 19 | 20 | #include "stdafx.h" 21 | #include "DemoHelper.h" 22 | #include "MainWindow.h" 23 | #include "IniSettings.h" 24 | #include "PathUtils.h" 25 | #include "SmartHandle.h" 26 | 27 | // Global Variables: 28 | HINSTANCE g_hInstance; // current instance 29 | HINSTANCE g_hResource; // the resource dll 30 | 31 | int APIENTRY wWinMain(HINSTANCE hInstance, 32 | HINSTANCE hPrevInstance, 33 | LPTSTR lpCmdLine, 34 | int nCmdShow) 35 | { 36 | UNREFERENCED_PARAMETER(hPrevInstance); 37 | UNREFERENCED_PARAMETER(lpCmdLine); 38 | UNREFERENCED_PARAMETER(nCmdShow); 39 | 40 | INITCOMMONCONTROLSEX used = { 41 | sizeof(INITCOMMONCONTROLSEX), 42 | ICC_STANDARD_CLASSES | ICC_BAR_CLASSES}; 43 | InitCommonControlsEx(&used); 44 | SetDllDirectory(L""); 45 | if (FAILED(CoInitialize(nullptr))) 46 | return -1; 47 | OnOutOfScope(CoUninitialize()); 48 | 49 | MagInitialize(); 50 | OnOutOfScope(MagUninitialize()); 51 | OnOutOfScope(Animator::Instance().ShutDown()); 52 | 53 | g_hResource = hInstance; 54 | g_hInstance = hInstance; 55 | 56 | auto iniFilePath = CPathUtils::GetModuleDir() + L"\\DemoHelper.ini"; 57 | { 58 | CAutoFile hFile = CreateFile(iniFilePath.c_str(), GENERIC_WRITE, FILE_SHARE_READ, nullptr, OPEN_ALWAYS, 0, nullptr); 59 | if (!hFile) 60 | { 61 | auto appDataPath = CPathUtils::GetAppDataPath() + L"\\DemoHelper"; 62 | CreateDirectory(appDataPath.c_str(), nullptr); 63 | iniFilePath = appDataPath + L"\\DemoHelper.ini"; 64 | } 65 | } 66 | CIniSettings::Instance().SetIniPath(iniFilePath); 67 | OnOutOfScope(CIniSettings::Instance().Save()); 68 | ULONG_PTR gdiPlusToken; 69 | Gdiplus::GdiplusStartupInput gdiPlusStartupInput; 70 | Gdiplus::GdiplusStartup(&gdiPlusToken, &gdiPlusStartupInput, nullptr); 71 | 72 | OnOutOfScope(Gdiplus::GdiplusShutdown(gdiPlusToken)); 73 | int ret = 1; 74 | MSG msg; 75 | { 76 | if (CMainWindow trayWindow(g_hResource); trayWindow.RegisterAndCreateWindow()) 77 | { 78 | HACCEL hAccelTable = LoadAccelerators(g_hResource, MAKEINTRESOURCE(IDR_DEMOHELPER)); 79 | // Main message loop: 80 | while (GetMessage(&msg, nullptr, 0, 0)) 81 | { 82 | if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) 83 | { 84 | TranslateMessage(&msg); 85 | DispatchMessage(&msg); 86 | } 87 | } 88 | ret = static_cast(msg.wParam); 89 | } 90 | } 91 | return ret; 92 | } 93 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | AccessModifierOffset: -4 4 | AlignAfterOpenBracket: Align 5 | AlignConsecutiveAssignments: AcrossEmptyLinesAndComments 6 | AlignConsecutiveBitFields: AcrossEmptyLinesAndComments 7 | AlignConsecutiveDeclarations: AcrossEmptyLinesAndComments 8 | AlignConsecutiveMacros: AcrossEmptyLinesAndComments 9 | AlignEscapedNewlines: Right 10 | AlignOperands: true 11 | AlignTrailingComments: true 12 | AllowAllParametersOfDeclarationOnNextLine: true 13 | AllowShortBlocksOnASingleLine: false 14 | AllowShortCaseLabelsOnASingleLine: false 15 | AllowShortFunctionsOnASingleLine: All 16 | AllowShortIfStatementsOnASingleLine: false 17 | AllowShortLoopsOnASingleLine: false 18 | AlwaysBreakAfterDefinitionReturnType: None 19 | AlwaysBreakAfterReturnType: None 20 | AlwaysBreakBeforeMultilineStrings: false 21 | AlwaysBreakTemplateDeclarations: false 22 | BinPackArguments: true 23 | BinPackParameters: true 24 | BraceWrapping: 25 | AfterCaseLabel: true 26 | AfterClass: true 27 | AfterControlStatement: true 28 | AfterEnum: true 29 | AfterFunction: true 30 | AfterNamespace: true 31 | AfterObjCDeclaration: true 32 | AfterStruct: true 33 | AfterUnion: true 34 | BeforeCatch: true 35 | BeforeElse: true 36 | IndentBraces: false 37 | SplitEmptyFunction: true 38 | SplitEmptyRecord: true 39 | SplitEmptyNamespace: true 40 | BreakBeforeBinaryOperators: None 41 | BreakBeforeBraces: Custom 42 | BreakBeforeInheritanceComma: true 43 | BreakBeforeTernaryOperators: true 44 | BreakConstructorInitializersBeforeComma: true 45 | BreakConstructorInitializers: BeforeColon 46 | BreakAfterJavaFieldAnnotations: false 47 | BreakStringLiterals: true 48 | ColumnLimit: 0 49 | CommentPragmas: '^ IWYU pragma:' 50 | CompactNamespaces: false 51 | ConstructorInitializerAllOnOneLineOrOnePerLine: false 52 | ConstructorInitializerIndentWidth: 4 53 | ContinuationIndentWidth: 4 54 | Cpp11BracedListStyle: true 55 | DerivePointerAlignment: true 56 | DisableFormat: false 57 | ExperimentalAutoDetectBinPacking: false 58 | FixNamespaceComments: true 59 | ForEachMacros: 60 | - foreach 61 | - Q_FOREACH 62 | - BOOST_FOREACH 63 | IncludeCategories: 64 | - Regex: '^"(llvm|llvm-c|clang|clang-c)/' 65 | Priority: 2 66 | - Regex: '^(<|"(gtest|gmock|isl|json)/)' 67 | Priority: 3 68 | - Regex: '.*' 69 | Priority: 1 70 | IncludeIsMainRegex: '(Test)?$' 71 | IndentCaseLabels: true 72 | IndentPPDirectives: AfterHash 73 | IndentWidth: 4 74 | IndentWrappedFunctionNames: true 75 | JavaScriptQuotes: Leave 76 | JavaScriptWrapImports: true 77 | KeepEmptyLinesAtTheStartOfBlocks: false 78 | MacroBlockBegin: "^\ 79 | BEGIN_MSG_MAP|\ 80 | BEGIN_MESSAGE_MAP|\ 81 | BEGIN_MSG_MAP_EX|\ 82 | BEGIN_MESSAGE_MAP_EX|\ 83 | BEGIN_SAFE_MSG_MAP_EX|\ 84 | CR_BEGIN_MSG_MAP_EX|\ 85 | IPC_BEGIN_MESSAGE_MAP|\ 86 | IPC_BEGIN_MESSAGE_MAP_WITH_PARAM|\ 87 | IPC_PROTOBUF_MESSAGE_TRAITS_BEGIN|\ 88 | IPC_STRUCT_BEGIN|\ 89 | IPC_STRUCT_BEGIN_WITH_PARENT|\ 90 | IPC_STRUCT_TRAITS_BEGIN|\ 91 | POLPARAMS_BEGIN|\ 92 | PPAPI_BEGIN_MESSAGE_MAP$" 93 | MacroBlockEnd: "^\ 94 | CR_END_MSG_MAP|\ 95 | END_MSG_MAP|\ 96 | END_MESSAGE_MAP|\ 97 | IPC_END_MESSAGE_MAP|\ 98 | IPC_PROTOBUF_MESSAGE_TRAITS_END|\ 99 | IPC_STRUCT_END|\ 100 | IPC_STRUCT_TRAITS_END|\ 101 | POLPARAMS_END|\ 102 | PPAPI_END_MESSAGE_MAP$" 103 | MaxEmptyLinesToKeep: 1 104 | NamespaceIndentation: None 105 | ObjCBlockIndentWidth: 2 106 | ObjCSpaceAfterProperty: false 107 | ObjCSpaceBeforeProtocolList: true 108 | PenaltyBreakAssignment: 2 109 | PenaltyBreakBeforeFirstCallParameter: 19 110 | PenaltyBreakComment: 300 111 | PenaltyBreakFirstLessLess: 120 112 | PenaltyBreakString: 1000 113 | PenaltyExcessCharacter: 1000000 114 | PenaltyReturnTypeOnItsOwnLine: 60 115 | PointerAlignment: Left 116 | ReflowComments: true 117 | SortIncludes: false 118 | SortUsingDeclarations: true 119 | SpaceAfterCStyleCast: false 120 | SpaceAfterTemplateKeyword: true 121 | SpaceBeforeAssignmentOperators: true 122 | SpaceBeforeParens: ControlStatements 123 | SpaceInEmptyParentheses: false 124 | SpacesBeforeTrailingComments: 1 125 | SpacesInAngles: false 126 | SpacesInContainerLiterals: false 127 | SpacesInCStyleCastParentheses: false 128 | SpacesInParentheses: false 129 | SpacesInSquareBrackets: false 130 | Standard: Cpp11 131 | TabWidth: 4 132 | UseTab: Never 133 | ... 134 | 135 | -------------------------------------------------------------------------------- /src/Graphics.cpp: -------------------------------------------------------------------------------- 1 | // demoHelper - screen drawing and presentation tool 2 | 3 | // Copyright (C) 2007-2008, 2020-2021 - Stefan Kueng 4 | 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | 15 | // You should have received a copy of the GNU General Public License 16 | // along with this program; if not, write to the Free Software Foundation, 17 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | // 19 | 20 | #include "stdafx.h" 21 | #include "MainWindow.h" 22 | #include "DPIAware.h" 23 | 24 | HCURSOR CMainWindow::CreateDrawCursor(COLORREF color, int penwidth) 25 | { 26 | // Get the system display DC 27 | HDC hDC = ::GetDC(*this); 28 | 29 | // Create helper DC 30 | HDC hMainDC = ::CreateCompatibleDC(hDC); 31 | HDC hAndMaskDC = ::CreateCompatibleDC(hDC); 32 | HDC hXorMaskDC = ::CreateCompatibleDC(hDC); 33 | 34 | auto cursorSizeX = CDPIAware::Instance().Scale(*this, GetSystemMetrics(SM_CXCURSOR)); 35 | auto cursorSizeY = CDPIAware::Instance().Scale(*this, GetSystemMetrics(SM_CYCURSOR)); 36 | 37 | // Create the mask bitmaps 38 | auto hSourceBitmap = ::CreateCompatibleBitmap(hDC, cursorSizeX, cursorSizeY); // original 39 | auto hAndMaskBitmap = ::CreateBitmap(cursorSizeX, cursorSizeY, 1, 1, nullptr); // monochrome 40 | auto hXorMaskBitmap = ::CreateCompatibleBitmap(hDC, cursorSizeX, cursorSizeY); // color 41 | 42 | // Release the system display DC 43 | ::ReleaseDC(*this, hDC); 44 | 45 | // Select the bitmaps to helper DC 46 | auto hOldMainBitmap = static_cast(::SelectObject(hMainDC, hSourceBitmap)); 47 | auto hOldAndMaskBitmap = static_cast(::SelectObject(hAndMaskDC, hAndMaskBitmap)); 48 | auto hOldXorMaskBitmap = static_cast(::SelectObject(hXorMaskDC, hXorMaskBitmap)); 49 | 50 | // fill our bitmap with the 'transparent' color RGB(1,1,1) 51 | RECT rc; 52 | rc.left = 0; 53 | rc.top = 0; 54 | rc.right = cursorSizeX; 55 | rc.bottom = cursorSizeY; 56 | SetBkColor(hMainDC, RGB(1, 1, 1)); 57 | ::ExtTextOut(hMainDC, 0, 0, ETO_OPAQUE, &rc, nullptr, 0, nullptr); 58 | // set up the pen and brush to draw 59 | auto hPen = CreatePen(PS_SOLID, 1, color); 60 | auto hOldPen = static_cast(SelectObject(hMainDC, hPen)); 61 | auto hBrush = CreateSolidBrush(color); 62 | auto hOldBrush = static_cast(SelectObject(hMainDC, hBrush)); 63 | 64 | // draw the real cursor 65 | HICON hIcon = CopyIcon(LoadCursor(nullptr, IDC_ARROW)); 66 | ICONINFO ii; 67 | GetIconInfo(hIcon, &ii); 68 | DrawIcon(hMainDC, cursorSizeX / 2, cursorSizeY / 2, hIcon); 69 | DestroyIcon(hIcon); 70 | 71 | // draw the brush circle 72 | Ellipse(hMainDC, (cursorSizeX - penwidth) / 2, (cursorSizeY - penwidth) / 2, (cursorSizeX - penwidth) / 2 + penwidth, (cursorSizeY - penwidth) / 2 + penwidth); 73 | 74 | SelectObject(hMainDC, hOldBrush); 75 | SelectObject(hMainDC, hOldPen); 76 | DeleteObject(hBrush); 77 | DeleteObject(hPen); 78 | 79 | // Assign the monochrome AND mask bitmap pixels so that a pixels of the source bitmap 80 | // with 'clrTransparent' will be white pixels of the monochrome bitmap 81 | ::SetBkColor(hMainDC, RGB(1, 1, 1)); 82 | ::BitBlt(hAndMaskDC, 0, 0, cursorSizeX, cursorSizeY, hMainDC, 0, 0, SRCCOPY); 83 | 84 | // Assign the color XOR mask bitmap pixels so that a pixels of the source bitmap 85 | // with 'clrTransparent' will be black and rest the pixels same as corresponding 86 | // pixels of the source bitmap 87 | ::SetBkColor(hXorMaskDC, RGB(0, 0, 0)); 88 | ::SetTextColor(hXorMaskDC, RGB(255, 255, 255)); 89 | ::BitBlt(hXorMaskDC, 0, 0, cursorSizeX, cursorSizeY, hAndMaskDC, 0, 0, SRCCOPY); 90 | ::BitBlt(hXorMaskDC, 0, 0, cursorSizeX, cursorSizeY, hMainDC, 0, 0, SRCAND); 91 | 92 | // Deselect bitmaps from the helper DC 93 | ::SelectObject(hMainDC, hOldMainBitmap); 94 | ::SelectObject(hAndMaskDC, hOldAndMaskBitmap); 95 | ::SelectObject(hXorMaskDC, hOldXorMaskBitmap); 96 | 97 | // Delete the helper DC 98 | ::DeleteDC(hXorMaskDC); 99 | ::DeleteDC(hAndMaskDC); 100 | ::DeleteDC(hMainDC); 101 | 102 | ICONINFO iconInfo = {0}; 103 | iconInfo.fIcon = FALSE; 104 | iconInfo.xHotspot = cursorSizeX / 2; 105 | iconInfo.yHotspot = cursorSizeY / 2; 106 | iconInfo.hbmMask = hAndMaskBitmap; 107 | iconInfo.hbmColor = hXorMaskBitmap; 108 | 109 | return ::CreateIconIndirect(&iconInfo); 110 | } 111 | -------------------------------------------------------------------------------- /src/MagnifierWindow.cpp: -------------------------------------------------------------------------------- 1 | // demoHelper - screen drawing and presentation tool 2 | 3 | // Copyright (C) 2021 - Stefan Kueng 4 | 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | 15 | // You should have received a copy of the GNU General Public License 16 | // along with this program; if not, write to the Free Software Foundation, 17 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | // 19 | #include "stdafx.h" 20 | #include "MagnifierWindow.h" 21 | 22 | BOOL CMagnifierWindow::Create(HINSTANCE hInst, HWND hwndHost, BOOL visible) 23 | { 24 | DWORD dwStyle = WS_CHILD | WS_EX_COMPOSITED | MS_SHOWMAGNIFIEDCURSOR | MS_CLIPAROUNDCURSOR; 25 | if (visible) 26 | dwStyle |= WS_VISIBLE; 27 | 28 | m_hWnd = CreateWindow(WC_MAGNIFIER, // Magnifier window class name defined in magnification.h 29 | L"MagnifierWindow2", 30 | dwStyle, 31 | 0, 0, 100, 100, 32 | hwndHost, nullptr, hInst, nullptr); 33 | 34 | if (m_hWnd == nullptr) 35 | return FALSE; 36 | 37 | return TRUE; 38 | } 39 | 40 | BOOL CMagnifierWindow::SetMagnification(POINT mousePt, float magnification) 41 | { 42 | // first adjust the mousePt to the current zoom rect 43 | RECT client = {0}; 44 | GetWindowRect(*this, &client); 45 | auto clientWidth = client.right - client.left; 46 | auto clientHeight = client.bottom - client.top; 47 | auto sourceWidth = m_sourceRect.right - m_sourceRect.left; 48 | auto sourceHeight = m_sourceRect.bottom - m_sourceRect.top; 49 | 50 | mousePt.x = mousePt.x - client.left; 51 | mousePt.y = mousePt.y - client.top; 52 | 53 | mousePt.x = mousePt.x * sourceWidth / clientWidth + m_sourceRect.left; 54 | mousePt.y = mousePt.y * sourceHeight / clientHeight + m_sourceRect.top; 55 | 56 | if (magnification == 0.0f) 57 | magnification = m_magFactor; 58 | 59 | m_sourceRect.left = static_cast(mousePt.x - ((clientWidth / magnification) / 2.0f)); 60 | m_sourceRect.right = static_cast(mousePt.x + ((clientWidth / magnification) / 2.0f)); 61 | m_sourceRect.top = static_cast(mousePt.y - ((clientHeight / magnification) / 2.0f)); 62 | m_sourceRect.bottom = static_cast(mousePt.y + ((clientHeight / magnification) / 2.0f)); 63 | 64 | if (m_sourceRect.left < client.left) 65 | { 66 | m_sourceRect.left = client.left; 67 | m_sourceRect.right = static_cast(m_sourceRect.left + (clientWidth / magnification)); 68 | } 69 | if (m_sourceRect.top < client.top) 70 | { 71 | m_sourceRect.top = client.top; 72 | m_sourceRect.bottom = static_cast(m_sourceRect.top + (clientHeight / magnification)); 73 | } 74 | 75 | if (m_sourceRect.right > client.right) 76 | { 77 | m_sourceRect.right = client.right; 78 | m_sourceRect.left = static_cast(client.right - (clientWidth / magnification)); 79 | } 80 | if (m_sourceRect.bottom > client.bottom) 81 | { 82 | m_sourceRect.bottom = client.bottom; 83 | m_sourceRect.top = static_cast(client.bottom - (clientHeight / magnification)); 84 | } 85 | 86 | MAGTRANSFORM matrix; 87 | memset(&matrix, 0, sizeof(matrix)); 88 | matrix.v[0][0] = magnification; 89 | matrix.v[1][1] = magnification; 90 | matrix.v[2][2] = 1.0f; 91 | 92 | m_magFactor = magnification; 93 | 94 | MagShowSystemCursor(false); 95 | MagSetWindowTransform(m_hWnd, &matrix); 96 | return MagSetWindowSource(m_hWnd, m_sourceRect); 97 | } 98 | 99 | BOOL CMagnifierWindow::SetSourceRect(RECT rc) 100 | { 101 | m_sourceRect = rc; 102 | 103 | RECT client = {0}; 104 | GetClientRect(*this, &client); 105 | auto magFactor = static_cast(client.right - client.left) / static_cast(m_sourceRect.right - m_sourceRect.left); 106 | MAGTRANSFORM matrix; 107 | memset(&matrix, 0, sizeof(matrix)); 108 | matrix.v[0][0] = magFactor; 109 | matrix.v[1][1] = magFactor; 110 | matrix.v[2][2] = 1.0f; 111 | 112 | m_magFactor = magFactor; 113 | 114 | MagShowSystemCursor(false); 115 | MagSetWindowTransform(m_hWnd, &matrix); 116 | return MagSetWindowSource(m_hWnd, m_sourceRect); 117 | } 118 | 119 | BOOL CMagnifierWindow::UpdateMagnifier() const 120 | { 121 | return MagSetWindowSource(m_hWnd, m_sourceRect); 122 | } 123 | 124 | BOOL CMagnifierWindow::Reset() 125 | { 126 | MAGTRANSFORM matrix; 127 | memset(&matrix, 0, sizeof(matrix)); 128 | matrix.v[0][0] = 1.0f; 129 | matrix.v[1][1] = 1.0f; 130 | matrix.v[2][2] = 1.0f; 131 | 132 | m_magFactor = 1.0f; 133 | 134 | MagShowSystemCursor(true); 135 | return MagSetWindowTransform(m_hWnd, &matrix); 136 | } 137 | -------------------------------------------------------------------------------- /default.build: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 14 | 15 | 16 | Sets the version information as properties, env variables 17 | and sets up the different version specific files. 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | now start an admin console in choco\package and then run 117 | choco pack 118 | to upload the package, run 119 | cpush demohelper-x.x.x.nupkg 120 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /src/KeyboardOverlay.cpp: -------------------------------------------------------------------------------- 1 | // demoHelper - screen drawing and presentation tool 2 | 3 | // Copyright (C) 2020-2021 - Stefan Kueng 4 | 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | 15 | // You should have received a copy of the GNU General Public License 16 | // along with this program; if not, write to the Free Software Foundation, 17 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | // 19 | #include "stdafx.h" 20 | #include "KeyboardOverlay.h" 21 | #include "DPIAware.h" 22 | #include "MemDC.h" 23 | #pragma warning(push) 24 | #pragma warning(disable : 4458) // declaration of 'xxx' hides class member 25 | #include 26 | #pragma warning(pop) 27 | #pragma comment(lib, "gdiplus.lib") 28 | 29 | #pragma comment(lib, "Winmm.lib") 30 | 31 | constexpr int FADE_TIMER = 101; 32 | 33 | CKeyboardOverlayWnd::~CKeyboardOverlayWnd() 34 | { 35 | } 36 | 37 | bool CKeyboardOverlayWnd::RegisterAndCreateWindow() 38 | { 39 | WNDCLASSEX wcx; 40 | 41 | // Fill in the window class structure with default parameters 42 | wcx.cbSize = sizeof(WNDCLASSEX); 43 | wcx.style = CS_HREDRAW | CS_VREDRAW | CS_CLASSDC; 44 | wcx.lpfnWndProc = CWindow::stWinMsgHandler; 45 | wcx.cbClsExtra = 0; 46 | wcx.cbWndExtra = 0; 47 | wcx.hInstance = hResource; 48 | wcx.hCursor = LoadCursor(nullptr, IDC_HAND); 49 | wcx.lpszClassName = L"CKeyboardOverlayWnd_{fda7e16a-f6b2-4be2-a3fc-ea929a07385d}"; 50 | wcx.hIcon = nullptr; 51 | wcx.hbrBackground = reinterpret_cast((COLOR_WINDOW + 1)); 52 | wcx.lpszMenuName = nullptr; 53 | wcx.hIconSm = nullptr; 54 | if (RegisterWindow(&wcx)) 55 | { 56 | if (CreateEx(WS_EX_TOOLWINDOW | WS_EX_LAYERED | WS_EX_TRANSPARENT | WS_EX_NOACTIVATE | WS_EX_TOPMOST, WS_POPUP | WS_DISABLED, nullptr)) 57 | { 58 | // Make the window fully transparent. 59 | return SetLayeredWindowAttributes(*this, 0, 255, LWA_COLORKEY | LWA_ALPHA); 60 | } 61 | } 62 | return false; 63 | } 64 | 65 | void CKeyboardOverlayWnd::Show(const std::wstring& text) 66 | { 67 | m_text = text; 68 | InvalidateRect(*this, nullptr, false); 69 | m_animVar = Animator::Instance().CreateAnimationVariable(255.0, 255.0); 70 | auto transKeep = Animator::Instance().CreateConstantTransition(2.0); 71 | auto transFade = Animator::Instance().CreateSmoothStopTransition(m_animVar, 0.8, 0.0); 72 | auto storyBoard = Animator::Instance().CreateStoryBoard(); 73 | storyBoard->AddTransition(m_animVar.m_animVar, transKeep); 74 | storyBoard->AddTransition(m_animVar.m_animVar, transFade); 75 | Animator::Instance().RunStoryBoard(storyBoard, [this]() { 76 | auto animVar = static_cast(Animator::GetIntegerValue(m_animVar)); 77 | SetLayeredWindowAttributes(*this, 0, animVar, LWA_COLORKEY | LWA_ALPHA); 78 | InvalidateRect(*this, nullptr, false); 79 | if (animVar == 0) 80 | ShowWindow(*this, SW_HIDE); 81 | }); 82 | SetLayeredWindowAttributes(*this, 0, static_cast(255), LWA_COLORKEY | LWA_ALPHA); 83 | } 84 | 85 | LRESULT CALLBACK CKeyboardOverlayWnd::WinMsgHandler(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 86 | { 87 | switch (uMsg) 88 | { 89 | case WM_CREATE: 90 | m_hwnd = hwnd; 91 | break; 92 | case WM_LBUTTONUP: 93 | // user clicked on the popup window 94 | break; 95 | case WM_ERASEBKGND: 96 | return TRUE; 97 | case WM_PAINT: 98 | { 99 | RECT rect; 100 | if (GetUpdateRect(*this, &rect, false)) 101 | { 102 | ::GetClientRect(*this, &rect); 103 | PAINTSTRUCT ps; 104 | HDC hDc = BeginPaint(hwnd, &ps); 105 | { 106 | CMemDC memDc(hDc); 107 | OnPaint(memDc, &rect); 108 | } 109 | EndPaint(hwnd, &ps); 110 | } 111 | } 112 | break; 113 | case WM_SETFOCUS: 114 | { 115 | if (wParam) 116 | SetFocus(reinterpret_cast(wParam)); // return the focus, we don't want it 117 | } 118 | break; 119 | default: 120 | return DefWindowProc(hwnd, uMsg, wParam, lParam); 121 | } 122 | 123 | return 0; 124 | }; 125 | 126 | void CKeyboardOverlayWnd::OnPaint(HDC hDC, LPRECT pRect) 127 | { 128 | auto animVar = static_cast(Animator::GetIntegerValue(m_animVar)); 129 | Gdiplus::Rect rect = {pRect->left, pRect->top, pRect->right - pRect->left, pRect->bottom - pRect->top}; 130 | Gdiplus::RectF rectF = {static_cast(pRect->left), 131 | static_cast(pRect->top), 132 | static_cast(pRect->right - pRect->left), 133 | static_cast(pRect->bottom - pRect->top)}; 134 | Gdiplus::Graphics graphics(hDC); 135 | graphics.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias); 136 | graphics.SetInterpolationMode(Gdiplus::InterpolationModeHighQualityBicubic); 137 | 138 | Gdiplus::SolidBrush transparentBrush(Gdiplus::Color::MakeARGB(255, 0, 0, 0)); 139 | Gdiplus::SolidBrush textBrush(Gdiplus::Color::MakeARGB(static_cast(animVar), 255, 255, 255)); 140 | Gdiplus::SolidBrush shadowBrush(Gdiplus::Color::MakeARGB(static_cast(animVar), 1, 1, 1)); 141 | graphics.FillRectangle(&transparentBrush, rect); 142 | 143 | Gdiplus::StringFormat format; 144 | format.SetAlignment(Gdiplus::StringAlignment::StringAlignmentCenter); 145 | format.SetLineAlignment(Gdiplus::StringAlignment::StringAlignmentCenter); 146 | 147 | Gdiplus::FontFamily fontFamily(L"Arial"); 148 | Gdiplus::GraphicsPath path; 149 | path.AddString(m_text.c_str(), static_cast(m_text.size()), 150 | &fontFamily, Gdiplus::FontStyleRegular, 151 | static_cast(CDPIAware::Instance().PointsToPixels(*this, 20)), rectF, &format); 152 | 153 | for (int i = 1; i < 8; ++i) 154 | { 155 | Gdiplus::Pen pen(Gdiplus::Color(static_cast(animVar) / 8, 192, 20, 20), static_cast(i)); 156 | pen.SetLineJoin(Gdiplus::LineJoinRound); 157 | graphics.DrawPath(&pen, &path); 158 | } 159 | 160 | graphics.FillPath(&textBrush, &path); 161 | } 162 | -------------------------------------------------------------------------------- /src/MemDC.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | ////////////////////////////////////////////////// 4 | // CMemDC - memory DC 5 | // 6 | // Author: Keith Rule 7 | // Email: keithr@europa.com 8 | // Copyright 1996-1997, Keith Rule 9 | // 10 | // You may freely use or modify this code provided this 11 | // Copyright is included in all derived versions. 12 | // 13 | // History - 10/3/97 Fixed scrolling bug. 14 | // Added print support. 15 | // 25 feb 98 - fixed minor assertion bug 16 | // 17 | // This class implements a memory Device Context 18 | 19 | #ifdef _MFC_VER 20 | class CMemDC : public CDC 21 | { 22 | public: 23 | // constructor sets up the memory DC 24 | CMemDC(CDC* pDC, bool bTempOnly = false, int nOffset = 0) : CDC() 25 | { 26 | ASSERT(pDC != NULL); 27 | 28 | m_pDC = pDC; 29 | m_pOldBitmap = NULL; 30 | m_bMemDC = ((!pDC->IsPrinting()) && (!GetSystemMetrics(SM_REMOTESESSION))); 31 | m_bTempOnly = bTempOnly; 32 | 33 | if (m_bMemDC) // Create a Memory DC 34 | { 35 | pDC->GetClipBox(&m_rect); 36 | CreateCompatibleDC(pDC); 37 | m_bitmap.CreateCompatibleBitmap(pDC, m_rect.Width() - nOffset, m_rect.Height()); 38 | m_pOldBitmap = SelectObject(&m_bitmap); 39 | SetWindowOrg(m_rect.left, m_rect.top); 40 | } 41 | else // Make a copy of the relevant parts of the current DC for printing 42 | { 43 | m_bPrinting = pDC->m_bPrinting; 44 | m_hDC = pDC->m_hDC; 45 | m_hAttribDC = pDC->m_hAttribDC; 46 | } 47 | 48 | FillSolidRect(m_rect, pDC->GetBkColor()); 49 | } 50 | 51 | CMemDC(CDC* pDC, const CRect* pRect) : CDC() 52 | { 53 | ASSERT(pDC != NULL); 54 | 55 | // Some initialization 56 | m_pDC = pDC; 57 | m_pOldBitmap = NULL; 58 | m_bMemDC = !pDC->IsPrinting(); 59 | m_bTempOnly = false; 60 | 61 | // Get the rectangle to draw 62 | if (pRect == NULL) { 63 | pDC->GetClipBox(&m_rect); 64 | } else { 65 | m_rect = *pRect; 66 | } 67 | 68 | if (m_bMemDC) { 69 | // Create a Memory DC 70 | CreateCompatibleDC(pDC); 71 | pDC->LPtoDP(&m_rect); 72 | 73 | m_bitmap.CreateCompatibleBitmap(pDC, m_rect.Width(), m_rect.Height()); 74 | m_pOldBitmap = SelectObject(&m_bitmap); 75 | 76 | SetMapMode(pDC->GetMapMode()); 77 | 78 | SetWindowExt(pDC->GetWindowExt()); 79 | SetViewportExt(pDC->GetViewportExt()); 80 | 81 | pDC->DPtoLP(&m_rect); 82 | SetWindowOrg(m_rect.left, m_rect.top); 83 | } else { 84 | // Make a copy of the relevant parts of the current DC for printing 85 | m_bPrinting = pDC->m_bPrinting; 86 | m_hDC = pDC->m_hDC; 87 | m_hAttribDC = pDC->m_hAttribDC; 88 | } 89 | 90 | // Fill background 91 | FillSolidRect(m_rect, pDC->GetBkColor()); 92 | } 93 | 94 | // Destructor copies the contents of the mem DC to the original DC 95 | ~CMemDC() 96 | { 97 | if (m_bMemDC) { 98 | // Copy the off screen bitmap onto the screen. 99 | if (!m_bTempOnly) 100 | m_pDC->BitBlt(m_rect.left, m_rect.top, m_rect.Width(), m_rect.Height(), 101 | this, m_rect.left, m_rect.top, SRCCOPY); 102 | 103 | //Swap back the original bitmap. 104 | SelectObject(m_pOldBitmap); 105 | } else { 106 | // All we need to do is replace the DC with an illegal value, 107 | // this keeps us from accidentally deleting the handles associated with 108 | // the CDC that was passed to the constructor. 109 | m_hDC = m_hAttribDC = NULL; 110 | } 111 | } 112 | 113 | // Allow usage as a pointer 114 | CMemDC* operator->() {return this;} 115 | 116 | // Allow usage as a pointer 117 | operator CMemDC*() {return this;} 118 | 119 | private: 120 | CBitmap m_bitmap; // Off screen bitmap 121 | CBitmap* m_pOldBitmap; // bitmap originally found in CMemDC 122 | CDC* m_pDC; // Saves CDC passed in constructor 123 | CRect m_rect; // Rectangle of drawing area. 124 | BOOL m_bMemDC; // TRUE if CDC really is a Memory DC. 125 | BOOL m_bTempOnly; // Whether to copy the contents on the real DC on destroy 126 | }; 127 | #else 128 | class CMemDC 129 | { 130 | public: 131 | 132 | // constructor sets up the memory DC 133 | CMemDC(HDC hDC, bool bTempOnly = false, int nOffset = 0) 134 | { 135 | UNREFERENCED_PARAMETER(nOffset); 136 | m_hDC = hDC; 137 | m_hOldBitmap = nullptr; 138 | m_bTempOnly = bTempOnly; 139 | 140 | GetClipBox(m_hDC, &m_rect); 141 | m_hMemDC = ::CreateCompatibleDC(m_hDC); 142 | m_hBitmap = CreateCompatibleBitmap(m_hDC, m_rect.right - m_rect.left, m_rect.bottom - m_rect.top); 143 | m_hOldBitmap = static_cast(SelectObject(m_hMemDC, m_hBitmap)); 144 | SetWindowOrgEx(m_hMemDC, m_rect.left, m_rect.top, nullptr); 145 | } 146 | 147 | CMemDC(HDC hDC, const RECT& rect) 148 | { 149 | m_hDC = hDC; 150 | m_hOldBitmap = nullptr; 151 | m_bTempOnly = false; 152 | 153 | m_rect = rect; 154 | 155 | LPtoDP(m_hDC, reinterpret_cast(&m_rect), 2); 156 | 157 | //GetClipBox(m_hDC, &m_rect); 158 | m_hMemDC = ::CreateCompatibleDC(m_hDC); 159 | m_hBitmap = CreateCompatibleBitmap(m_hDC, m_rect.right - m_rect.left, m_rect.bottom - m_rect.top); 160 | m_hOldBitmap = static_cast(SelectObject(m_hMemDC, m_hBitmap)); 161 | 162 | SetMapMode(m_hMemDC, GetMapMode(hDC)); 163 | 164 | SIZE ext; 165 | GetWindowExtEx(m_hDC, &ext); 166 | SetWindowExtEx(m_hMemDC, ext.cx, ext.cy, nullptr); 167 | 168 | GetViewportExtEx(m_hDC, &ext); 169 | SetViewportExtEx(m_hMemDC, ext.cx, ext.cy, nullptr); 170 | 171 | DPtoLP(m_hDC, reinterpret_cast(&m_rect), 2); 172 | 173 | SetWindowOrgEx(m_hMemDC, m_rect.left, m_rect.top, nullptr); 174 | } 175 | 176 | // Destructor copies the contents of the mem DC to the original DC 177 | ~CMemDC() 178 | { 179 | if (m_hMemDC) { 180 | // Copy the off screen bitmap onto the screen. 181 | if (!m_bTempOnly) 182 | BitBlt(m_hDC, m_rect.left, m_rect.top, m_rect.right-m_rect.left, m_rect.bottom-m_rect.top, m_hMemDC, m_rect.left, m_rect.top, SRCCOPY); 183 | 184 | //Swap back the original bitmap. 185 | SelectObject(m_hMemDC, m_hOldBitmap); 186 | DeleteObject(m_hBitmap); 187 | DeleteDC(m_hMemDC); 188 | } else { 189 | // All we need to do is replace the DC with an illegal value, 190 | // this keeps us from accidentally deleting the handles associated with 191 | // the CDC that was passed to the constructor. 192 | DeleteObject(m_hBitmap); 193 | DeleteDC(m_hMemDC); 194 | m_hMemDC = nullptr; 195 | } 196 | } 197 | 198 | // Allow usage as a pointer 199 | operator HDC() const {return m_hMemDC;} 200 | private: 201 | HBITMAP m_hBitmap; // Off screen bitmap 202 | HBITMAP m_hOldBitmap; // bitmap originally found in CMemDC 203 | HDC m_hDC; // Saves CDC passed in constructor 204 | HDC m_hMemDC; // our own memory DC 205 | RECT m_rect; // Rectangle of drawing area. 206 | bool m_bTempOnly; // Whether to copy the contents on the real DC on destroy 207 | }; 208 | 209 | #endif 210 | 211 | -------------------------------------------------------------------------------- /src/MainWindow.h: -------------------------------------------------------------------------------- 1 | // demoHelper - screen drawing and presentation tool 2 | 3 | // Copyright (C) 2007-2008, 2012, 2020-2021 - Stefan Kueng 4 | 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | 15 | // You should have received a copy of the GNU General Public License 16 | // along with this program; if not, write to the Free Software Foundation, 17 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | // 19 | 20 | #pragma once 21 | 22 | #include "BaseWindow.h" 23 | #include "resource.h" 24 | #include "hyperlink.h" 25 | #include "ResString.h" 26 | #include "AnimationManager.h" 27 | #include "KeyboardOverlayD2D.h" 28 | #include "MouseOverlay.h" 29 | #include "MagnifierWindow.h" 30 | #include 31 | #include 32 | #include 33 | 34 | #define DRAW_HOTKEY 100 35 | #define ZOOM_HOTKEY 101 36 | #define LENS_HOTKEY 102 37 | 38 | #define TIMER_ID_DRAW 101 39 | #define TIMER_ID_ZOOM 102 40 | #define TIMER_ID_FADE 103 41 | #define TIMER_ID_LENS 104 42 | #define TIMER_OVERLAY_POSITIONS 105 43 | 44 | #define LINE_ALPHA 100 45 | 46 | enum class LineType 47 | { 48 | Hand, 49 | Straight, 50 | Arrow, 51 | Rectangle, 52 | Ellipse 53 | }; 54 | 55 | enum class OverlayPosition 56 | { 57 | TopLeft, 58 | TopRight, 59 | BottomLeft, 60 | BottomRight 61 | }; 62 | 63 | class WndPositions 64 | { 65 | public: 66 | WndPositions(HWND hWnd, int x, int y, int cx, int cy) 67 | : hWnd(hWnd) 68 | , x(x) 69 | , y(y) 70 | , cx(cx) 71 | , cy(cy) 72 | { 73 | } 74 | HWND hWnd = nullptr; 75 | int x = 0; 76 | int y = 0; 77 | int cx = 0; 78 | int cy = 0; 79 | }; 80 | 81 | class DrawLine 82 | { 83 | public: 84 | DrawLine() 85 | { 86 | } 87 | 88 | LineType lineType = LineType::Hand; 89 | int lineIndex = 0; 90 | std::vector points; 91 | BYTE alpha = 100; 92 | 93 | Gdiplus::Point lineStartPoint = {-1, -1}; 94 | Gdiplus::Point lineEndPoint = {-1, -1}; 95 | 96 | int penWidth = 1; 97 | int colorIndex = 0; 98 | }; 99 | 100 | class CMainWindow : public CWindow 101 | { 102 | public: 103 | explicit CMainWindow(HINSTANCE hInst, const WNDCLASSEX* wcx = nullptr) 104 | : CWindow(hInst, wcx) 105 | , niData({0}) 106 | , hDesktopCompatibleDC(nullptr) 107 | , hDesktopCompatibleBitmap(nullptr) 108 | , hOldBmp(nullptr) 109 | , m_bDrawing(false) 110 | , m_zoomFactor(1.2f) 111 | , m_bZooming(false) 112 | , m_colorIndex(1) 113 | , m_currentPenWidth(6) 114 | , m_currentAlpha(LINE_ALPHA) 115 | , m_fadeSeconds(0) 116 | , m_lineStartShiftPoint({}) 117 | , m_hCursor(nullptr) 118 | , m_hPreviousCursor(nullptr) 119 | , m_bMarker(false) 120 | , m_oldPenWidth(6) 121 | , m_oldColorIndex(0) 122 | , m_oldAlpha(0) 123 | , m_bInlineZoom(false) 124 | , m_ptInlineZoomStartPoint({}) 125 | , m_ptInlineZoomEndPoint({}) 126 | , m_rcScreen({0}) 127 | { 128 | SetWindowTitle(static_cast(ResString(hResource, IDS_APP_TITLE))); 129 | m_colors[0] = RGB(255, 255, 0); 130 | m_colors[1] = RGB(255, 0, 0); 131 | m_colors[2] = RGB(150, 0, 0); 132 | m_colors[3] = RGB(0, 255, 0); 133 | m_colors[4] = RGB(0, 150, 0); 134 | m_colors[5] = RGB(0, 0, 255); 135 | m_colors[6] = RGB(0, 0, 150); 136 | m_colors[7] = RGB(0, 0, 0); 137 | m_colors[8] = RGB(150, 150, 150); 138 | m_colors[9] = RGB(0, 255, 255); 139 | m_animVarZoom = Animator::Instance().CreateAnimationVariable(1.2, 1.2); 140 | }; 141 | ~CMainWindow(){}; 142 | 143 | bool RegisterAndCreateWindow(); 144 | 145 | protected: 146 | /// the message handler for this window 147 | LRESULT CALLBACK WinMsgHandler(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) override; 148 | 149 | /// Handles all the WM_COMMAND window messages (e.g. menu commands) 150 | LRESULT DoCommand(int id); 151 | 152 | bool StartPresentationMode(); 153 | bool EndPresentationMode(); 154 | bool StartInlineZoom(); 155 | bool StartZoomingMode(); 156 | bool EndZoomingMode(); 157 | bool DrawZoom(HDC hdc, POINT pt); 158 | HCURSOR CreateDrawCursor(COLORREF color, int penwidth); 159 | 160 | static BOOL CALLBACK OptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam); 161 | static BOOL CALLBACK ColorDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam); 162 | static WORD HotKeyControl2HotKey(WORD hk); 163 | static WORD HotKey2HotKeyControl(WORD hk); 164 | static LRESULT LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam); 165 | static LRESULT LowLevelMouseProc(int nCode, WPARAM wParam, LPARAM lParam); 166 | 167 | void RegisterHotKeys(); 168 | bool UpdateCursor(); 169 | static void ClearOutdatedPopupWindows(); 170 | 171 | protected: 172 | NOTIFYICONDATA niData; 173 | HDC hDesktopCompatibleDC; 174 | HBITMAP hDesktopCompatibleBitmap; 175 | HBITMAP hOldBmp; 176 | 177 | bool m_bDrawing; 178 | float m_zoomFactor; 179 | bool m_bZooming; 180 | 181 | int m_colorIndex; 182 | int m_currentPenWidth; 183 | BYTE m_currentAlpha; 184 | int m_fadeSeconds; 185 | 186 | POINT m_lineStartShiftPoint; 187 | 188 | COLORREF m_colors[10]; 189 | 190 | HCURSOR m_hCursor; 191 | HCURSOR m_hPreviousCursor; 192 | 193 | bool m_bMarker; 194 | int m_oldPenWidth; 195 | int m_oldColorIndex; 196 | BYTE m_oldAlpha; 197 | 198 | bool m_bInlineZoom; 199 | POINT m_ptInlineZoomStartPoint; 200 | POINT m_ptInlineZoomEndPoint; 201 | 202 | RECT m_rcScreen; 203 | AnimationVariable m_animVarZoom; 204 | std::deque m_drawLines; 205 | 206 | static HHOOK m_hKeyboardHook; 207 | static HHOOK m_hMouseHook; 208 | static DWORD m_lastHookTime; 209 | static POINT m_lastHookPoint; 210 | static WPARAM m_lastHookMsg; 211 | //static CKeyboardOverlayWnd m_infoOverlay; 212 | static std::unique_ptr m_infoOverlay; 213 | static CMouseOverlayWnd m_mouseOverlay; 214 | static CMagnifierWindow m_magnifierWindow; 215 | static bool m_bLensMode; 216 | static bool m_bMouseVisuals; 217 | static bool m_bMouseClicks; 218 | static COLORREF m_mvLColor; 219 | static COLORREF m_mvMColor; 220 | static COLORREF m_mvRColor; 221 | static std::vector m_keySequence; 222 | static std::deque> m_overlayWnds; 223 | static OverlayPosition m_overlayPosition; 224 | static HWND m_mainWnd; 225 | static std::vector m_wndPositions; 226 | }; 227 | -------------------------------------------------------------------------------- /src/DemoHelper.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | {49e8bfba-7391-4a67-88f8-d925f77c5b60} 18 | 19 | 20 | {0b59c782-7415-401f-916e-b9f6739a1874} 21 | 22 | 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | Header Files 32 | 33 | 34 | Header Files 35 | 36 | 37 | Header Files 38 | 39 | 40 | sktoolslib 41 | 42 | 43 | sktoolslib 44 | 45 | 46 | sktoolslib 47 | 48 | 49 | sktoolslib 50 | 51 | 52 | sktoolslib 53 | 54 | 55 | sktoolslib 56 | 57 | 58 | sktoolslib 59 | 60 | 61 | sktoolslib 62 | 63 | 64 | sktoolslib 65 | 66 | 67 | sktoolslib 68 | 69 | 70 | Header Files 71 | 72 | 73 | Header Files 74 | 75 | 76 | Header Files 77 | 78 | 79 | Header Files 80 | 81 | 82 | Header Files 83 | 84 | 85 | sktoolslib 86 | 87 | 88 | sktoolslib 89 | 90 | 91 | sktoolslib 92 | 93 | 94 | Header Files 95 | 96 | 97 | Header Files 98 | 99 | 100 | sktoolslib 101 | 102 | 103 | 104 | 105 | Resource Files 106 | 107 | 108 | 109 | scripts 110 | 111 | 112 | scripts 113 | 114 | 115 | scripts 116 | 117 | 118 | scripts 119 | 120 | 121 | scripts 122 | 123 | 124 | scripts 125 | 126 | 127 | Resource Files 128 | 129 | 130 | Resource Files 131 | 132 | 133 | 134 | 135 | Resource Files 136 | 137 | 138 | 139 | 140 | sktoolslib 141 | 142 | 143 | sktoolslib 144 | 145 | 146 | Source Files 147 | 148 | 149 | Source Files 150 | 151 | 152 | Source Files 153 | 154 | 155 | Source Files 156 | 157 | 158 | Source Files 159 | 160 | 161 | Source Files 162 | 163 | 164 | sktoolslib 165 | 166 | 167 | sktoolslib 168 | 169 | 170 | sktoolslib 171 | 172 | 173 | sktoolslib 174 | 175 | 176 | sktoolslib 177 | 178 | 179 | sktoolslib 180 | 181 | 182 | Source Files 183 | 184 | 185 | Source Files 186 | 187 | 188 | Source Files 189 | 190 | 191 | Source Files 192 | 193 | 194 | Source Files 195 | 196 | 197 | sktoolslib 198 | 199 | 200 | sktoolslib 201 | 202 | 203 | sktoolslib 204 | 205 | 206 | Source Files 207 | 208 | 209 | Source Files 210 | 211 | 212 | sktoolslib 213 | 214 | 215 | 216 | 217 | Resource Files 218 | 219 | 220 | -------------------------------------------------------------------------------- /src/OptionsDlg.cpp: -------------------------------------------------------------------------------- 1 | // demoHelper - screen drawing and presentation tool 2 | 3 | // Copyright (C) 2007-2008, 2012, 2015, 2020-2021, 2023 - Stefan Kueng 4 | 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | 15 | // You should have received a copy of the GNU General Public License 16 | // along with this program; if not, write to the Free Software Foundation, 17 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | // 19 | 20 | #include "stdafx.h" 21 | #include "DemoHelper.h" 22 | #include "MainWindow.h" 23 | #include "IniSettings.h" 24 | #include "ColorDlg.h" 25 | 26 | BOOL CALLBACK CMainWindow::OptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) 27 | { 28 | switch (message) 29 | { 30 | case WM_INITDIALOG: 31 | { 32 | auto zoom = static_cast(CIniSettings::Instance().GetInt64(L"HotKeys", L"zoom", 0x231)); 33 | auto draw = static_cast(CIniSettings::Instance().GetInt64(L"HotKeys", L"draw", 0x232)); 34 | auto lens = static_cast(CIniSettings::Instance().GetInt64(L"HotKeys", L"lens", 0x233)); 35 | auto allMonitors = CIniSettings::Instance().GetInt64(L"Misc", L"allmonitors", 0); 36 | auto fadeSeconds = CIniSettings::Instance().GetInt64(L"Draw", L"fadeseconds", 0); 37 | auto keyHook = CIniSettings::Instance().GetInt64(L"Hooks", L"keyboard", 1); 38 | auto mouseHook = CIniSettings::Instance().GetInt64(L"Hooks", L"mouse", 1); 39 | auto mouseVisual = CIniSettings::Instance().GetInt64(L"Misc", L"mousevisual", 1); 40 | auto overlayPosition = static_cast(CIniSettings::Instance().GetInt64(L"Misc", L"OvlPosition", static_cast(OverlayPosition::BottomRight))); 41 | SendMessage(GetDlgItem(hwndDlg, IDC_HOTKEY_ZOOMMODE), HKM_SETHOTKEY, static_cast(zoom), 0); 42 | SendMessage(GetDlgItem(hwndDlg, IDC_HOTKEY_DRAWMODE), HKM_SETHOTKEY, static_cast(draw), 0); 43 | SendMessage(GetDlgItem(hwndDlg, IDC_HOTKEY_LENSMODE), HKM_SETHOTKEY, static_cast(lens), 0); 44 | CheckRadioButton(hwndDlg, IDC_CURRENTMONITOR, IDC_ALLMONITORS, allMonitors ? IDC_ALLMONITORS : IDC_CURRENTMONITOR); 45 | CheckDlgButton(hwndDlg, IDC_KEYHOOK, keyHook ? BST_CHECKED : BST_UNCHECKED); 46 | CheckDlgButton(hwndDlg, IDC_MOUSEHOOK, mouseHook ? BST_CHECKED : BST_UNCHECKED); 47 | CheckDlgButton(hwndDlg, IDC_MOUSEVISUALS, mouseVisual ? BST_CHECKED : BST_UNCHECKED); 48 | CheckRadioButton(hwndDlg, IDC_POS_TOPLEFT, IDC_POS_BOTTOMRIGHT, static_cast(overlayPosition) + IDC_POS_TOPLEFT); 49 | TCHAR buffer[128] = {0}; 50 | LoadString(g_hInstance, IDS_WEBLINK, buffer, _countof(buffer)); 51 | _stprintf_s(buffer, _countof(buffer), _T("%ld"), static_cast(fadeSeconds)); 52 | SetWindowText(GetDlgItem(hwndDlg, IDC_FADESECONDS), buffer); 53 | 54 | // position the dialog box on the screen 55 | HWND hwndOwner; 56 | RECT rc, rcDlg, rcOwner; 57 | 58 | hwndOwner = GetDesktopWindow(); 59 | 60 | GetWindowRect(hwndOwner, &rcOwner); 61 | GetWindowRect(hwndDlg, &rcDlg); 62 | CopyRect(&rc, &rcOwner); 63 | 64 | OffsetRect(&rcDlg, -rcDlg.left, -rcDlg.top); 65 | OffsetRect(&rc, -rc.left, -rc.top); 66 | OffsetRect(&rc, -rcDlg.right, -rcDlg.bottom); 67 | 68 | SetWindowPos(hwndDlg, HWND_TOP, rcOwner.left + (rc.right / 2), rcOwner.top + (rc.bottom / 2), 0, 0, SWP_NOSIZE); 69 | } 70 | break; 71 | case WM_COMMAND: 72 | switch (LOWORD(wParam)) 73 | { 74 | case IDOK: 75 | { 76 | LRESULT res = SendMessage(GetDlgItem(hwndDlg, IDC_HOTKEY_DRAWMODE), HKM_GETHOTKEY, 0, 0); 77 | CIniSettings::Instance().SetInt64(L"HotKeys", L"draw", res); 78 | res = SendMessage(GetDlgItem(hwndDlg, IDC_HOTKEY_ZOOMMODE), HKM_GETHOTKEY, 0, 0); 79 | CIniSettings::Instance().SetInt64(L"HotKeys", L"zoom", res); 80 | res = SendMessage(GetDlgItem(hwndDlg, IDC_HOTKEY_LENSMODE), HKM_GETHOTKEY, 0, 0); 81 | CIniSettings::Instance().SetInt64(L"HotKeys", L"lens", res); 82 | TCHAR buffer[128]; 83 | GetWindowText(GetDlgItem(hwndDlg, IDC_FADESECONDS), buffer, _countof(buffer)); 84 | CIniSettings::Instance().SetString(L"Draw", L"fadeseconds", buffer); 85 | CIniSettings::Instance().SetInt64(L"Misc", L"allmonitors", IsDlgButtonChecked(hwndDlg, IDC_ALLMONITORS) ? 1 : 0); 86 | CIniSettings::Instance().SetInt64(L"Hooks", L"keyboard", IsDlgButtonChecked(hwndDlg, IDC_KEYHOOK) ? 1 : 0); 87 | CIniSettings::Instance().SetInt64(L"Hooks", L"mouse", IsDlgButtonChecked(hwndDlg, IDC_MOUSEHOOK) ? 1 : 0); 88 | CIniSettings::Instance().SetInt64(L"Misc", L"mousevisual", IsDlgButtonChecked(hwndDlg, IDC_MOUSEVISUALS) ? 1 : 0); 89 | if (IsDlgButtonChecked(hwndDlg, IDC_POS_TOPLEFT)) 90 | CIniSettings::Instance().SetInt64(L"Misc", L"OvlPosition", static_cast(OverlayPosition::TopLeft)); 91 | if (IsDlgButtonChecked(hwndDlg, IDC_POS_TOPRIGHT)) 92 | CIniSettings::Instance().SetInt64(L"Misc", L"OvlPosition", static_cast(OverlayPosition::TopRight)); 93 | if (IsDlgButtonChecked(hwndDlg, IDC_POS_BOTTOMLEFT)) 94 | CIniSettings::Instance().SetInt64(L"Misc", L"OvlPosition", static_cast(OverlayPosition::BottomLeft)); 95 | if (IsDlgButtonChecked(hwndDlg, IDC_POS_BOTTOMRIGHT)) 96 | CIniSettings::Instance().SetInt64(L"Misc", L"OvlPosition", static_cast(OverlayPosition::BottomRight)); 97 | CIniSettings::Instance().Save(); 98 | } 99 | [[fallthrough]]; 100 | case IDCANCEL: 101 | EndDialog(hwndDlg, wParam); 102 | return TRUE; 103 | case IDC_CONF_COLORS: 104 | { 105 | CColorDlg dlg(hwndDlg); 106 | dlg.DoModal(g_hResource, IDD_COLORS, hwndDlg); 107 | } 108 | break; 109 | } 110 | break; 111 | case WM_NOTIFY: 112 | 113 | switch (reinterpret_cast(lParam)->code) 114 | { 115 | case NM_CLICK: // Fall through to the next case. 116 | case NM_RETURN: 117 | { 118 | PNMLINK pNMLink = reinterpret_cast(lParam); 119 | LITEM item = pNMLink->item; 120 | 121 | if ((reinterpret_cast(lParam)->hwndFrom == GetDlgItem(hwndDlg, IDC_SYSLINK1)) && (item.iLink == 0)) 122 | { 123 | ShellExecute(nullptr, L"open", item.szUrl, nullptr, nullptr, SW_SHOW); 124 | } 125 | 126 | break; 127 | } 128 | } 129 | } 130 | return FALSE; 131 | } 132 | 133 | WORD CMainWindow::HotKeyControl2HotKey(WORD hk) 134 | { 135 | UINT flags = 0; 136 | if (HIBYTE(hk) & HOTKEYF_ALT) 137 | flags |= MOD_ALT; 138 | if (HIBYTE(hk) & HOTKEYF_SHIFT) 139 | flags |= MOD_SHIFT; 140 | if (HIBYTE(hk) & HOTKEYF_EXT) 141 | flags |= MOD_WIN; 142 | if (HIBYTE(hk) & HOTKEYF_CONTROL) 143 | flags |= MOD_CONTROL; 144 | return MAKEWORD(LOBYTE(hk), flags); 145 | } 146 | 147 | WORD CMainWindow::HotKey2HotKeyControl(WORD hk) 148 | { 149 | UINT flags = 0; 150 | if (HIBYTE(hk) & MOD_ALT) 151 | flags |= HOTKEYF_ALT; 152 | if (HIBYTE(hk) & MOD_SHIFT) 153 | flags |= HOTKEYF_SHIFT; 154 | if (HIBYTE(hk) & MOD_WIN) 155 | flags |= HOTKEYF_EXT; 156 | if (HIBYTE(hk) & MOD_CONTROL) 157 | flags |= HOTKEYF_CONTROL; 158 | return MAKEWORD(LOBYTE(hk), flags); 159 | } 160 | -------------------------------------------------------------------------------- /src/MouseOverlay.cpp: -------------------------------------------------------------------------------- 1 | // demoHelper - screen drawing and presentation tool 2 | 3 | // Copyright (C) 2020-2021 - Stefan Kueng 4 | 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | 15 | // You should have received a copy of the GNU General Public License 16 | // along with this program; if not, write to the Free Software Foundation, 17 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | // 19 | #include "stdafx.h" 20 | #include "MouseOverlay.h" 21 | #include "DPIAware.h" 22 | #include "MemDC.h" 23 | #include 24 | using namespace Microsoft::WRL; 25 | #pragma warning(push) 26 | #pragma warning(disable : 4458) // declaration of 'xxx' hides class member 27 | #include 28 | #pragma warning(pop) 29 | #pragma comment(lib, "gdiplus.lib") 30 | 31 | #pragma comment(lib, "Winmm.lib") 32 | 33 | #define WIN_HALF_WIDTH long(CDPIAware::Instance().Scale(*this, 30)) 34 | #define WIN_HALF_HEIGHT long(CDPIAware::Instance().Scale(*this, 30)) 35 | 36 | CMouseOverlayWnd::~CMouseOverlayWnd() 37 | { 38 | } 39 | 40 | bool CMouseOverlayWnd::RegisterAndCreateWindow() 41 | { 42 | WNDCLASSEX wcx; 43 | 44 | // Fill in the window class structure with default parameters 45 | wcx.cbSize = sizeof(WNDCLASSEX); 46 | wcx.style = CS_HREDRAW | CS_VREDRAW | CS_CLASSDC; 47 | wcx.lpfnWndProc = CWindow::stWinMsgHandler; 48 | wcx.cbClsExtra = 0; 49 | wcx.cbWndExtra = 0; 50 | wcx.hInstance = hResource; 51 | wcx.hCursor = LoadCursor(nullptr, IDC_HAND); 52 | wcx.lpszClassName = L"CMouseOverlayWnd_{eee30d59-743f-42e5-8414-6ef9f311c49a}"; 53 | wcx.hIcon = nullptr; 54 | wcx.hbrBackground = reinterpret_cast((COLOR_WINDOW + 1)); 55 | wcx.lpszMenuName = nullptr; 56 | wcx.hIconSm = nullptr; 57 | if (RegisterWindow(&wcx)) 58 | { 59 | if (CreateEx(WS_EX_TOOLWINDOW | WS_EX_LAYERED | WS_EX_TRANSPARENT | WS_EX_NOACTIVATE | WS_EX_TOPMOST, WS_POPUP | WS_DISABLED, nullptr)) 60 | { 61 | // Make the window fully transparent. 62 | return SetLayeredWindowAttributes(*this, 0, 255, LWA_COLORKEY | LWA_ALPHA); 63 | } 64 | } 65 | return false; 66 | } 67 | 68 | void CMouseOverlayWnd::Show(POINT screenPos, COLORREF color, double fadeTo) 69 | { 70 | m_color = color; 71 | SetWindowPos(*this, HWND_TOPMOST, screenPos.x - WIN_HALF_WIDTH, screenPos.y - WIN_HALF_HEIGHT, 2 * WIN_HALF_WIDTH, 2 * WIN_HALF_HEIGHT, SWP_NOACTIVATE | SWP_SHOWWINDOW); 72 | InvalidateRect(*this, nullptr, false); 73 | m_animVar = Animator::Instance().CreateAnimationVariable(255.0, fadeTo); 74 | auto transFade = Animator::Instance().CreateSmoothStopTransition(m_animVar, 1.0 * ((255.0 - fadeTo) / 255.0), fadeTo); 75 | auto storyBoard = Animator::Instance().CreateStoryBoard(); 76 | storyBoard->AddTransition(m_animVar.m_animVar, transFade); 77 | Animator::Instance().RunStoryBoard(storyBoard, [this]() { 78 | auto animVar = static_cast(Animator::GetIntegerValue(m_animVar)); 79 | SetLayeredWindowAttributes(*this, 0, animVar / 2, LWA_COLORKEY | LWA_ALPHA); 80 | InvalidateRect(*this, nullptr, false); 81 | if (animVar == 0) 82 | ShowWindow(*this, SW_HIDE); 83 | }); 84 | 85 | SetLayeredWindowAttributes(*this, 0, static_cast(128), LWA_COLORKEY | LWA_ALPHA); 86 | } 87 | 88 | void CMouseOverlayWnd::UpdatePos(POINT screenPos) 89 | { 90 | if (m_animVar.m_animVar) 91 | { 92 | auto animVar = static_cast(Animator::GetIntegerValue(m_animVar)); 93 | if (animVar) 94 | SetWindowPos(*this, HWND_TOPMOST, screenPos.x - WIN_HALF_WIDTH, screenPos.y - WIN_HALF_HEIGHT, 2 * WIN_HALF_WIDTH, 2 * WIN_HALF_HEIGHT, SWP_NOACTIVATE | SWP_SHOWWINDOW); 95 | } 96 | } 97 | 98 | void CMouseOverlayWnd::Fade() 99 | { 100 | if (m_animVar.m_animVar) 101 | { 102 | auto animVar = static_cast(Animator::GetIntegerValue(m_animVar)); 103 | if (animVar) 104 | { 105 | auto transFade = Animator::Instance().CreateSmoothStopTransition(m_animVar, 1.0, 0.0); 106 | auto storyBoard = Animator::Instance().CreateStoryBoard(); 107 | storyBoard->AddTransition(m_animVar.m_animVar, transFade); 108 | Animator::Instance().RunStoryBoard(storyBoard, [this]() { 109 | auto animVar = static_cast(Animator::GetIntegerValue(m_animVar)); 110 | SetLayeredWindowAttributes(*this, 0, animVar / 2, LWA_COLORKEY | LWA_ALPHA); 111 | InvalidateRect(*this, nullptr, false); 112 | if (animVar == 0) 113 | ShowWindow(*this, SW_HIDE); 114 | }); 115 | } 116 | } 117 | } 118 | 119 | LRESULT CALLBACK CMouseOverlayWnd::WinMsgHandler(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 120 | { 121 | switch (uMsg) 122 | { 123 | case WM_CREATE: 124 | m_hwnd = hwnd; 125 | break; 126 | case WM_LBUTTONUP: 127 | // user clicked on the popup window 128 | break; 129 | case WM_ERASEBKGND: 130 | return TRUE; 131 | case WM_PAINT: 132 | { 133 | RECT rect; 134 | if (GetUpdateRect(*this, &rect, false)) 135 | { 136 | ::GetClientRect(*this, &rect); 137 | PAINTSTRUCT ps; 138 | HDC hdc = BeginPaint(hwnd, &ps); 139 | { 140 | CMemDC memDC(hdc); 141 | OnPaint(memDC, &rect); 142 | } 143 | EndPaint(hwnd, &ps); 144 | } 145 | } 146 | break; 147 | case WM_SETFOCUS: 148 | { 149 | if (wParam) 150 | SetFocus(reinterpret_cast(wParam)); // return the focus, we don't want it 151 | } 152 | break; 153 | case WM_DESTROY: 154 | { 155 | if (m_animVar.m_animVar && Animator::IsInstanceActive()) 156 | { 157 | ComPtr storyBoard; 158 | if (SUCCEEDED(m_animVar.m_animVar->GetCurrentStoryboard(storyBoard.GetAddressOf()))) 159 | { 160 | if (storyBoard) 161 | { 162 | storyBoard->Abandon(); 163 | } 164 | } 165 | } 166 | m_animVar.m_animVar = nullptr; 167 | } 168 | break; 169 | default: 170 | return DefWindowProc(hwnd, uMsg, wParam, lParam); 171 | } 172 | 173 | return 0; 174 | }; 175 | 176 | void CMouseOverlayWnd::OnPaint(HDC hDC, LPRECT pRect) 177 | { 178 | auto animVar = static_cast(Animator::GetIntegerValue(m_animVar)); 179 | Gdiplus::Rect rect = {pRect->left, pRect->top, pRect->right - pRect->left, pRect->bottom - pRect->top}; 180 | Gdiplus::Graphics graphics(hDC); 181 | graphics.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias); 182 | graphics.SetInterpolationMode(Gdiplus::InterpolationModeHighQualityBicubic); 183 | 184 | Gdiplus::SolidBrush transparentBrush(Gdiplus::Color::MakeARGB(255, 0, 0, 0)); 185 | graphics.FillRectangle(&transparentBrush, rect); 186 | 187 | auto radius = animVar * (pRect->right - pRect->left) / 255 / 2; 188 | Gdiplus::Rect circle = {pRect->left + (pRect->right - pRect->left) / 2 - radius, 189 | pRect->top + (pRect->bottom - pRect->top) / 2 - radius, 190 | 2 * radius, 191 | 2 * radius}; 192 | 193 | Gdiplus::Color surroundColors[] = {Gdiplus::Color::MakeARGB(static_cast(animVar), GetRValue(m_color), GetGValue(m_color), GetBValue(m_color))}; 194 | INT surroundColorCount = _countof(surroundColors); 195 | 196 | Gdiplus::GraphicsPath gp; 197 | gp.AddEllipse(circle); 198 | Gdiplus::PathGradientBrush pgb(&gp); 199 | pgb.SetCenterPoint(Gdiplus::Point(circle.Width / 2, circle.Height / 2)); 200 | pgb.SetCenterColor(Gdiplus::Color::MakeARGB(static_cast(animVar), 255, 255, 255)); 201 | pgb.SetSurroundColors(surroundColors, &surroundColorCount); 202 | 203 | graphics.FillPath(&pgb, &gp); 204 | } 205 | -------------------------------------------------------------------------------- /src/ColorButton.cpp: -------------------------------------------------------------------------------- 1 | // demoHelper - screen drawing and presentation tool 2 | 3 | // Copyright (C) 2020-2021 - Stefan Kueng 4 | 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | 15 | // You should have received a copy of the GNU General Public License 16 | // along with this program; if not, write to the Free Software Foundation, 17 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | // 19 | #include "stdafx.h" 20 | #include "ColorButton.h" 21 | #include "StringUtils.h" 22 | #include 23 | #include 24 | #include 25 | 26 | namespace 27 | { 28 | COLORREF g_acrCustClr[16]; 29 | 30 | std::wstring GetWindowText(HWND hwnd) 31 | { 32 | wchar_t buf[20]; // We're dealing with color values no longer than three chars. 33 | ::GetWindowText(hwnd, buf, _countof(buf)); 34 | return buf; 35 | } 36 | 37 | BOOL CALLBACK EnumChildWindowProc(HWND hwnd, LPARAM lParam) 38 | { 39 | auto& [cName, wndVec] = *reinterpret_cast>*>(lParam); 40 | 41 | if (cName.empty()) 42 | wndVec.push_back(hwnd); 43 | else 44 | { 45 | wchar_t className[257]; 46 | auto status = ::GetClassName(hwnd, className, _countof(className)); 47 | if (status > 0) 48 | { 49 | if (_wcsicmp(className, cName.c_str()) == 0) 50 | wndVec.push_back(hwnd); 51 | } 52 | } 53 | return TRUE; 54 | } 55 | 56 | // Empty classname means match child windows of ANY classname. 57 | std::vector GetChildWindows(HWND hwnd, const std::wstring& classname) 58 | { 59 | std::pair> state; 60 | state.first = classname; 61 | EnumChildWindows(hwnd, EnumChildWindowProc, reinterpret_cast(&state)); 62 | return state.second; 63 | } 64 | } // namespace 65 | 66 | CColorButton::CColorButton() 67 | { 68 | } 69 | 70 | CColorButton::~CColorButton() 71 | { 72 | } 73 | 74 | bool CColorButton::ConvertToColorButton(HWND hwndCtl) 75 | { 76 | // Subclass the existing control. 77 | m_pfnOrigCtlProc = reinterpret_cast(GetWindowLongPtr(hwndCtl, GWLP_WNDPROC)); 78 | SetWindowLongPtr(hwndCtl, GWLP_WNDPROC, reinterpret_cast(_ColorButtonProc)); 79 | SetWindowLongPtr(hwndCtl, GWLP_USERDATA, reinterpret_cast(this)); 80 | m_hwnd = hwndCtl; 81 | return true; 82 | } 83 | 84 | BOOL CColorButton::ConvertToColorButton(HWND hwndParent, UINT uiCtlId) 85 | { 86 | m_ctlId = uiCtlId; 87 | return ConvertToColorButton(GetDlgItem(hwndParent, uiCtlId)); 88 | } 89 | 90 | LRESULT CALLBACK CColorButton::_ColorButtonProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) 91 | { 92 | CColorButton* pColorButton = GetObjectFromWindow(hwnd); 93 | switch (message) 94 | { 95 | case WM_PAINT: 96 | { 97 | PAINTSTRUCT ps; 98 | HDC hdc = BeginPaint(hwnd, &ps); 99 | RECT rc; 100 | GetClientRect(hwnd, &rc); 101 | SetBkColor(hdc, pColorButton->m_color); 102 | ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED | ETO_OPAQUE, &rc, L"", 0, nullptr); 103 | EndPaint(hwnd, &ps); 104 | return 0L; 105 | } 106 | case WM_ERASEBKGND: 107 | return TRUE; 108 | case WM_KEYUP: 109 | { 110 | if (wParam != VK_SPACE) 111 | break; 112 | } 113 | // Fall through 114 | case WM_LBUTTONUP: 115 | { 116 | CHOOSECOLOR cc = {0}; 117 | cc.lStructSize = sizeof(CHOOSECOLOR); 118 | cc.hwndOwner = hwnd; 119 | cc.rgbResult = pColorButton->m_color; 120 | cc.lpCustColors = g_acrCustClr; 121 | cc.lCustData = reinterpret_cast(pColorButton); 122 | cc.lpfnHook = CCHookProc; 123 | cc.Flags = CC_ANYCOLOR | CC_RGBINIT | CC_ENABLEHOOK | CC_FULLOPEN; 124 | 125 | if (ChooseColor(&cc) != FALSE) 126 | { 127 | pColorButton->m_dialogResult = ColorButtonDialogResult::Ok; 128 | } 129 | else if (pColorButton->m_hasLastColor) 130 | { 131 | pColorButton->SetColor(cc.rgbResult); 132 | pColorButton->m_dialogResult = ColorButtonDialogResult::Cancel; 133 | SendMessage(GetParent(hwnd), WM_COMMAND, pColorButton->m_ctlId, reinterpret_cast(hwnd)); 134 | } 135 | return 0; 136 | } 137 | case WM_DESTROY: 138 | SetWindowLongPtr(hwnd, GWLP_WNDPROC, reinterpret_cast(pColorButton->m_pfnOrigCtlProc)); 139 | break; 140 | } 141 | 142 | return CallWindowProc(pColorButton->m_pfnOrigCtlProc, hwnd, message, wParam, lParam); 143 | } 144 | 145 | void CColorButton::SetColor(COLORREF clr) 146 | { 147 | m_color = clr; 148 | InvalidateRect(m_hwnd, nullptr, FALSE); 149 | } 150 | 151 | // This function is attempts to hijack and hack the standard basic Windows 152 | // Color Control into allow repeated colors to be selected without having 153 | // to press OK each time. Each selection initiates a WM_COMMAND. 154 | // If Cancel is chosen, a WM_COMMAND is sent that undoes the previous color set. 155 | // The logic in this function is based on an idea from this article: 156 | // http://stackoverflow.com/questions/16583139/get-color-property-while-colordialog-still-open-before-confirming-the-dialog 157 | // As the article states, it is questionable to do what we do in this function 158 | // as the code i subject to break if the Windows Color Control changes 159 | // in the future. 160 | 161 | UINT_PTR CALLBACK CColorButton::CCHookProc( 162 | _In_ HWND hdlg, 163 | _In_ UINT uiMsg, 164 | _In_ WPARAM wParam, 165 | _In_ LPARAM lParam) 166 | { 167 | UNREFERENCED_PARAMETER(wParam); 168 | switch (uiMsg) 169 | { 170 | case WM_INITDIALOG: 171 | { 172 | const CHOOSECOLOR& cc = *reinterpret_cast(lParam); 173 | // Crude attempt to assert this data slot isn't used by anybody but us. 174 | assert(GetWindowLongPtr(hdlg, GWLP_USERDATA) == static_cast(0)); 175 | SetWindowLongPtr(hdlg, GWLP_USERDATA, cc.lCustData); 176 | CColorButton* pColorBtn = reinterpret_cast(cc.lCustData); 177 | auto mainWindow = GetAncestor(hdlg, GA_ROOT); 178 | pColorBtn->m_colorEdits = GetChildWindows(mainWindow, L"Edit"); 179 | assert(pColorBtn->m_colorEdits.size() == 6); 180 | } 181 | break; 182 | case WM_CTLCOLOREDIT: 183 | { 184 | // InitDialog should have set this. 185 | CColorButton* pColorButton = GetObjectFromWindow(hdlg); 186 | assert(pColorButton != nullptr); 187 | assert(pColorButton->m_colorEdits.size() == 6); 188 | 189 | // See top of function for what's going on here. 190 | std::vector colorText; 191 | for (auto hwnd : pColorButton->m_colorEdits) 192 | colorText.push_back(GetWindowText(hwnd)); 193 | 194 | COLORREF color = 0; 195 | try 196 | { 197 | BYTE r = static_cast(std::stoi(colorText[3])); 198 | BYTE g = static_cast(std::stoi(colorText[4])); 199 | BYTE b = static_cast(std::stoi(colorText[5])); 200 | color = RGB(r, g, b); 201 | } 202 | catch (const std::exception& /*ex*/) 203 | { 204 | return 0; 205 | } 206 | if (!pColorButton->m_hasLastColor || color != pColorButton->m_lastColor) 207 | { 208 | pColorButton->m_lastColor = color; 209 | pColorButton->m_hasLastColor = true; 210 | #ifdef _DEBUG 211 | std::wstring msg = CStringUtils::Format(L"RGB(%d,%d,%d)\n", 212 | static_cast(GetRValue(color)), static_cast(GetGValue(color)), static_cast(GetBValue(color))); 213 | OutputDebugString(msg.c_str()); 214 | #endif 215 | pColorButton->SetColor(color); 216 | SendMessage(GetParent(hdlg), WM_COMMAND, 217 | pColorButton->m_ctlId, reinterpret_cast(GetParent(hdlg))); 218 | } 219 | break; 220 | } 221 | } 222 | return 0; 223 | } 224 | -------------------------------------------------------------------------------- /src/KeyboardOverlayD2D.cpp: -------------------------------------------------------------------------------- 1 | // demoHelper - screen drawing and presentation tool 2 | 3 | // Copyright (C) 2020-2021 - Stefan Kueng 4 | 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | 15 | // You should have received a copy of the GNU General Public License 16 | // along with this program; if not, write to the Free Software Foundation, 17 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | // 19 | #include "stdafx.h" 20 | #include "KeyboardOverlayD2D.h" 21 | #include "DPIAware.h" 22 | 23 | #pragma comment(lib, "Winmm.lib") 24 | 25 | constexpr int FADE_TIMER = 101; 26 | 27 | CKeyboardOverlayWndD2D::~CKeyboardOverlayWndD2D() 28 | { 29 | CKeyboardOverlayWndD2D::DiscardDeviceResources(); 30 | if (m_animVar.m_animVar && Animator::IsInstanceActive()) 31 | { 32 | ComPtr storyBoard; 33 | if (SUCCEEDED(m_animVar.m_animVar->GetCurrentStoryboard(storyBoard.GetAddressOf()))) 34 | { 35 | if (storyBoard) 36 | { 37 | storyBoard->Abandon(); 38 | } 39 | } 40 | } 41 | } 42 | 43 | bool CKeyboardOverlayWndD2D::RegisterAndCreateWindow() 44 | { 45 | WNDCLASSEX wcx; 46 | 47 | // Fill in the window class structure with default parameters 48 | wcx.cbSize = sizeof(WNDCLASSEX); 49 | wcx.style = CS_HREDRAW | CS_VREDRAW | CS_CLASSDC; 50 | wcx.lpfnWndProc = CWindow::stWinMsgHandler; 51 | wcx.cbClsExtra = 0; 52 | wcx.cbWndExtra = 0; 53 | wcx.hInstance = hResource; 54 | wcx.hCursor = LoadCursor(nullptr, IDC_HAND); 55 | wcx.lpszClassName = L"CKeyboardOverlayWndD2D_{3c0b3390-375e-4553-a1ce-04dc03764e4b}"; 56 | wcx.hIcon = nullptr; 57 | wcx.hbrBackground = reinterpret_cast((COLOR_WINDOW + 1)); 58 | wcx.lpszMenuName = nullptr; 59 | wcx.hIconSm = nullptr; 60 | if (RegisterWindow(&wcx)) 61 | { 62 | auto ret = CreateEx(WS_EX_NOREDIRECTIONBITMAP | WS_EX_TRANSPARENT | WS_EX_LAYERED | WS_EX_NOACTIVATE | WS_EX_TOPMOST, WS_POPUP | WS_DISABLED, nullptr); 63 | return ret; 64 | } 65 | return false; 66 | } 67 | 68 | SIZE CKeyboardOverlayWndD2D::GetRequiredHeight(const std::wstring& text) 69 | { 70 | RECT rc; 71 | GetClientRect(*this, &rc); 72 | auto textOffset = static_cast(CDPIAware::Instance().Scale(*this, 3)); 73 | ComPtr textLayout; 74 | if (SUCCEEDED(m_writeFactory->CreateTextLayout(text.c_str(), 75 | static_cast(text.length()), m_textFormat.Get(), 76 | static_cast(rc.right) - textOffset - textOffset, static_cast(rc.bottom), 77 | textLayout.GetAddressOf()))) 78 | { 79 | DWRITE_TEXT_METRICS textMetrics = {}; 80 | if (SUCCEEDED(textLayout->GetMetrics(&textMetrics))) 81 | return SIZE{static_cast(textMetrics.width), static_cast(textMetrics.height)}; 82 | } 83 | return SIZE{}; 84 | } 85 | 86 | void CKeyboardOverlayWndD2D::Show(const std::wstring& text) 87 | { 88 | m_text = text; 89 | InvalidateRect(*this, nullptr, false); 90 | m_animVar = Animator::Instance().CreateAnimationVariable(255.0, 255.0); 91 | auto transKeep = Animator::Instance().CreateConstantTransition(2.0); 92 | auto transFade = Animator::Instance().CreateSmoothStopTransition(m_animVar, 0.8, 0.0); 93 | auto storyBoard = Animator::Instance().CreateStoryBoard(); 94 | storyBoard->AddTransition(m_animVar.m_animVar, transKeep); 95 | storyBoard->AddTransition(m_animVar.m_animVar, transFade); 96 | Animator::Instance().RunStoryBoard(storyBoard, [this]() { 97 | auto animVar = static_cast(Animator::GetIntegerValue(m_animVar)); 98 | InvalidateRect(*this, nullptr, false); 99 | if (animVar == 0) 100 | ShowWindow(*this, SW_HIDE); 101 | }); 102 | m_bShown = true; 103 | } 104 | 105 | bool CKeyboardOverlayWndD2D::IsAnimationFinished() 106 | { 107 | auto animVar = static_cast(Animator::GetIntegerValue(m_animVar)); 108 | return (animVar == 0); 109 | } 110 | 111 | bool CKeyboardOverlayWndD2D::HasWindowBeenShown() const 112 | { 113 | return m_bShown; 114 | } 115 | 116 | LRESULT CKeyboardOverlayWndD2D::WinMsgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 117 | { 118 | switch (uMsg) 119 | { 120 | case WM_CREATE: 121 | m_hwnd = hwnd; 122 | break; 123 | case WM_LBUTTONUP: 124 | // user clicked on the popup window 125 | break; 126 | case WM_SETFOCUS: 127 | { 128 | if (wParam) 129 | SetFocus(reinterpret_cast(wParam)); // return the focus, we don't want it 130 | } 131 | break; 132 | case WM_NCHITTEST: 133 | return HTTRANSPARENT; 134 | default: 135 | return DefWindowProc(hwnd, uMsg, wParam, lParam); 136 | } 137 | 138 | return 0; 139 | } 140 | HRESULT CKeyboardOverlayWndD2D::OnRender(ID2D1DeviceContext* dc) 141 | { 142 | HRESULT hr = S_OK; 143 | auto [width, height] = dc->GetSize(); 144 | auto roundRadius = static_cast(CDPIAware::Instance().Scale(*this, 15)); 145 | auto textOffset = static_cast(CDPIAware::Instance().Scale(*this, 3)); 146 | auto roundedRect = D2D1::RoundedRect(D2D1::RectF(0, 0, width, height), roundRadius, roundRadius); 147 | 148 | auto animVar = static_cast(Animator::GetIntegerValue(m_animVar)); 149 | 150 | ComPtr bmp; 151 | D2D1_SIZE_U sizeU = {static_cast(width), static_cast(height)}; 152 | D2D1_BITMAP_PROPERTIES1 properties = {}; 153 | properties.pixelFormat.alphaMode = D2D1_ALPHA_MODE_PREMULTIPLIED; 154 | properties.pixelFormat.format = DXGI_FORMAT_B8G8R8A8_UNORM; 155 | properties.bitmapOptions = D2D1_BITMAP_OPTIONS_TARGET; 156 | hr = dc->CreateBitmap(sizeU, nullptr, 0, properties, bmp.GetAddressOf()); 157 | 158 | m_dc->SetTarget(bmp.Get()); 159 | 160 | auto textRect = D2D1::RectF(textOffset, textOffset, width - textOffset - textOffset, height - textOffset - textOffset); 161 | ComPtr shadowBrush; 162 | hr = m_dc->CreateSolidColorBrush(D2D1::ColorF(RGB(10, 10, 10), animVar / 255.0f), shadowBrush.GetAddressOf()); 163 | if (m_textFormat) 164 | dc->DrawText(m_text.c_str(), static_cast(m_text.size()), m_textFormat.Get(), textRect, shadowBrush.Get()); 165 | 166 | m_gaussianBlurEffect->SetInput(0, bmp.Get()); 167 | m_gaussianBlurEffect->SetValue(D2D1_GAUSSIANBLUR_PROP_STANDARD_DEVIATION, 5.0f); 168 | 169 | m_dc->SetTarget(m_d2dBitmap.Get()); 170 | 171 | ComPtr backgroundBrush; 172 | hr = m_dc->CreateSolidColorBrush(D2D1::ColorF(RGB(128, 128, 128), animVar / 255.0f / 1.4f), backgroundBrush.GetAddressOf()); 173 | dc->FillRoundedRectangle(roundedRect, backgroundBrush.Get()); 174 | //ComPtr backgroundBorderBrush; 175 | //hr = m_dc->CreateSolidColorBrush(D2D1::ColorF(RGB(120, 10, 10), animVar / 255.0f), backgroundBorderBrush.GetAddressOf()); 176 | //dc->DrawRoundedRectangle(roundedRect, backgroundBorderBrush.Get(), 5.0f); 177 | 178 | D2D1_POINT_2F offset = {7, 7}; 179 | dc->DrawImage(m_gaussianBlurEffect.Get(), &offset); 180 | 181 | ComPtr textBrush; 182 | hr = m_dc->CreateSolidColorBrush(D2D1::ColorF(RGB(120, 120, 255), animVar / 255.0f / 1.1f), textBrush.GetAddressOf()); 183 | if (m_textFormat) 184 | dc->DrawText(m_text.c_str(), static_cast(m_text.size()), m_textFormat.Get(), textRect, textBrush.Get()); 185 | return hr; 186 | } 187 | 188 | HRESULT CKeyboardOverlayWndD2D::CreateDeviceResources() 189 | { 190 | HRESULT hr = S_OK; 191 | if (SUCCEEDED(hr)) 192 | hr = m_writeFactory->CreateTextFormat(L"Arial", nullptr, 193 | DWRITE_FONT_WEIGHT_DEMI_BOLD, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_CONDENSED, 194 | static_cast(CDPIAware::Instance().Scale(*this, 36)), 195 | L"", m_textFormat.GetAddressOf()); 196 | if (SUCCEEDED(hr)) 197 | hr = m_textFormat->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER); 198 | 199 | if (SUCCEEDED(hr)) 200 | hr = m_textFormat->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER); 201 | 202 | if (SUCCEEDED(hr)) 203 | hr = m_dc->CreateEffect(CLSID_D2D1GaussianBlur, &m_gaussianBlurEffect); 204 | 205 | return hr; 206 | } 207 | HRESULT CKeyboardOverlayWndD2D::DiscardDeviceResources() 208 | { 209 | m_textFormat = nullptr; 210 | return S_OK; 211 | }; 212 | -------------------------------------------------------------------------------- /src/RectSelectionWnd.cpp: -------------------------------------------------------------------------------- 1 | // demoHelper - screen drawing and presentation tool 2 | 3 | // Copyright (C) 2020-2021 - Stefan Kueng 4 | 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | 15 | // You should have received a copy of the GNU General Public License 16 | // along with this program; if not, write to the Free Software Foundation, 17 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | // 19 | #include "stdafx.h" 20 | #include "RectSelectionWnd.h" 21 | #include "DPIAware.h" 22 | 23 | #pragma comment(lib, "Winmm.lib") 24 | 25 | constexpr int FADE_TIMER = 101; 26 | 27 | CRectSelectionWnd::~CRectSelectionWnd() 28 | { 29 | CRectSelectionWnd::DiscardDeviceResources(); 30 | } 31 | 32 | bool CRectSelectionWnd::RegisterAndCreateWindow() 33 | { 34 | WNDCLASSEX wcx; 35 | 36 | // Fill in the window class structure with default parameters 37 | wcx.cbSize = sizeof(WNDCLASSEX); 38 | wcx.style = CS_HREDRAW | CS_VREDRAW | CS_CLASSDC; 39 | wcx.lpfnWndProc = CWindow::stWinMsgHandler; 40 | wcx.cbClsExtra = 0; 41 | wcx.cbWndExtra = 0; 42 | wcx.hInstance = hResource; 43 | wcx.hCursor = LoadCursor(nullptr, IDC_HAND); 44 | wcx.lpszClassName = L"CRectSelectionWnd_{3FD2D1AD-D9BD-4F3B-99F7-1103C8AAE535}"; 45 | wcx.hIcon = nullptr; 46 | wcx.hbrBackground = reinterpret_cast((COLOR_WINDOW + 1)); 47 | wcx.lpszMenuName = nullptr; 48 | wcx.hIconSm = nullptr; 49 | if (RegisterWindow(&wcx)) 50 | { 51 | auto ret = CreateEx(WS_EX_NOREDIRECTIONBITMAP | WS_EX_TOPMOST, WS_POPUP, nullptr); 52 | return ret; 53 | } 54 | return false; 55 | } 56 | 57 | RECT CRectSelectionWnd::Show(HWND hWndParent, RECT wndRect, float aspectRatio) 58 | { 59 | m_aspectRatio = aspectRatio; 60 | SetWindowPos(*this, HWND_TOP, wndRect.left, wndRect.top, wndRect.right - wndRect.left, wndRect.bottom - wndRect.top, SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_ASYNCWINDOWPOS); 61 | // deactivate the parent window 62 | if (hWndParent) 63 | ::EnableWindow(hWndParent, FALSE); 64 | 65 | m_startPt = {}; 66 | m_endPt = {}; 67 | // Main message loop: 68 | m_bRunning = true; 69 | MSG msg = {nullptr}; 70 | BOOL bRet = TRUE; 71 | while (m_bRunning && ((bRet = GetMessage(&msg, nullptr, 0, 0)) != 0)) 72 | { 73 | if (bRet == -1) 74 | { 75 | // handle the error and possibly exit 76 | break; 77 | } 78 | else 79 | { 80 | TranslateMessage(&msg); 81 | DispatchMessage(&msg); 82 | } 83 | } 84 | // re-enable the parent window 85 | if (hWndParent) 86 | ::EnableWindow(hWndParent, TRUE); 87 | ShowWindow(*this, SW_HIDE); 88 | if (msg.message == WM_QUIT) 89 | PostQuitMessage(static_cast(msg.wParam)); 90 | return m_selectedRect; 91 | } 92 | 93 | LRESULT CRectSelectionWnd::WinMsgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 94 | { 95 | switch (uMsg) 96 | { 97 | case WM_CREATE: 98 | m_hwnd = hwnd; 99 | break; 100 | case WM_LBUTTONDOWN: 101 | m_startPt.x = GET_X_LPARAM(lParam); 102 | m_startPt.y = GET_Y_LPARAM(lParam); 103 | m_selectionInProgress = true; 104 | break; 105 | case WM_LBUTTONUP: 106 | if (m_selectionInProgress) 107 | { 108 | m_endPt.x = GET_X_LPARAM(lParam); 109 | m_endPt.y = GET_Y_LPARAM(lParam); 110 | AdjustEndPoint(); 111 | m_selectedRect.left = std::min(m_startPt.x, m_endPt.x); 112 | m_selectedRect.right = std::max(m_startPt.x, m_endPt.x); 113 | m_selectedRect.top = std::min(m_startPt.y, m_endPt.y); 114 | m_selectedRect.bottom = std::max(m_startPt.y, m_endPt.y); 115 | m_bRunning = false; 116 | m_selectionInProgress = false; 117 | } 118 | break; 119 | case WM_MOUSEMOVE: 120 | if (m_selectionInProgress) 121 | { 122 | m_endPt.x = GET_X_LPARAM(lParam); 123 | m_endPt.y = GET_Y_LPARAM(lParam); 124 | AdjustEndPoint(); 125 | InvalidateRect(*this, nullptr, false); 126 | } 127 | break; 128 | case WM_KEYDOWN: 129 | if (wParam == VK_ESCAPE) 130 | { 131 | if (m_startPt.x == m_endPt.x && m_startPt.y == m_endPt.y) 132 | { 133 | m_selectedRect = {}; 134 | m_bRunning = false; 135 | m_selectionInProgress = false; 136 | } 137 | else 138 | { 139 | m_startPt = {}; 140 | m_endPt = {}; 141 | m_selectionInProgress = false; 142 | } 143 | InvalidateRect(*this, nullptr, false); 144 | } 145 | break; 146 | 147 | default: 148 | return DefWindowProc(hwnd, uMsg, wParam, lParam); 149 | } 150 | 151 | return 0; 152 | } 153 | HRESULT CRectSelectionWnd::OnRender(ID2D1DeviceContext* dc) 154 | { 155 | HRESULT hr = S_OK; 156 | auto [width, height] = dc->GetSize(); 157 | auto wndRect = D2D1::RectF(0, 0, width, height); 158 | 159 | ComPtr backgroundBrush; 160 | hr = m_dc->CreateSolidColorBrush(D2D1::ColorF(RGB(128, 128, 128), 0.5f), backgroundBrush.GetAddressOf()); 161 | ComPtr textBrush; 162 | hr = m_dc->CreateSolidColorBrush(D2D1::ColorF(RGB(120, 120, 255), 0.9f), textBrush.GetAddressOf()); 163 | 164 | std::wstring text = L"select zoom area"; 165 | if (m_textFormat) 166 | dc->DrawText(text.c_str(), static_cast(text.size()), m_textFormat.Get(), wndRect, textBrush.Get()); 167 | if (m_selectionInProgress) 168 | { 169 | auto selRect = D2D1::RectF(static_cast(std::min(m_startPt.x, m_endPt.x)), 170 | static_cast(std::min(m_startPt.y, m_endPt.y)), 171 | static_cast(std::max(m_startPt.x, m_endPt.x)), 172 | static_cast(std::max(m_startPt.y, m_endPt.y))); 173 | // rect above the selRect 174 | auto topRect = D2D1::RectF(0, 0, wndRect.right, selRect.top); 175 | // rect below the selRect 176 | auto bottomRect = D2D1::RectF(0, selRect.bottom, wndRect.right, wndRect.bottom); 177 | // rect left of the selRect 178 | auto leftRect = D2D1::RectF(0, selRect.top, selRect.left, selRect.bottom); 179 | // rect right of the selRect 180 | auto rightRect = D2D1::RectF(selRect.right, selRect.top, wndRect.right, selRect.bottom); 181 | 182 | dc->FillRectangle(topRect, backgroundBrush.Get()); 183 | dc->FillRectangle(bottomRect, backgroundBrush.Get()); 184 | dc->FillRectangle(leftRect, backgroundBrush.Get()); 185 | dc->FillRectangle(rightRect, backgroundBrush.Get()); 186 | 187 | ComPtr selBrush; 188 | hr = m_dc->CreateSolidColorBrush(D2D1::ColorF(RGB(128, 128, 128), 0.2f), selBrush.GetAddressOf()); 189 | ComPtr lineBrush; 190 | hr = m_dc->CreateSolidColorBrush(D2D1::ColorF(RGB(255, 0, 0), 0.7f), lineBrush.GetAddressOf()); 191 | dc->FillRectangle(selRect, selBrush.Get()); 192 | dc->DrawRectangle(selRect, lineBrush.Get(), 2.0f); 193 | } 194 | else 195 | { 196 | dc->FillRectangle(wndRect, backgroundBrush.Get()); 197 | } 198 | return hr; 199 | } 200 | 201 | HRESULT CRectSelectionWnd::CreateDeviceResources() 202 | { 203 | HRESULT hr = S_OK; 204 | if (SUCCEEDED(hr)) 205 | hr = m_writeFactory->CreateTextFormat(L"Arial", nullptr, 206 | DWRITE_FONT_WEIGHT_DEMI_BOLD, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_CONDENSED, 207 | static_cast(CDPIAware::Instance().Scale(*this, 36)), 208 | L"", m_textFormat.GetAddressOf()); 209 | if (SUCCEEDED(hr)) 210 | hr = m_textFormat->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER); 211 | 212 | if (SUCCEEDED(hr)) 213 | hr = m_textFormat->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_NEAR); 214 | 215 | if (SUCCEEDED(hr)) 216 | hr = m_dc->CreateEffect(CLSID_D2D1GaussianBlur, &m_gaussianBlurEffect); 217 | 218 | return hr; 219 | } 220 | HRESULT CRectSelectionWnd::DiscardDeviceResources() 221 | { 222 | m_textFormat = nullptr; 223 | return S_OK; 224 | } 225 | void CRectSelectionWnd::AdjustEndPoint() 226 | { 227 | // adjust the end point according to the aspect ratio 228 | // keep the smaller rect, not the bigger one 229 | auto width = std::abs(m_startPt.x - m_endPt.x); 230 | auto height = std::abs(m_startPt.y - m_endPt.y); 231 | auto xFactor = m_startPt.x > m_endPt.x ? -1.0f : 1.0f; 232 | auto yFactor = m_startPt.y > m_endPt.y ? -1.0f : 1.0f; 233 | if (width / m_aspectRatio > height) 234 | { 235 | m_endPt.x = m_startPt.x + static_cast(xFactor * (height * m_aspectRatio)); 236 | } 237 | else 238 | { 239 | m_endPt.y = m_startPt.y + static_cast(yFactor * (width / m_aspectRatio)); 240 | } 241 | }; 242 | -------------------------------------------------------------------------------- /src/DemoHelper.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #include "resource.h" 4 | 5 | #define APSTUDIO_READONLY_SYMBOLS 6 | ///////////////////////////////////////////////////////////////////////////// 7 | // 8 | // Generated from the TEXTINCLUDE 2 resource. 9 | // 10 | #include "winresrc.h" 11 | #ifndef APSTUDIO_INVOKED 12 | #include "DemoHelper.rc2" 13 | #endif 14 | ///////////////////////////////////////////////////////////////////////////// 15 | #undef APSTUDIO_READONLY_SYMBOLS 16 | 17 | ///////////////////////////////////////////////////////////////////////////// 18 | // English (United States) resources 19 | 20 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 21 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 22 | #pragma code_page(1252) 23 | 24 | ///////////////////////////////////////////////////////////////////////////// 25 | // 26 | // Icon 27 | // 28 | 29 | // Icon with lowest ID value placed first to ensure application icon 30 | // remains consistent on all systems. 31 | IDI_DEMOHELPER ICON "DemoHelper.ico" 32 | 33 | 34 | ///////////////////////////////////////////////////////////////////////////// 35 | // 36 | // Menu 37 | // 38 | 39 | IDC_DEMOHELPER MENU 40 | BEGIN 41 | POPUP "TrayContext" 42 | BEGIN 43 | MENUITEM "&Zoom", ID_TRAYCONTEXT_ZOOM 44 | MENUITEM "&Draw", ID_TRAYCONTEXT_DRAW 45 | MENUITEM SEPARATOR 46 | MENUITEM "&Options", ID_TRAYCONTEXT_OPTIONS 47 | MENUITEM "&Help", IDHELP 48 | MENUITEM SEPARATOR 49 | MENUITEM "E&xit", IDM_EXIT 50 | END 51 | END 52 | 53 | 54 | ///////////////////////////////////////////////////////////////////////////// 55 | // 56 | // Accelerator 57 | // 58 | 59 | IDR_DEMOHELPER ACCELERATORS 60 | BEGIN 61 | VK_RETURN, ID_CMD_ACCEPT, VIRTKEY, NOINVERT 62 | "e", ID_CMD_CLEARLINES, ASCII, NOINVERT 63 | "c", ID_CMD_CLEARSCREEN, ASCII, NOINVERT 64 | "0", ID_CMD_COLOR0, ASCII, NOINVERT 65 | "1", ID_CMD_COLOR1, ASCII, NOINVERT 66 | "2", ID_CMD_COLOR2, ASCII, NOINVERT 67 | "3", ID_CMD_COLOR3, ASCII, NOINVERT 68 | "4", ID_CMD_COLOR4, ASCII, NOINVERT 69 | "5", ID_CMD_COLOR5, ASCII, NOINVERT 70 | "6", ID_CMD_COLOR6, ASCII, NOINVERT 71 | "7", ID_CMD_COLOR7, ASCII, NOINVERT 72 | "8", ID_CMD_COLOR8, ASCII, NOINVERT 73 | "9", ID_CMD_COLOR9, ASCII, NOINVERT 74 | VK_DOWN, ID_CMD_DECREASE, VIRTKEY, NOINVERT 75 | VK_UP, ID_CMD_INCREASE, VIRTKEY, NOINVERT 76 | "z", ID_CMD_INLINEZOOM, ASCII, NOINVERT 77 | VK_RIGHT, ID_CMD_NEXTCOLOR, VIRTKEY, NOINVERT 78 | VK_LEFT, ID_CMD_PREVCOLOR, VIRTKEY, NOINVERT 79 | "m", ID_CMD_QUICKTOMARKER, ASCII, NOINVERT 80 | VK_ESCAPE, ID_CMD_QUITMODE, VIRTKEY, NOINVERT 81 | "t", ID_CMD_TOGGLEROP, ASCII, NOINVERT 82 | VK_BACK, ID_CMD_UNDOLINE, VIRTKEY, NOINVERT 83 | VK_F1, IDHELP, VIRTKEY, NOINVERT 84 | "/", IDM_ABOUT, ASCII, ALT, NOINVERT 85 | "?", IDM_ABOUT, ASCII, ALT, NOINVERT 86 | VK_DELETE, ID_CMD_REMOVEFIRST, VIRTKEY, NOINVERT 87 | END 88 | 89 | 90 | ///////////////////////////////////////////////////////////////////////////// 91 | // 92 | // Dialog 93 | // 94 | 95 | IDD_OPTIONS DIALOGEX 0, 0, 297, 299 96 | STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU 97 | CAPTION "DemoHelper Options" 98 | FONT 9, "Segoe UI", 400, 0, 0x1 99 | BEGIN 100 | ICON IDI_DEMOHELPER,IDC_MYICON2,7,7,20,20 101 | CONTROL "DemoHelper: visit our website",IDC_SYSLINK1, 102 | "SysLink",WS_TABSTOP,40,13,244,12 103 | GROUPBOX "Misc",IDC_STATIC,7,25,283,40 104 | LTEXT "Whether to capture only the monitor where the cursor is at, or the whole virtual screen covering all monitors.",IDC_STATIC,14,33,270,19 105 | CONTROL "Current Monitor",IDC_CURRENTMONITOR,"Button",BS_AUTORADIOBUTTON,14,51,70,10 106 | CONTROL "All Monitors",IDC_ALLMONITORS,"Button",BS_AUTORADIOBUTTON,94,51,80,10 107 | GROUPBOX "Zoom",IDC_STATIC,7,66,283,86 108 | LTEXT "After enabling the zoom mode, you can zoom in and out using the mouse wheel or the up/down arrow keys. Exit zoom mode with Escape.\nIn Live Zoom Mode, Use Win+Shift+mousewheel to zoom in/out, and hit the hotkey again to exit.",IDC_STATIC,14,76,270,36 109 | LTEXT "Zoom Mode:",IDC_STATIC,14,118,54,8 110 | CONTROL "",IDC_HOTKEY_ZOOMMODE,"msctls_hotkey32",WS_BORDER | WS_TABSTOP,94,115,190,14 111 | LTEXT "Live Zoom Mode:",IDC_STATIC,14,136,73,8 112 | CONTROL "",IDC_HOTKEY_LENSMODE,"msctls_hotkey32",WS_BORDER | WS_TABSTOP,94,133,190,14 113 | GROUPBOX "Draw",IDC_STATIC,7,153,283,72 114 | LTEXT "After enabling the drawing mode, increase or decrease the pen size with the up/down arrow keys. Cycle through the available colors with the right/left arrow keys. Erase the last line with the Backspace key.",IDC_STATIC,14,162,270,26 115 | LTEXT "Draw Mode:",IDC_STATIC,14,193,54,8 116 | CONTROL "",IDC_HOTKEY_DRAWMODE,"msctls_hotkey32",WS_BORDER | WS_TABSTOP,94,190,190,14 117 | LTEXT "Remove lines after",IDC_STATIC,14,210,61,8 118 | EDITTEXT IDC_FADESECONDS,94,207,40,14,ES_AUTOHSCROLL | ES_NUMBER 119 | LTEXT "seconds",IDC_STATIC,139,210,27,8 120 | GROUPBOX "Overlays",IDC_STATIC,7,226,283,49 121 | CONTROL "Show keystrokes",IDC_KEYHOOK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,237,70,10 122 | CONTROL "Show mouseclicks",IDC_MOUSEHOOK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,94,237,75,10 123 | CONTROL "Visualize mouseclicks",IDC_MOUSEVISUALS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,179,237,86,10 124 | PUSHBUTTON "Configure colors",IDC_CONF_COLORS,14,278,80,14 125 | DEFPUSHBUTTON "OK",IDOK,182,278,50,14 126 | PUSHBUTTON "Cancel",IDCANCEL,240,278,50,14 127 | CONTROL "Top left",IDC_POS_TOPLEFT,"Button",BS_AUTORADIOBUTTON,14,249,41,10 128 | CONTROL "Top right",IDC_POS_TOPRIGHT,"Button",BS_AUTORADIOBUTTON,94,249,46,10 129 | CONTROL "Bottom left",IDC_POS_BOTTOMLEFT,"Button",BS_AUTORADIOBUTTON,14,259,53,10 130 | CONTROL "Bottom right",IDC_POS_BOTTOMRIGHT,"Button",BS_AUTORADIOBUTTON,94,259,58,10 131 | END 132 | 133 | IDD_COLORS DIALOGEX 0, 0, 142, 98 134 | STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU 135 | CAPTION "Colors" 136 | FONT 8, "MS Shell Dlg", 400, 0, 0x1 137 | BEGIN 138 | LTEXT "Mouse visual left click:",IDC_STATIC,7,9,84,8 139 | PUSHBUTTON "",IDC_MOUSEVISUAL_LEFT,108,7,27,14 140 | LTEXT "Mouse visual middle click:",IDC_STATIC,7,27,84,8 141 | PUSHBUTTON "",IDC_MOUSEVISUAL_MIDDLE,108,26,27,14 142 | LTEXT "Mouse visual right click:",IDC_STATIC,7,47,84,8 143 | PUSHBUTTON "",IDC_MOUSEVISUAL_RIGHT,108,45,27,14 144 | DEFPUSHBUTTON "OK",IDOK,31,77,50,14 145 | PUSHBUTTON "Cancel",IDCANCEL,85,77,50,14 146 | END 147 | 148 | 149 | ///////////////////////////////////////////////////////////////////////////// 150 | // 151 | // DESIGNINFO 152 | // 153 | 154 | #ifdef APSTUDIO_INVOKED 155 | GUIDELINES DESIGNINFO 156 | BEGIN 157 | IDD_OPTIONS, DIALOG 158 | BEGIN 159 | LEFTMARGIN, 7 160 | RIGHTMARGIN, 290 161 | VERTGUIDE, 14 162 | VERTGUIDE, 40 163 | VERTGUIDE, 94 164 | VERTGUIDE, 284 165 | TOPMARGIN, 7 166 | BOTTOMMARGIN, 292 167 | END 168 | 169 | IDD_COLORS, DIALOG 170 | BEGIN 171 | LEFTMARGIN, 7 172 | RIGHTMARGIN, 135 173 | TOPMARGIN, 7 174 | BOTTOMMARGIN, 91 175 | END 176 | END 177 | #endif // APSTUDIO_INVOKED 178 | 179 | 180 | #ifdef APSTUDIO_INVOKED 181 | ///////////////////////////////////////////////////////////////////////////// 182 | // 183 | // TEXTINCLUDE 184 | // 185 | 186 | 1 TEXTINCLUDE 187 | BEGIN 188 | "resource.h\0" 189 | END 190 | 191 | 2 TEXTINCLUDE 192 | BEGIN 193 | "#include ""winresrc.h""\r\n" 194 | "#ifndef APSTUDIO_INVOKED\r\n" 195 | "#include ""DemoHelper.rc2""\r\n" 196 | "#endif\0" 197 | END 198 | 199 | 3 TEXTINCLUDE 200 | BEGIN 201 | "\r\n" 202 | "\0" 203 | END 204 | 205 | #endif // APSTUDIO_INVOKED 206 | 207 | 208 | ///////////////////////////////////////////////////////////////////////////// 209 | // 210 | // RTF 211 | // 212 | 213 | IDR_HELP RTF "res\\DemoHelperHelp.rtf" 214 | 215 | 216 | ///////////////////////////////////////////////////////////////////////////// 217 | // 218 | // String Table 219 | // 220 | 221 | STRINGTABLE 222 | BEGIN 223 | IDS_APP_TITLE "DemoHelper" 224 | IDS_WEBLINK "https://tools.stefankueng.com/DemoHelper.html" 225 | IDC_DEMOHELPER "DemoHelper" 226 | END 227 | 228 | #endif // English (United States) resources 229 | ///////////////////////////////////////////////////////////////////////////// 230 | 231 | 232 | 233 | #ifndef APSTUDIO_INVOKED 234 | ///////////////////////////////////////////////////////////////////////////// 235 | // 236 | // Generated from the TEXTINCLUDE 3 resource. 237 | // 238 | 239 | 240 | ///////////////////////////////////////////////////////////////////////////// 241 | #endif // not APSTUDIO_INVOKED 242 | 243 | -------------------------------------------------------------------------------- /src/Commands.cpp: -------------------------------------------------------------------------------- 1 | // demoHelper - screen drawing and presentation tool 2 | 3 | // Copyright (C) 2007-2008, 2020-2021 - Stefan Kueng 4 | 5 | // This program is free software; you can redistribute it and/or 6 | // modify it under the terms of the GNU General Public License 7 | // as published by the Free Software Foundation; either version 2 8 | // of the License, or (at your option) any later version. 9 | 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | 15 | // You should have received a copy of the GNU General Public License 16 | // along with this program; if not, write to the Free Software Foundation, 17 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | // 19 | 20 | #include "stdafx.h" 21 | #include "MainWindow.h" 22 | #include "IniSettings.h" 23 | #include "InfoRtfDialog.h" 24 | 25 | extern HINSTANCE g_hInstance; // current instance 26 | extern HINSTANCE g_hResource; // the resource dll 27 | 28 | LRESULT CMainWindow::DoCommand(int id) 29 | { 30 | switch (id) 31 | { 32 | case ID_CMD_TOGGLEROP: 33 | if (m_currentAlpha == 255) 34 | m_currentAlpha = LINE_ALPHA; 35 | else 36 | m_currentAlpha = 255; 37 | break; 38 | case ID_CMD_QUITMODE: 39 | if (!m_bLensMode) 40 | { 41 | m_bZooming = false; 42 | EndPresentationMode(); 43 | UpdateCursor(); 44 | } 45 | break; 46 | case ID_CMD_UNDOLINE: 47 | m_bDrawing = false; 48 | if (!m_drawLines.empty()) 49 | m_drawLines.pop_back(); 50 | RedrawWindow(*this, nullptr, nullptr, RDW_INTERNALPAINT | RDW_INVALIDATE); 51 | break; 52 | case ID_CMD_REMOVEFIRST: 53 | { 54 | m_bDrawing = false; 55 | if (!m_drawLines.empty()) 56 | m_drawLines.pop_front(); 57 | RedrawWindow(*this, nullptr, nullptr, RDW_INTERNALPAINT | RDW_INVALIDATE); 58 | } 59 | break; 60 | case ID_CMD_INCREASE: 61 | if (m_bZooming) 62 | { 63 | m_zoomFactor += 0.2f; 64 | if (m_zoomFactor > 4.0f) 65 | m_zoomFactor = 4.0f; 66 | RedrawWindow(*this, nullptr, nullptr, RDW_INTERNALPAINT | RDW_INVALIDATE); 67 | } 68 | else if (!m_drawLines.empty()) 69 | { 70 | // increase pen size 71 | if (m_currentPenWidth < 32) 72 | { 73 | m_currentPenWidth++; 74 | RedrawWindow(*this, nullptr, nullptr, RDW_INTERNALPAINT | RDW_INVALIDATE); 75 | } 76 | } 77 | UpdateCursor(); 78 | break; 79 | case ID_CMD_DECREASE: 80 | if (m_bZooming) 81 | { 82 | m_zoomFactor -= 0.2f; 83 | if (m_zoomFactor < 1.0f) 84 | m_zoomFactor = 1.0f; 85 | RedrawWindow(*this, nullptr, nullptr, RDW_INTERNALPAINT | RDW_INVALIDATE); 86 | } 87 | else if (!m_drawLines.empty()) 88 | { 89 | // decrease pen size 90 | if (m_currentPenWidth > 1) 91 | { 92 | m_currentPenWidth--; 93 | RedrawWindow(*this, nullptr, nullptr, RDW_INTERNALPAINT | RDW_INVALIDATE); 94 | } 95 | } 96 | UpdateCursor(); 97 | break; 98 | case ID_CMD_NEXTCOLOR: 99 | // cycle through colors 100 | if (!m_drawLines.empty()) 101 | { 102 | if (m_colorIndex < 9) 103 | m_colorIndex++; 104 | else 105 | m_colorIndex = 0; 106 | RedrawWindow(*this, nullptr, nullptr, RDW_INTERNALPAINT | RDW_INVALIDATE); 107 | } 108 | UpdateCursor(); 109 | break; 110 | case ID_CMD_PREVCOLOR: 111 | // cycle through colors 112 | if (!m_drawLines.empty()) 113 | { 114 | if (m_colorIndex > 0) 115 | m_colorIndex--; 116 | else 117 | m_colorIndex = 9; 118 | RedrawWindow(*this, nullptr, nullptr, RDW_INTERNALPAINT | RDW_INVALIDATE); 119 | } 120 | UpdateCursor(); 121 | break; 122 | case ID_CMD_COLOR0: 123 | m_colorIndex = 0; 124 | UpdateCursor(); 125 | break; 126 | case ID_CMD_COLOR1: 127 | m_colorIndex = 1; 128 | UpdateCursor(); 129 | break; 130 | case ID_CMD_COLOR2: 131 | m_colorIndex = 2; 132 | UpdateCursor(); 133 | break; 134 | case ID_CMD_COLOR3: 135 | m_colorIndex = 3; 136 | UpdateCursor(); 137 | break; 138 | case ID_CMD_COLOR4: 139 | m_colorIndex = 4; 140 | UpdateCursor(); 141 | break; 142 | case ID_CMD_COLOR5: 143 | m_colorIndex = 5; 144 | UpdateCursor(); 145 | break; 146 | case ID_CMD_COLOR6: 147 | m_colorIndex = 6; 148 | UpdateCursor(); 149 | break; 150 | case ID_CMD_COLOR7: 151 | m_colorIndex = 7; 152 | UpdateCursor(); 153 | break; 154 | case ID_CMD_COLOR8: 155 | m_colorIndex = 8; 156 | UpdateCursor(); 157 | break; 158 | case ID_CMD_COLOR9: 159 | m_colorIndex = 9; 160 | UpdateCursor(); 161 | break; 162 | case ID_CMD_CLEARLINES: 163 | m_bDrawing = false; 164 | m_drawLines.clear(); 165 | RedrawWindow(*this, nullptr, nullptr, RDW_INTERNALPAINT | RDW_INVALIDATE); 166 | break; 167 | case ID_CMD_QUICKTOMARKER: 168 | // marker mode - quick way to select the biggest brush size and color yellow 169 | if (m_bMarker) 170 | { 171 | m_currentPenWidth = m_oldPenWidth; 172 | m_colorIndex = m_oldColorIndex; 173 | m_currentAlpha = m_oldAlpha; 174 | m_bMarker = false; 175 | } 176 | else 177 | { 178 | m_oldPenWidth = m_currentPenWidth; 179 | m_oldColorIndex = m_colorIndex; 180 | m_oldAlpha = m_currentAlpha; 181 | 182 | m_currentPenWidth = GetSystemMetrics(SM_CXCURSOR); 183 | m_colorIndex = 0; 184 | m_currentAlpha = LINE_ALPHA; 185 | 186 | m_bMarker = true; 187 | } 188 | UpdateCursor(); 189 | break; 190 | case ID_CMD_ACCEPT: 191 | if (m_bZooming) 192 | { 193 | m_bZooming = false; 194 | // now make the zoomed window the 'default' 195 | HDC hdc = GetDC(*this); 196 | POINT pt; 197 | GetCursorPos(&pt); 198 | DrawZoom(hdc, pt); 199 | DeleteDC(hdc); 200 | RedrawWindow(*this, nullptr, nullptr, RDW_INTERNALPAINT | RDW_INVALIDATE); 201 | UpdateCursor(); 202 | } 203 | break; 204 | case IDM_EXIT: 205 | Shell_NotifyIcon(NIM_DELETE, &niData); 206 | if (m_hKeyboardHook) 207 | UnhookWindowsHookEx(m_hKeyboardHook); 208 | if (m_hMouseHook) 209 | UnhookWindowsHookEx(m_hMouseHook); 210 | m_hKeyboardHook = nullptr; 211 | m_hMouseHook = nullptr; 212 | for (auto& wnd : m_overlayWnds) 213 | { 214 | ShowWindow(*wnd.get(), SW_HIDE); 215 | CloseWindow(*wnd.get()); 216 | DestroyWindow(*wnd.get()); 217 | } 218 | ShowWindow(*m_infoOverlay.get(), SW_HIDE); 219 | CloseWindow(*m_infoOverlay.get()); 220 | DestroyWindow(*m_infoOverlay.get()); 221 | m_overlayWnds.clear(); 222 | m_infoOverlay.reset(nullptr); 223 | ShowWindow(m_mouseOverlay, SW_HIDE); 224 | CloseWindow(m_mouseOverlay); 225 | DestroyWindow(m_mouseOverlay); 226 | ::PostQuitMessage(0); 227 | return 0; 228 | case ID_TRAYCONTEXT_OPTIONS: 229 | { 230 | // deregister our hotkeys 231 | UnregisterHotKey(*this, DRAW_HOTKEY); 232 | UnregisterHotKey(*this, ZOOM_HOTKEY); 233 | UnregisterHotKey(*this, LENS_HOTKEY); 234 | // remove hooks 235 | if (m_hKeyboardHook) 236 | UnhookWindowsHookEx(m_hKeyboardHook); 237 | if (m_hMouseHook) 238 | UnhookWindowsHookEx(m_hMouseHook); 239 | m_hKeyboardHook = nullptr; 240 | m_hMouseHook = nullptr; 241 | DialogBox(hResource, MAKEINTRESOURCE(IDD_OPTIONS), *this, reinterpret_cast(OptionsDlgProc)); 242 | // now register our hotkeys again 243 | RegisterHotKeys(); 244 | // and install the hooks if requested 245 | m_hMouseHook = SetWindowsHookEx(WH_MOUSE_LL, LowLevelMouseProc, g_hInstance, 0); 246 | if (CIniSettings::Instance().GetInt64(L"Hooks", L"keyboard", 1)) 247 | m_hKeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardProc, g_hInstance, 0); 248 | m_bMouseVisuals = CIniSettings::Instance().GetInt64(L"Misc", L"mousevisual", 1) != 0; 249 | m_bMouseClicks = CIniSettings::Instance().GetInt64(L"Hooks", L"mouse", 1) != 0; 250 | m_mvLColor = static_cast(CIniSettings::Instance().GetInt64(L"Misc", L"mousevisualLcolor", RGB(255, 0, 0))); 251 | m_mvMColor = static_cast(CIniSettings::Instance().GetInt64(L"Misc", L"mousevisualMcolor", RGB(0, 0, 255))); 252 | m_mvRColor = static_cast(CIniSettings::Instance().GetInt64(L"Misc", L"mousevisualRcolor", RGB(0, 255, 0))); 253 | m_overlayPosition = static_cast(CIniSettings::Instance().GetInt64(L"Misc", L"OvlPosition", static_cast(OverlayPosition::BottomRight))); 254 | } 255 | break; 256 | case ID_TRAYCONTEXT_DRAW: 257 | SetTimer(*this, TIMER_ID_DRAW, 300, nullptr); 258 | break; 259 | case ID_TRAYCONTEXT_ZOOM: 260 | SetTimer(*this, TIMER_ID_ZOOM, 300, nullptr); 261 | break; 262 | case ID_CMD_INLINEZOOM: 263 | StartInlineZoom(); 264 | break; 265 | case ID_CMD_CLEARSCREEN: 266 | { 267 | // clear the whole screen for drawing on it 268 | RECT rect; 269 | rect.left = GetSystemMetrics(SM_XVIRTUALSCREEN); 270 | rect.top = GetSystemMetrics(SM_YVIRTUALSCREEN); 271 | rect.right = rect.left + GetSystemMetrics(SM_CXVIRTUALSCREEN); 272 | rect.bottom = rect.top + GetSystemMetrics(SM_CYVIRTUALSCREEN); 273 | SetBkColor(hDesktopCompatibleDC, ::GetSysColor(COLOR_WINDOW)); 274 | ::ExtTextOut(hDesktopCompatibleDC, 0, 0, ETO_OPAQUE, &rect, nullptr, 0, nullptr); 275 | // also clear all lines already drawn 276 | m_bDrawing = false; 277 | m_drawLines.clear(); 278 | RedrawWindow(*this, nullptr, nullptr, RDW_INTERNALPAINT | RDW_INVALIDATE); 279 | } 280 | break; 281 | case IDHELP: 282 | { 283 | CInfoRtfDialog dlg; 284 | RECT rcOwner; 285 | auto hwndOwner = GetDesktopWindow(); 286 | GetWindowRect(hwndOwner, &rcOwner); 287 | const int width = 470; 288 | const int height = 430; 289 | dlg.DoModal(hResource, hwndOwner, "DemoHelper help", IDR_HELP, L"RTF", IDI_DEMOHELPER, 290 | rcOwner.right - width, rcOwner.bottom - height, width, height); 291 | } 292 | break; 293 | default: 294 | break; 295 | }; 296 | return 1; 297 | } 298 | -------------------------------------------------------------------------------- /src/DemoHelper.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {644720B5-9DD2-4FAB-A531-142C2D89BBCB} 23 | DemoHelper 24 | Win32Proj 25 | 10.0 26 | 27 | 28 | 29 | Application 30 | Unicode 31 | true 32 | v143 33 | 34 | 35 | Application 36 | Unicode 37 | true 38 | v143 39 | 40 | 41 | Application 42 | Unicode 43 | v143 44 | 45 | 46 | Application 47 | Unicode 48 | v143 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | <_ProjectFileVersion>10.0.40219.1 68 | $(SolutionDir)bin\$(Configuration)\$(Platform)\ 69 | $(SolutionDir)bin\$(Configuration)\$(Platform)\ 70 | $(SolutionDir)obj\$(Configuration)\$(Platform)\ 71 | $(SolutionDir)obj\$(Configuration)\$(Platform)\ 72 | true 73 | true 74 | $(SolutionDir)bin\$(Configuration)\$(Platform)\ 75 | $(SolutionDir)bin\$(Configuration)\$(Platform)\ 76 | $(SolutionDir)obj\$(Configuration)\$(Platform)\ 77 | $(SolutionDir)obj\$(Configuration)\$(Platform)\ 78 | false 79 | false 80 | NativeRecommendedRules.ruleset 81 | NativeRecommendedRules.ruleset 82 | 83 | 84 | 85 | 86 | NativeRecommendedRules.ruleset 87 | NativeRecommendedRules.ruleset 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | ..\sktoolslib;last 96 | EditAndContinue 97 | Sync 98 | true 99 | Disabled 100 | Use 101 | WIN32;_DEBUG;DEBUG;_WINDOWS;%(PreprocessorDefinitions) 102 | MultiThreadedDebug 103 | Level4 104 | 105 | 106 | comctl32.lib;shlwapi.lib;Msimg32.lib;%(AdditionalDependencies) 107 | true 108 | Windows 109 | MachineX86 110 | false 111 | 112 | 113 | PerMonitorHighDPIAware 114 | 115 | 116 | last 117 | 118 | 119 | 120 | 121 | ..\sktoolslib;last 122 | ProgramDatabase 123 | Sync 124 | Disabled 125 | Use 126 | WIN32;_DEBUG;DEBUG;_WINDOWS;%(PreprocessorDefinitions) 127 | MultiThreadedDebug 128 | Level4 129 | stdcpp20 130 | 131 | 132 | comctl32.lib;shlwapi.lib;Msimg32.lib;%(AdditionalDependencies) 133 | true 134 | Windows 135 | false 136 | 137 | 138 | PerMonitorHighDPIAware 139 | 140 | 141 | last 142 | 143 | 144 | 145 | 146 | ..\sktoolslib;last 147 | ProgramDatabase 148 | NoExtensions 149 | true 150 | true 151 | MaxSpeed 152 | Use 153 | WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) 154 | MultiThreaded 155 | true 156 | Level4 157 | 158 | 159 | comctl32.lib;shlwapi.lib;Msimg32.lib;%(AdditionalDependencies) 160 | true 161 | true 162 | true 163 | true 164 | Windows 165 | MachineX86 166 | 167 | 168 | PerMonitorHighDPIAware 169 | 170 | 171 | last 172 | 173 | 174 | 175 | 176 | ..\sktoolslib;last 177 | ProgramDatabase 178 | true 179 | true 180 | MaxSpeed 181 | Use 182 | WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) 183 | MultiThreaded 184 | true 185 | Level4 186 | stdcpp20 187 | 188 | 189 | comctl32.lib;shlwapi.lib;Msimg32.lib;%(AdditionalDependencies) 190 | true 191 | true 192 | true 193 | true 194 | Windows 195 | false 196 | 197 | 198 | PerMonitorHighDPIAware 199 | 200 | 201 | last 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | Create 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------