Reputation: 1315
I need to get the current WndProc
with its messages and configuration and add my own code to it. Why do I need this? Because I'm working under an IDE that defines a window (and its children controls) with a WndProc
, and I need to modify it because It contains all the actions related with every control. If I point a control to a custom WndProc
the control loses all the actions and configuration set by the IDE. Suggestions?
Scheme:
HWND button; //My Button
LONG_PTR wndProc = GetWindowLongPtr(button, GWL_WNDPROC); //Getting the WndProc
wndProc -> Get this `WndProc` source code
LRESULT CALLBACK WndProcedure(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam){
wndProc (all the data);
+ my messages
}
Upvotes: 2
Views: 2085
Reputation: 12235
You can't get source code of "old" WndProc of course, but you can call it using CallWindowProc() in your new wnd proc. Check out this article:
Quote:
... your subclass function should go something like this:
wndProcOrig = (WNDPROC)SetWindowLongPtr(hwndButton, GWLP_WNDPROC, (LONG_PTR)SubclassWndProc); LRESULT CALLBACK SubclassWndProc(HWND hwnd, UINT wm, WPARAM wParam, LPARAM lParam) { switch (wm) { ... default: return CallWindowProc(wndprocOrig, hwnd, wm, wParam, lParam); } }
Upvotes: 2