├── wdvscroll.gif ├── xlhscroll.gif ├── MsoScroll ├── exports.def ├── resource.h ├── stdafx.cpp ├── dllmain.cpp ├── debugtrace.h ├── resources.rc ├── stdafx.h ├── MsoScroll.cpp └── MsoScroll.vcproj ├── README.md ├── ThisDocument.cls ├── ThisWorkbook.cls └── The Code Project Open License (CPOL) 1.02.md /wdvscroll.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/T800G/OfficeScroll/HEAD/wdvscroll.gif -------------------------------------------------------------------------------- /xlhscroll.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/T800G/OfficeScroll/HEAD/xlhscroll.gif -------------------------------------------------------------------------------- /MsoScroll/exports.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | Connect PRIVATE 3 | Disconnect PRIVATE 4 | -------------------------------------------------------------------------------- /MsoScroll/resource.h: -------------------------------------------------------------------------------- 1 | #ifndef IDC_STATIC 2 | #define IDC_STATIC (-1) 3 | #endif 4 | -------------------------------------------------------------------------------- /MsoScroll/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // MsoScroll.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /MsoScroll/dllmain.cpp: -------------------------------------------------------------------------------- 1 | // dllmain.cpp : Defines the entry point for the DLL application. 2 | #include "stdafx.h" 3 | 4 | BOOL APIENTRY DllMain( HMODULE hModule, 5 | DWORD ul_reason_for_call, 6 | LPVOID lpReserved 7 | ) 8 | { 9 | switch (ul_reason_for_call) 10 | { 11 | case DLL_PROCESS_ATTACH: 12 | case DLL_THREAD_ATTACH: 13 | case DLL_THREAD_DETACH: 14 | case DLL_PROCESS_DETACH: 15 | break; 16 | } 17 | return TRUE; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /MsoScroll/debugtrace.h: -------------------------------------------------------------------------------- 1 | #include 2 | #ifndef _DEBUGTRACE_8A7AC67B_B017_4AAB_BBA7_1EE09FEDC416_ 3 | #define _DEBUGTRACE_8A7AC67B_B017_4AAB_BBA7_1EE09FEDC416_ 4 | #ifdef _DEBUG 5 | 6 | #define DBGTRACE(msg, ...) DbgTrace(0, "", msg, __VA_ARGS__) 7 | #define DBGTRACE2(msg, ...) DbgTrace(__LINE__, __FILE__, msg, __VA_ARGS__) 8 | 9 | void DbgTrace(int line, const char* fileName, const char* msg, ...) 10 | { 11 | va_list args; 12 | char buffer[256] = { 0 }; 13 | if (line) 14 | { 15 | /*_stprintf_s*/sprintf_s(buffer, "%s(%d) : ", (strrchr(fileName, '\\') ? strrchr(fileName, '\\') + 1 : fileName), line); 16 | OutputDebugStringA(buffer); 17 | } 18 | 19 | // retrieve the variable arguments 20 | va_start(args, msg); 21 | /*_vstprintf_s*/vsprintf_s(buffer, msg, args); 22 | OutputDebugStringA(buffer); 23 | va_end(args); 24 | } 25 | 26 | #else 27 | #define DBGTRACE(msg, ...) 28 | #define DBGTRACE2(msg, ...) 29 | #endif//_DEBUG 30 | #endif//_DEBUGTRACE_8A7AC67B_B017_4AAB_BBA7_1EE09FEDC416_ 31 | -------------------------------------------------------------------------------- /MsoScroll/resources.rc: -------------------------------------------------------------------------------- 1 | // Generated by ResEdit 1.6.2 2 | // Copyright (C) 2006-2014 3 | // http://www.resedit.net 4 | 5 | #include 6 | //#include 7 | //#include 8 | #include "resource.h" 9 | 10 | 11 | // 12 | // Version Information resources 13 | // 14 | LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL 15 | VS_VERSION_INFO VERSIONINFO 16 | FILEVERSION 1,2,0,0 17 | PRODUCTVERSION 1,2,0,0 18 | FILEOS VOS__WINDOWS32 19 | FILETYPE VFT_DLL 20 | FILESUBTYPE VFT2_UNKNOWN 21 | FILEFLAGSMASK 0x00000000 22 | FILEFLAGS 0x00000000 23 | { 24 | BLOCK "StringFileInfo" 25 | { 26 | BLOCK "040904B0" 27 | { 28 | VALUE "CompanyName", "T800 Productions\0" 29 | #ifdef _WIN64 30 | VALUE "FileDescription", "Office Scroll Add-In 64-bit\0" 31 | #else 32 | VALUE "FileDescription", "Office Scroll Add-In 32-bit\0" 33 | #endif 34 | VALUE "FileVersion", "1.2\0" 35 | VALUE "ProductVersion", "1.2\0" 36 | VALUE "LegalCopyright", "T800 Productions \251 2019\0" 37 | VALUE "ProductName", "Office Scroll Add-In\0" 38 | } 39 | } 40 | BLOCK "VarFileInfo" 41 | { 42 | VALUE "Translation", 0x0409, 0x04B0 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Office Scroll Add-In 2 | Enhanced mouse wheel scroll add-in for Microsoft Excel and Word.
3 | Horizonal scroll while Shift key is pressed and scroll by page when Alt key is pressed. 4 | ![alt text](https://github.com/T800G/OfficeScroll/blob/master/xlhscroll.gif "Excel horizontal scroll") 5 | ![alt text](https://github.com/T800G/OfficeScroll/blob/master/wdvscroll.gif "Word vertical scroll")
6 | 7 | ## Minimum requirements: 8 | * Windows 2000 9 | * Office 2000 10 | 11 | 12 | Supports both 32-bit and 64-bit Office. 13 | 14 | ### IMPORTANT 15 | This add-in is not compatible with KatMouse and similar software. Excel.exe must be added to application ignore list in KatMouse options.
16 | This add-in is not compatible with Excel Horizontal Scroll COM add-in, you need to uninstall it first.
17 | If Windows AppLocker is active on your system, depending on the configuration, you may not be able to use this add-in. 18 | 19 | ### Multiple system input languages 20 | This addin sends additional Alt key strokes to hide ribbon tooltips. 21 | If you use multiple system input languages, set the input language switch key to "Not assigned" (Control panel -> Regional settings) and enable language bar in taskbar to switch languages through right-click on it. 22 | 23 | ## KNOWN PROBLEMS 24 | * The Office version installed from Microsoft Store has problems loading external dll files. 25 | For solution, refer to https://stackoverflow.com/questions/50683727/loadlibrary-in-vba-returns-0-when-trying-to-load-r-dll-in-office-from-microsoft 26 | * Kaspersky antivirus software causes PowerPoint to crash when loading ppa/ppm add-ins. For that reason PowerPoint add-in is provided in a separate zip package. 27 | 28 | ## Install/Remove 29 | You can install this add-in as a standard user (non-administrator).
30 | 1. Unzip all files.
31 | 2. Double click INSTALL.bat to copy files to their folders (double click REMOVE.bat to delete all files).
32 | 3. Restart Word and Excel. 33 | -------------------------------------------------------------------------------- /ThisDocument.cls: -------------------------------------------------------------------------------- 1 | Option Explicit 2 | 3 | Private Const S_OK = 0 4 | Private hResult As Long 5 | 6 | #If Win64 Then 7 | Private Const DLLNAME = "MsoScroll64.dll" 8 | Private Declare PtrSafe Function Connect Lib "MsoScroll64.dll" (ByVal r As Object) As Long 9 | Private Declare PtrSafe Function Disconnect Lib "MsoScroll64.dll" () As Long 10 | Private Declare PtrSafe Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As LongPtr 11 | Private Declare PtrSafe Function FreeLibrary Lib "kernel32" (ByVal hLibModule As LongPtr) As Long 12 | Private m_hDll As LongPtr 13 | #Else 14 | Private Const DLLNAME = "MsoScroll.dll" 15 | Private Declare Function Connect Lib "MsoScroll.dll" (ByVal r As Object) As Long 16 | Private Declare Function Disconnect Lib "MsoScroll.dll" () As Long 17 | Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long 18 | Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long 19 | Private m_hDll As Long 20 | #End If 21 | 22 | Public Sub AutoExec() 23 | Dim dllPath As String 24 | dllPath = Environ("APPDATA") & "\Microsoft\AddIns\" & DLLNAME 25 | If Dir(dllPath) <> "" Then 26 | 'If Not CheckWDAddins() Then Exit Sub 27 | 'Debug.Assert (m_hDll = 0) 28 | If (m_hDll = 0) Then m_hDll = LoadLibrary(dllPath) 29 | 'Debug.Assert (m_hDll <> 0) 30 | If m_hDll <> 0 Then 31 | hResult = Connect(Application) 32 | 'Debug.Assert (hResult = S_OK) 33 | Debug.Print DLLNAME & "::Connect()" 34 | End If 35 | Else 36 | MsgBox "File not found:" & vbCrLf & dllPath, vbCritical, "Office Scroll Add-in" 37 | End If 38 | End Sub 39 | 40 | Public Sub AutoExit() 41 | If (m_hDll <> 0) Then 42 | hResult = Disconnect() 43 | 'Debug.Assert (hResult = S_OK) 44 | FreeLibrary m_hDll 45 | m_hDll = 0 46 | End If 47 | End Sub 48 | -------------------------------------------------------------------------------- /MsoScroll/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 | #ifndef STRICT 9 | #define STRICT 10 | #endif 11 | 12 | // The following macros define the minimum required platform. The minimum required platform 13 | // is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run 14 | // your application. The macros work by enabling all features available on platform versions up to and 15 | // including the version specified. 16 | 17 | // Modify the following defines if you have to target a platform prior to the ones specified below. 18 | // Refer to MSDN for the latest info on corresponding values for different platforms. 19 | //#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later. 20 | //#define WINVER 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later. 21 | //#endif 22 | 23 | #ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later. 24 | #define _WIN32_WINNT _WIN32_WINNT_WIN2K // Change this to the appropriate value to target Windows 2000 or later. 25 | #endif 26 | 27 | //#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later. 28 | //#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. 29 | //#endif 30 | // 31 | //#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later. 32 | //#define _WIN32_IE 0x0400 // Change this to the appropriate value to target IE 5.0 or later. 33 | //#endif 34 | 35 | #include 36 | #include "resource.h" 37 | 38 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 39 | // Windows Header Files: 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | 46 | // TODO: reference additional headers your program requires here 47 | -------------------------------------------------------------------------------- /ThisWorkbook.cls: -------------------------------------------------------------------------------- 1 | Option Explicit 2 | 3 | Private Const S_OK = 0 4 | Private hResult As Long 5 | 6 | #If Win64 Then 7 | Private Const DLLNAME = "MsoScroll64.dll" 8 | Private Declare PtrSafe Function Connect Lib "MsoScroll64.dll" (ByVal r As Object) As Long 9 | Private Declare PtrSafe Function Disconnect Lib "MsoScroll64.dll" () As Long 10 | Private Declare PtrSafe Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As LongPtr 11 | Private Declare PtrSafe Function FreeLibrary Lib "kernel32" (ByVal hLibModule As LongPtr) As Long 12 | Private m_hDll As LongPtr 13 | #Else 14 | Private Const DLLNAME = "MsoScroll.dll" 15 | Private Declare Function Connect Lib "MsoScroll.dll" (ByVal r As Object) As Long 16 | Private Declare Function Disconnect Lib "MsoScroll.dll" () As Long 17 | Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long 18 | Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long 19 | Private m_hDll As Long 20 | #End If 21 | 22 | Public Sub Workbook_Open() 23 | Dim dllPath As String 24 | dllPath = Environ("APPDATA") & "\Microsoft\AddIns\" & DLLNAME 25 | If Dir(dllPath) <> "" Then 26 | 'If Not CheckXLAddins() Then Exit Sub 27 | 'Debug.Assert (m_hDll = 0) 28 | If (m_hDll = 0) Then m_hDll = LoadLibrary(dllPath) 29 | 'Debug.Assert (m_hDll <> 0) 30 | If m_hDll <> 0 Then 31 | hResult = Connect(Application) 32 | 'Debug.Assert (hResult = S_OK) 33 | Debug.Print DLLNAME & "::Connect()" 34 | End If 35 | Else 36 | MsgBox "File not found:" & vbCrLf & dllPath, vbCritical, "Office Scroll Add-in" 37 | End If 38 | End Sub 39 | 40 | Public Sub Workbook_BeforeClose(Cancel As Boolean) 41 | If (m_hDll <> 0) Then 42 | hResult = Disconnect() 43 | 'Debug.Assert (hResult = S_OK) 44 | FreeLibrary m_hDll 45 | m_hDll = 0 46 | End If 47 | End Sub 48 | 49 | 'Private Function CheckXLAddins() As Boolean 50 | 'On Error GoTo ErrHandler 51 | ' CheckXLAddins = True 52 | ' Dim ca As COMAddIn 53 | ' For Each ca In Application.COMAddIns 54 | ' 'Debug.Print "Application.COMAddIns: " & ca.GUID & " " & ca.progID 55 | ' If ca.progID = "XLHScroll.Connect" Then 56 | ' MsgBox "Uninstall Excel Horizontal Scroll Add-in before using Office Scroll Add-in", vbOKOnly Or vbExclamation, "Office Scroll Add-in" 57 | ' CheckXLAddins = False 58 | ' Exit Function 59 | ' End If 60 | ' Next ca 61 | ' On Error GoTo 0 62 | ' Exit Function 63 | 'ErrHandler: 64 | ' Debug.Print "MsoScroll::CheckXLAddins Line " & Erl & " error " & Err.Number & ": " & Err.Description 65 | 'End Function -------------------------------------------------------------------------------- /MsoScroll/MsoScroll.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "debugtrace.h" 3 | 4 | extern "C" IMAGE_DOS_HEADER __ImageBase; 5 | HHOOK g_mouseHook; 6 | IDispatch* g_pApplication; 7 | //LONG g_AppID;//Excel=0, Word=1 8 | BOOL g_bRecurse; 9 | 10 | // 11 | // FUNCTION: AutoWrap(int, VARIANT*, IDispatch*, LPOLESTR, int,...) 12 | // PURPOSE: Automation helper function. It simplifies most of the low-level 13 | // details involved with using IDispatch directly. Feel free to use it 14 | // in your own implementations. One caveat is that if you pass multiple 15 | // parameters, they need to be passed in reverse-order. 16 | // PARAMETERS: 17 | // * autoType - Could be one of these values: DISPATCH_PROPERTYGET, 18 | // DISPATCH_PROPERTYPUT, DISPATCH_PROPERTYPUTREF, DISPATCH_METHOD. 19 | // * pvResult - Holds the return value in a VARIANT. 20 | // * pDisp - The IDispatch interface. 21 | // * ptName - The property/method name exposed by the interface. 22 | // * cArgs - The count of the arguments. 23 | // RETURN VALUE: An HRESULT value indicating whether the function succeeds or not. 24 | // EXAMPLE: 25 | // AutoWrap(DISPATCH_METHOD, NULL, pDisp, L"call", 2, parm[1], parm[0]); 26 | // 27 | HRESULT AutoWrap(int autoType, VARIANT *pvResult, IDispatch *pDisp, LPOLESTR ptName, int cArgs...) 28 | { 29 | if (!pDisp) return E_INVALIDARG; 30 | 31 | // Variables used 32 | DISPPARAMS dp = { NULL, NULL, 0, 0 }; 33 | DISPID dispidNamed = DISPID_PROPERTYPUT; 34 | DISPID dispID; 35 | HRESULT hr; 36 | 37 | // Get DISPID for name passed 38 | hr = pDisp->GetIDsOfNames(IID_NULL, &ptName, 1, /*LOCALE_USER_DEFAULT*/ LOCALE_SYSTEM_DEFAULT, &dispID); 39 | if (FAILED(hr)) 40 | { 41 | //#ifdef _DEBUG 42 | OutputDebugString(_T("AutoWrap::IDispatch->GetIDsOfNames failed\n")); 43 | _com_error err(hr); 44 | OutputDebugString(err.ErrorMessage()); OutputDebugString(_T("\n")); 45 | //#endif//_DEBUG 46 | return hr; 47 | } 48 | 49 | // Begin variable-argument list 50 | va_list marker; 51 | va_start(marker, cArgs); 52 | 53 | // Allocate memory for arguments 54 | VARIANT *pArgs = new VARIANT[cArgs + 1]; 55 | // Extract arguments... 56 | for(int i=0; i < cArgs; i++) 57 | { 58 | pArgs[i] = va_arg(marker, VARIANT); 59 | } 60 | 61 | // Build DISPPARAMS 62 | dp.cArgs = cArgs; 63 | dp.rgvarg = pArgs; 64 | 65 | // Handle special-case for property-puts 66 | if (autoType & DISPATCH_PROPERTYPUT) 67 | { 68 | dp.cNamedArgs = 1; 69 | dp.rgdispidNamedArgs = &dispidNamed; 70 | } 71 | 72 | // Make the call 73 | hr = pDisp->Invoke(dispID, IID_NULL, /*LOCALE_USER_DEFAULT*/ LOCALE_SYSTEM_DEFAULT, autoType, &dp, pvResult, NULL, NULL); 74 | if FAILED(hr) 75 | { 76 | //#ifdef _DEBUG 77 | OutputDebugString(_T("AutoWrap::IDispatch->Invoke failed\n")); 78 | _com_error err(hr); 79 | OutputDebugString(err.ErrorMessage()); OutputDebugString(_T("\n")); 80 | //#endif//_DEBUG 81 | } 82 | 83 | // End variable-argument section 84 | va_end(marker); 85 | delete[] pArgs; 86 | return hr; 87 | } 88 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 89 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 90 | LRESULT CALLBACK MouseHookProc(int nCode, WPARAM wMsg, LPARAM lParam) 91 | { 92 | if (g_bRecurse || (nCode<0)) return CallNextHookEx(g_mouseHook, nCode, wMsg, lParam); 93 | 94 | if ((wMsg==WM_MOUSEWHEEL) && (HIWORD(GetKeyState(VK_SHIFT)) || HIWORD(GetKeyState(VK_MENU)))) //VK_MENU=ALT key 95 | { 96 | //if (g_bRecurse) {DBGTRACE("prevent RECURSION-------\n");return 1;} 97 | g_bRecurse=TRUE; 98 | //DBGTRACE("WM_MOUSEWHEEL received\n"); 99 | //DBGTRACE("hwnd=0x%x\n",((LPMOUSEHOOKSTRUCT)lParam)->hwnd); 100 | //DBGTRACE("WM_MOUSEWHEEL+VK_SHIFT|VK_MENU\n"); 101 | 102 | short zDelta=GET_WHEEL_DELTA_WPARAM(((LPMOUSEHOOKSTRUCTEX)lParam)->mouseData); 103 | VARIANT vtActiveWindow; 104 | VariantInit(&vtActiveWindow); 105 | //protected view window has no scroll/page members 106 | if SUCCEEDED(AutoWrap(DISPATCH_PROPERTYGET, &vtActiveWindow, g_pApplication, L"ActiveWindow", 0)) 107 | { 108 | //Excel and Word both have these methods (can be called as ActiveWindow.ActivePane.LargeScroll or ActiveWindow.LargeScroll) 109 | //Word can also use "PageScroll" method 110 | LPOLESTR pstrMethodName= HIWORD(GetKeyState(VK_MENU)) ? L"LargeScroll" : L"SmallScroll";//scroll by line/cell or by page 111 | 112 | //send Alt key up,down,up to fix ribbon tooltips 113 | INPUT ip[3] ; 114 | ZeroMemory(ip, sizeof(ip)); 115 | ip[0].type = INPUT_KEYBOARD; 116 | ip[0].ki.wScan = MapVirtualKey(VK_MENU, MAPVK_VK_TO_VSC); 117 | ip[0].ki.dwFlags = KEYEVENTF_EXTENDEDKEY | KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP; 118 | ip[1].type = INPUT_KEYBOARD; 119 | ip[1].ki.wScan = MapVirtualKey(VK_MENU, MAPVK_VK_TO_VSC); 120 | ip[1].ki.dwFlags = KEYEVENTF_EXTENDEDKEY | KEYEVENTF_SCANCODE; 121 | ip[2].type = INPUT_KEYBOARD; 122 | ip[2].ki.wScan = MapVirtualKey(VK_MENU, MAPVK_VK_TO_VSC); 123 | ip[2].ki.dwFlags = KEYEVENTF_EXTENDEDKEY | KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP; 124 | SendInput(3, ip, sizeof(INPUT)); 125 | 126 | VARIANT vt_, vt1; 127 | vt_.vt = VT_I4;//VB Long type 128 | vt1.vt = VT_I4; 129 | vt_.lVal = 0; 130 | vt1.lVal = 1; 131 | //SendInput might interfere, so use GetAsyncKeyState instead of GetKeyState 132 | if HIWORD(GetAsyncKeyState(VK_SHIFT)) //scroll horizontaly 133 | { 134 | if (zDelta < 0) AutoWrap(DISPATCH_METHOD, NULL, vtActiveWindow.pdispVal, pstrMethodName, 4, vt_, vt1, vt_, vt_); //Left, Right, Up, Down (reverse order!) 135 | else AutoWrap(DISPATCH_METHOD, NULL, vtActiveWindow.pdispVal, pstrMethodName, 4, vt1, vt_, vt_, vt_); 136 | } 137 | else //scroll verticaly 138 | { 139 | //if (g_AppID) //Word 140 | //{ 141 | // if (zDelta < 0) AutoWrap(DISPATCH_METHOD, NULL, vtActiveWindow.pdispVal, L"PageScroll", 2, vt_, vt1);//Up, Down 142 | // else AutoWrap(DISPATCH_METHOD, NULL, vtActiveWindow.pdispVal, L"PageScroll", 2, vt1, vt_); 143 | //} 144 | //else //Excel 145 | { 146 | if (zDelta < 0) AutoWrap(DISPATCH_METHOD, NULL, vtActiveWindow.pdispVal, pstrMethodName, 4, vt_, vt_, vt_, vt1); 147 | else AutoWrap(DISPATCH_METHOD, NULL, vtActiveWindow.pdispVal, pstrMethodName, 4, vt_, vt_, vt1, vt_); 148 | } 149 | } 150 | vtActiveWindow.pdispVal->Release(); 151 | } 152 | 153 | g_bRecurse=FALSE; 154 | 155 | /*We must not pass this message to hook chain if there's no opened workbook, otherwise WM_MOUSEWHEEL + Shift crashes Excel. 156 | Excel (and Word) installs it's own application-level hooks (WH_MSGFILTER, WH_KEYBOARD, WH_CBT). 157 | This bug is present in Excel 97, 2000, 2002 and 2003. */ 158 | return 1; 159 | } 160 | return CallNextHookEx(g_mouseHook, nCode, wMsg, lParam); 161 | } 162 | 163 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 164 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 165 | STDAPI Connect(IDispatch *pApplication) 166 | { 167 | if (pApplication==NULL) return E_INVALIDARG; 168 | HRESULT hr=S_OK; 169 | 170 | _ASSERTE(g_pApplication==NULL); 171 | if (g_pApplication==NULL) 172 | { 173 | //get application name 174 | // VARIANT vtAppName; 175 | // VariantInit(&vtAppName); 176 | // if SUCCEEDED(AutoWrap(DISPATCH_PROPERTYGET, &vtAppName, pApplication, L"Name", 0)) 177 | // { 178 | //OutputDebugString(vtAppName.bstrVal); 179 | // if(0 == wcscmp(vtAppName.bstrVal, L"Microsoft Word")) g_AppID=1; 180 | // VariantClear(&vtAppName); 181 | g_pApplication=pApplication; 182 | g_pApplication->AddRef(); 183 | DBGTRACE("MsoScroll::Connect\n"); 184 | //} 185 | } 186 | else hr=ERROR_ALREADY_ASSIGNED; 187 | 188 | if SUCCEEDED(hr) 189 | { 190 | _ASSERTE(g_mouseHook==NULL); 191 | if (g_mouseHook==NULL) 192 | { 193 | g_mouseHook=SetWindowsHookEx(WH_MOUSE, MouseHookProc, (HINSTANCE)&__ImageBase, GetCurrentThreadId()); 194 | DBGTRACE("MsoScroll::SetWindowsHookEx\n"); 195 | } 196 | else {hr=ERROR_ALREADY_EXISTS; DBGTRACE("ERROR_ALREADY_EXISTS\n");} 197 | } 198 | return hr; 199 | } 200 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 201 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 202 | STDAPI Disconnect() 203 | { 204 | //_ASSERTE(g_mouseHook); 205 | if (g_mouseHook) 206 | { 207 | UnhookWindowsHookEx(g_mouseHook); 208 | g_mouseHook=NULL; 209 | DBGTRACE("MsoScroll::UnhookWindowsHookEx\n"); 210 | } 211 | //_ASSERTE(g_pApplication); 212 | if (g_pApplication) 213 | { 214 | g_pApplication->Release(); 215 | g_pApplication=NULL; 216 | DBGTRACE("MsoScroll::g_pApplication->Release\n"); 217 | } 218 | return S_OK; 219 | } -------------------------------------------------------------------------------- /MsoScroll/MsoScroll.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 15 | 18 | 19 | 20 | 21 | 22 | 29 | 32 | 35 | 38 | 41 | 44 | 55 | 58 | 61 | 64 | 72 | 75 | 78 | 81 | 84 | 87 | 90 | 94 | 95 | 102 | 105 | 108 | 111 | 114 | 118 | 129 | 132 | 136 | 139 | 148 | 151 | 154 | 157 | 160 | 163 | 166 | 170 | 171 | 179 | 182 | 185 | 188 | 191 | 194 | 205 | 208 | 211 | 214 | 223 | 226 | 229 | 232 | 235 | 238 | 241 | 245 | 246 | 254 | 257 | 260 | 263 | 266 | 270 | 281 | 284 | 288 | 291 | 301 | 304 | 307 | 310 | 313 | 316 | 319 | 323 | 324 | 325 | 326 | 327 | 328 | 333 | 336 | 337 | 340 | 343 | 348 | 349 | 352 | 357 | 358 | 361 | 366 | 367 | 370 | 375 | 376 | 377 | 380 | 381 | 384 | 385 | 388 | 391 | 395 | 396 | 399 | 403 | 404 | 407 | 411 | 412 | 415 | 419 | 420 | 421 | 424 | 425 | 426 | 431 | 434 | 435 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | -------------------------------------------------------------------------------- /The Code Project Open License (CPOL) 1.02.md: -------------------------------------------------------------------------------- 1 |

The Code Project Open License (CPOL) 1.02

2 |
3 | 4 |
5 |
6 | 7 |

Preamble

8 |

9 | This License governs Your use of the Work. This License is intended to allow developers 10 | to use the Source Code and Executable Files provided as part of the Work in any 11 | application in any form. 12 |

13 |

14 | The main points subject to the terms of the License are:

15 |
    16 |
  • Source Code and Executable Files can be used in commercial applications;
  • 17 |
  • Source Code and Executable Files can be redistributed; and
  • 18 |
  • Source Code can be modified to create derivative works.
  • 19 |
  • No claim of suitability, guarantee, or any warranty whatsoever is provided. The software is 20 | provided "as-is".
  • 21 |
  • The Article accompanying the Work may not be distributed or republished without the 22 | Author's consent
  • 23 |
24 | 25 |

26 | This License is entered between You, the individual or other entity reading or otherwise 27 | making use of the Work licensed pursuant to this License and the individual or other 28 | entity which offers the Work under the terms of this License ("Author").

29 | 30 |

License

31 |

32 | THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CODE PROJECT OPEN 33 | LICENSE ("LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE 34 | LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT 35 | LAW IS PROHIBITED.

36 |

37 | BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HEREIN, YOU ACCEPT AND AGREE TO BE 38 | BOUND BY THE TERMS OF THIS LICENSE. THE AUTHOR GRANTS YOU THE RIGHTS CONTAINED HEREIN 39 | IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS. IF YOU DO NOT 40 | AGREE TO ACCEPT AND BE BOUND BY THE TERMS OF THIS LICENSE, YOU CANNOT MAKE ANY 41 | USE OF THE WORK.

42 | 43 |
    44 |
  1. Definitions. 45 | 46 |
      47 |
    1. "Articles" means, collectively, all articles written by Author 48 | which describes how the Source Code and Executable Files for the Work may be used 49 | by a user.
    2. 50 |
    3. "Author" means the individual or entity that offers the Work under the terms 51 | of this License.
    4. 52 |
    5. "Derivative Work" means a work based upon the Work or upon the 53 | Work and other pre-existing works.
    6. 54 |
    7. "Executable Files" refer to the executables, binary files, configuration 55 | and any required data files included in the Work.
    8. 56 |
    9. "Publisher" means the provider of the website, magazine, CD-ROM, DVD or other 57 | medium from or by which the Work is obtained by You.
    10. 58 |
    11. "Source Code" refers to the collection of source code and configuration files 59 | used to create the Executable Files.
    12. 60 |
    13. "Standard Version" refers to such a Work if it has not been modified, or 61 | has been modified in accordance with the consent of the Author, such consent being 62 | in the full discretion of the Author.
    14. 63 |
    15. "Work" refers to the collection of files distributed by the Publisher, including 64 | the Source Code, Executable Files, binaries, data files, documentation, whitepapers 65 | and the Articles.
    16. 66 |
    17. "You" is you, an individual or entity wishing to use the Work and exercise 67 | your rights under this License. 68 |
    18. 69 |
    70 |
  2. 71 | 72 |
  3. Fair Use/Fair Use Rights. Nothing in this License is intended to 73 | reduce, limit, or restrict any rights arising from fair use, fair dealing, first 74 | sale or other limitations on the exclusive rights of the copyright owner under copyright 75 | law or other applicable laws. 76 |
  4. 77 | 78 |
  5. License Grant. Subject to the terms and conditions of this License, 79 | the Author hereby grants You a worldwide, royalty-free, non-exclusive, perpetual 80 | (for the duration of the applicable copyright) license to exercise the rights in 81 | the Work as stated below: 82 | 83 |
      84 |
    1. You may use the standard version of the Source Code or Executable Files in Your 85 | own applications.
    2. 86 |
    3. You may apply bug fixes, portability fixes and other modifications obtained from 87 | the Public Domain or from the Author. A Work modified in such a way shall still 88 | be considered the standard version and will be subject to this License.
    4. 89 |
    5. You may otherwise modify Your copy of this Work (excluding the Articles) in any 90 | way to create a Derivative Work, provided that You insert a prominent notice in 91 | each changed file stating how, when and where You changed that file.
    6. 92 |
    7. You may distribute the standard version of the Executable Files and Source Code 93 | or Derivative Work in aggregate with other (possibly commercial) programs as part 94 | of a larger (possibly commercial) software distribution.
    8. 95 |
    9. The Articles discussing the Work published in any form by the author may not be 96 | distributed or republished without the Author's consent. The author retains 97 | copyright to any such Articles. You may use the Executable Files and Source Code 98 | pursuant to this License but you may not repost or republish or otherwise distribute 99 | or make available the Articles, without the prior written consent of the Author.
    10. 100 |
    101 | 102 | Any subroutines or modules supplied by You and linked into the Source Code or Executable 103 | Files of this Work shall not be considered part of this Work and will not be subject 104 | to the terms of this License. 105 |
  6. 106 | 107 |
  7. Patent License. Subject to the terms and conditions of this License, 108 | each Author hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, 109 | irrevocable (except as stated in this section) patent license to make, have made, use, import, 110 | and otherwise transfer the Work.
  8. 111 | 112 |
  9. Restrictions. The license granted in Section 3 above is expressly 113 | made subject to and limited by the following restrictions: 114 | 115 |
      116 |
    1. You agree not to remove any of the original copyright, patent, trademark, and 117 | attribution notices and associated disclaimers that may appear in the Source Code 118 | or Executable Files.
    2. 119 |
    3. You agree not to advertise or in any way imply that this Work is a product of Your 120 | own.
    4. 121 |
    5. The name of the Author may not be used to endorse or promote products derived from 122 | the Work without the prior written consent of the Author.
    6. 123 |
    7. You agree not to sell, lease, or rent any part of the Work. This does not restrict 124 | you from including the Work or any part of the Work inside a larger software 125 | distribution that itself is being sold. The Work by itself, though, cannot be sold, 126 | leased or rented.
    8. 127 |
    9. You may distribute the Executable Files and Source Code only under the terms of 128 | this License, and You must include a copy of, or the Uniform Resource Identifier 129 | for, this License with every copy of the Executable Files or Source Code You distribute 130 | and ensure that anyone receiving such Executable Files and Source Code agrees that 131 | the terms of this License apply to such Executable Files and/or Source Code. You 132 | may not offer or impose any terms on the Work that alter or restrict the terms of 133 | this License or the recipients' exercise of the rights granted hereunder. You 134 | may not sublicense the Work. You must keep intact all notices that refer to this 135 | License and to the disclaimer of warranties. You may not distribute the Executable 136 | Files or Source Code with any technological measures that control access or use 137 | of the Work in a manner inconsistent with the terms of this License.
    10. 138 |
    11. You agree not to use the Work for illegal, immoral or improper purposes, or on pages 139 | containing illegal, immoral or improper material. The Work is subject to applicable 140 | export laws. You agree to comply with all such laws and regulations that may apply 141 | to the Work after Your receipt of the Work. 142 |
    12. 143 |
    144 |
  10. 145 | 146 |
  11. Representations, Warranties and Disclaimer. THIS WORK IS PROVIDED 147 | "AS IS", "WHERE IS" AND "AS AVAILABLE", WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES 148 | OR CONDITIONS OR GUARANTEES. YOU, THE USER, ASSUME ALL RISK IN ITS USE, INCLUDING 149 | COPYRIGHT INFRINGEMENT, PATENT INFRINGEMENT, SUITABILITY, ETC. AUTHOR EXPRESSLY 150 | DISCLAIMS ALL EXPRESS, IMPLIED OR STATUTORY WARRANTIES OR CONDITIONS, INCLUDING 151 | WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF MERCHANTABILITY, MERCHANTABLE QUALITY 152 | OR FITNESS FOR A PARTICULAR PURPOSE, OR ANY WARRANTY OF TITLE OR NON-INFRINGEMENT, 153 | OR THAT THE WORK (OR ANY PORTION THEREOF) IS CORRECT, USEFUL, BUG-FREE OR FREE OF 154 | VIRUSES. YOU MUST PASS THIS DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE WORK OR DERIVATIVE 155 | WORKS. 156 |
  12. 157 | 158 |
  13. Indemnity. You agree to defend, indemnify and hold harmless the Author and 159 | the Publisher from and against any claims, suits, losses, damages, liabilities, 160 | costs, and expenses (including reasonable legal or attorneys fees) resulting from 161 | or relating to any use of the Work by You. 162 |
  14. 163 | 164 |
  15. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE 165 | LAW, IN NO EVENT WILL THE AUTHOR OR THE PUBLISHER BE LIABLE TO YOU ON ANY LEGAL 166 | THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES 167 | ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK OR OTHERWISE, EVEN IF THE AUTHOR 168 | OR THE PUBLISHER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 169 |
  16. 170 | 171 |
  17. Termination. 172 | 173 |
      174 |
    1. This License and the rights granted hereunder will terminate automatically upon 175 | any breach by You of any term of this License. Individuals or entities who have 176 | received Derivative Works from You under this License, however, will not have their 177 | licenses terminated provided such individuals or entities remain in full compliance 178 | with those licenses. Sections 1, 2, 6, 7, 8, 9, 10 and 11 will survive any termination 179 | of this License.
    2. 180 | 181 |
    3. If You bring a copyright, trademark, patent or any other infringement claim against 182 | any contributor over infringements You claim are made by the Work, your License 183 | from such contributor to the Work ends automatically.
    4. 184 | 185 |
    5. Subject to the above terms and conditions, this License is perpetual (for the duration 186 | of the applicable copyright in the Work). Notwithstanding the above, the Author 187 | reserves the right to release the Work under different license terms or to stop 188 | distributing the Work at any time; provided, however that any such election will 189 | not serve to withdraw this License (or any other license that has been, or is required 190 | to be, granted under the terms of this License), and this License will continue 191 | in full force and effect unless terminated as stated above. 192 |
    6. 193 |
    194 |
  18. 195 | 196 |
  19. Publisher. The parties hereby confirm that the Publisher shall 197 | not, under any circumstances, be responsible for and shall not have any liability 198 | in respect of the subject matter of this License. The Publisher makes no warranty 199 | whatsoever in connection with the Work and shall not be liable to You or any party 200 | on any legal theory for any damages whatsoever, including without limitation any 201 | general, special, incidental or consequential damages arising in connection to this 202 | license. The Publisher reserves the right to cease making the Work available to 203 | You at any time without notice
  20. 204 | 205 |
  21. Miscellaneous 206 | 207 |
      208 |
    1. This License shall be governed by the laws of the location of the head office of 209 | the Author or if the Author is an individual, the laws of location of the principal 210 | place of residence of the Author.
    2. 211 |
    3. If any provision of this License is invalid or unenforceable under applicable law, 212 | it shall not affect the validity or enforceability of the remainder of the terms 213 | of this License, and without further action by the parties to this License, such 214 | provision shall be reformed to the minimum extent necessary to make such provision 215 | valid and enforceable.
    4. 216 |
    5. No term or provision of this License shall be deemed waived and no breach consented 217 | to unless such waiver or consent shall be in writing and signed by the party to 218 | be charged with such waiver or consent.
    6. 219 |
    7. This License constitutes the entire agreement between the parties with respect to 220 | the Work licensed herein. There are no understandings, agreements or representations 221 | with respect to the Work not specified herein. The Author shall not be bound by 222 | any additional provisions that may appear in any communication from You. This License 223 | may not be modified without the mutual written agreement of the Author and You. 224 |
    8. 225 |
    226 | 227 |
  22. 228 |
229 | 230 |
231 |
232 | 233 | 234 | 235 | --------------------------------------------------------------------------------