How kallunwillock/ezpzmousecontroller works
Project type and purpose
• This is a VBA-based library (with a demo Excel workbook) for capturing MouseWheel and other mouse events in UserForms and controls, using the Microsoft Tablet PC InkCollector COM object instead of subclassing or Win32 API calls.
• The demo workbook (EZPZMouseController_Demo.xlsm) shows how to integrate and exercise the library, and the src folder contains the actual VBA code (UserForm definitions and modules).
File structure
• Top‐level files:
• EZPZMouseController_Demo.xlsm – the Excel/VBA demo
• LICENSE, README.md – project metadata
• src/ – the VBA source code tree
• Inside src/:
• frmMouse_Wheel.frm (+ .frx) – a UserForm demonstrating wheel capture
• frmMouse_Windowless.frm (+ .frx) – a UserForm showing “windowless” capture technique
• modMisc.bas – utility routines (e.g., reference‐adding function)
• modTaskBox.bas – routines for UI tasks (e.g., grouping controls, dynamic binding)
• No build scripts or external deployment; simply import into an Excel VBA project.
Key insights from the README
• Core dependency: Microsoft Tablet PC Type Library (InkObj.dll)
• Architecture: VBA UserForms ↔ InkCollector COM objects ↔ Windows mouse event stream
• Demo code illustrating initialization, event‐interest settings, and handler implementations.
a. Main components:
1. Excel Host Application
2. VBA Project Container
‑ UserForms (frmMouse_Wheel, frmMouse_Windowless)
‑ Code Modules (modMisc, modTaskBox)
3. InkCollector COM Object (from Microsoft Tablet PC Type Library)
4. Windows OS Input Subsystem (raw mouse events)
5. Developer/User Code (event handlers inside UserForms)
b. Relationships & Data Flow:
• The Windows OS generates mouse events → InkCollector (registered as a COM event sink)
• InkCollector raises VBA events (IC_MouseWheel, IC_MouseDown, etc.)
• VBA event handlers in the UserForm modules receive event arguments (Delta, X, Y, Shift)
• Handlers invoke code in modTaskBox or modMisc to perform scrolling, UI updates, or repositioning controls
c. Architectural patterns & principles:
• Event‐driven pattern (InkCollector events callback into VBA handlers)
• Separation of demonstration (UserForms) vs. utility code (modules)
• Dependency injection by setting IC.hWnd at runtime to attach to specific control windows
d. Key technologies:
• VBA UserForms (.frm/.frx)
• COM interop via InkCollector (MSINKAUTLib)
• Excel VBA host
Detail level & essential elements
• UserForm separately, showing the WithEvents IC As InkCollector declaration.
• ModMisc’s AddMSInkReference as the setup step.
• Fact that multiple InkCollector instances can be bound to different hWnds (frame controls vs. whole form).
• Don’t over‐partition: group similar modules together, but call out distinctive responsibilities (event binding vs. UI logic).
– The layering (Windows → COM → VBA → Excel UI)
– The separation of library vs. demo code
– The key flow of mouse events from OS to your VBA handlers
– How a consumer would integrate and extend the library in their own VBA projects.