hi and thx. the subclassing works now with a WH_CBT hook, but now i have problems to catch the WM_GETMINMAXINFO event (i get no output 'in').
maybe searching for the topwindow by the classname "CicMarshalWndClass" doesn't work. i tried it with GetParent() and GetAncestor(), but that dosent work too.
Code:
long oldwinproc;
LRESULT CALLBACK WndProcOverwrite(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam){ // the new window procedure
HANDLE hPipe = connectToPipe();
WritePipe(hPipe, "*"); /// subclassing works
if(msg == WM_GETMINMAXINFO){
WritePipe(hPipe, "in"); // !!!
((MINMAXINFO*)lParam)->ptMinTrackSize.x = 300;
((MINMAXINFO*)lParam)->ptMinTrackSize.y = 300;
CloseHandle(hPipe);
return DefWindowProc(hwnd, msg, wParam, lParam);
}
CloseHandle(hPipe);
return CallWindowProc((WNDPROC)oldwinproc, hwnd, msg, wParam, lParam );
}
LRESULT CALLBACK filterFunc(int nCode, WPARAM wParam, LPARAM lParam){ // WH_CBT hook
if (nCode == HCBT_CREATEWND){
HWND hwnd = (HWND)wParam;
if(getModule(hwnd, "notepad.exe")){
char wndClassname[STRLEN]; RealGetWindowClass(hwnd, wndClassname, STRLEN);
if(strstr(wndClassname, "CicMarshalWndClass")){
oldwinproc = SetWindowLongPtr(hwnd, GWLP_WNDPROC, (long)WndProcOverwrite);
}
}
}
return CallNextHookEx(g_hHook, nCode, wParam, lParam);
}