I have been reading the MSDN documentation on subclassing and I have been successful in handling events in a subclass
My issue is with passing messages back to the original WndProc.
As an example, if I have a window, with a sub-classed groupbox control and a button as a child of that groupbox, I want to handle the button event in the original window procedure, not the subclassed groupbox procedure.
Essentially, I want an empty subclass procedure:
LRESULT FAR PASCAL SubClassFunc(HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{
return CallWindowProc(oldProc, hwnd, uMsg, wParam, lParam);
}
Where oldProc is:
FARPROC oldProc = (FARPROC)SetClassLong(group_box, GCL_WDPROC, (DWORD)SubCLassFunc);
And where the window and groupbox and button are:
HWND window = CreateWindowEx(
WS_EX_WINDOWEDGE,
appname,
TEXT("Subclass Test"),
WS_VISIBLE |WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
300,
400,
NULL,
NULL,
hInstance,
0);
HWND group_box = CreateWindowEx(
0,
TEXT("BUTTON"),
TEXT("Group Box"),
WS_CHILD | WS_VISIBLE | BS_GROUPBOX,
8,
8,
275,
350,
window,
NULL,
hInstance,
0);
HWND push_button = CreateWindowEx(
0,
TEXT("BUTTON"),
TEXT("Push Button"),
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | BS_VCENTER,
50,
100,
100,
25,
group_box,
(HMENU)PUSH_BUTTON,
hInstance,
0);
I can handle the button events in the SubClassFunc, but what I want to do is pass them back to the window WndProc. It seems that CallWindowProc isn't doing this, or I may be totally wrong in how CallWindowProc works.