Jack
2008-03-30 17:22:35 UTC
Hi, I have a subclassed editbox which works fine. I want to run the same
code on several editboxes in the dialog (code below).
I use the handle returned by the subclassing SetWindowLong() in the
subclassed procedure.
But when I create a second subclass on another editbox the returned handle
is different so the subclassed procedure gets confused (I presume).
How can I set things up so that I can use the same subclass procedure code?
I thought about saving each WNDPROC and passing it in each time the
subclass is called via a Sendmessage() return code but I presume there is a
cleaner way.
Will someone let me in on the secret? :) TIA.
PS do I have to unhook the procedure for each subclassed editbox when I exit
the popup dialog on which it resides or will things be cleaned-up
automatically on dialog exit?
~~~~~~~~~
With the first control I do this:
WNDPROC lpfnOrigEBGenericAmount ;
lpfnOrigEBGenericAmount = (WNDPROC) SetWindowLong (hWndEdit1, GWL_WNDPROC,
(LONG) EBSubclassGenericProcAmount);
LRESULT CALLBACK EBSubclassGenericProcAmount(HWND hWnd, UINT uMsg, WPARAM
wParam, LPARAM lParam){
switch (uMsg)
{
####
}
return CallWindowProc(lpfnOrigEBGenericAmount , hWnd, uMsg, wParam,
lParam);
}
code on several editboxes in the dialog (code below).
I use the handle returned by the subclassing SetWindowLong() in the
subclassed procedure.
But when I create a second subclass on another editbox the returned handle
is different so the subclassed procedure gets confused (I presume).
How can I set things up so that I can use the same subclass procedure code?
I thought about saving each WNDPROC and passing it in each time the
subclass is called via a Sendmessage() return code but I presume there is a
cleaner way.
Will someone let me in on the secret? :) TIA.
PS do I have to unhook the procedure for each subclassed editbox when I exit
the popup dialog on which it resides or will things be cleaned-up
automatically on dialog exit?
~~~~~~~~~
With the first control I do this:
WNDPROC lpfnOrigEBGenericAmount ;
lpfnOrigEBGenericAmount = (WNDPROC) SetWindowLong (hWndEdit1, GWL_WNDPROC,
(LONG) EBSubclassGenericProcAmount);
LRESULT CALLBACK EBSubclassGenericProcAmount(HWND hWnd, UINT uMsg, WPARAM
wParam, LPARAM lParam){
switch (uMsg)
{
####
}
return CallWindowProc(lpfnOrigEBGenericAmount , hWnd, uMsg, wParam,
lParam);
}