Cheers, works great. I actually applied a similar principle back at the beginning of this ordeal. The actual window procedure, which I've nearly forgotten about, uses a static declaration to retain the previous window procedure address:
Code:
LRESULT CALLBACK ListProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
static WNDPROC oldProc;
switch (msg)
{
case (WM_USER+1):
if ( (wParam==1) && (lParam) )
oldProc=(WNDPROC)lParam;
if ( (wParam==2) && (!lParam) )
SetWindowLong(hwnd,GWL_WNDPROC,(LONG)oldProc);
case WM_LBUTTONUP:
MessageBox(NULL,"YO BUTTON CLICKED","NOTIFY",MB_OK);
break;
default:
break;
}
return CallWindowProc(oldProc,hwnd,msg,wParam,lParam);
}
BOOL SubClass(HWND hSub,WNDPROC lpfnWndProc)
{
WNDPROC oldProc;
oldProc=(WNDPROC)SetWindowLong(hSub,GWL_WNDPROC,(LONG)lpfnWndProc);
SendMessage(hSub,WM_USER+1,1,(LPARAM)oldProc);
return TRUE;
}
BOOL WINAPI DllMain(HANDLE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)
{
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
{
MessageBox(NULL,"Dll loaded","Notify",MB_OK);
HWND hList;
hList=FindListView();
SubClass(hList,ListProc);
}
case DLL_PROCESS_DETACH:
{
HWND hList;
hList=FindListView();
SendMessage(hList,WM_USER+1,2,0);
}
default:
break;
}
return TRUE;
}
What do you think of that code? I couldn't figure out a better way to do it.