Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@kumatti1
Created March 2, 2014 00:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kumatti1/9299696 to your computer and use it in GitHub Desktop.
Save kumatti1/9299696 to your computer and use it in GitHub Desktop.
VBAでサブクラス化
#include <windows.h>
#include <Commctrl.h>
LRESULT CALLBACK SUBCLASSPROC(
HWND hWnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam,
UINT_PTR uIdSubclass,
DWORD_PTR dwRefData
){
#ifdef _M_AMD64
auto pDefSubclassProc = reinterpret_cast<decltype (DefSubclassProc)*>(0x1111111111111111);
auto VBA_PROC = reinterpret_cast<decltype (DefSubclassProc)*>(0x1111111111111111);
#else
auto pDefSubclassProc = reinterpret_cast<decltype (DefSubclassProc)*>(0x11111111);
auto VBA_PROC = reinterpret_cast<decltype (DefSubclassProc)*>(0x11111111);
#endif
UINT volatile OrgMsg = (UINT)0x11111111;
if(uMsg == OrgMsg)
{
VBA_PROC(hwnd, uMsg, wParam, lParam);
}
return pDefSubclassProc(hwnd, uMsg, wParam, lParam);
}
Option Explicit
Function CallFunc(ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As LongPtr
Debug.Print Hex$(hWnd)
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment