SubClassing BUTTON class

Hello,

I want to subclass the system Button class (not MFC), so far I just changed the callback of all the button windows in a dialog to a new callback of my own, which handels WM_PAINT, and then callls the controls orignal WNDPROC function.

I can get the class WndClass structure of the systems Button class and and get its default WNDPROC function, but I don't know if I can reregister it so I won't have to use the method which I'm using now. It will be better that way since I won't have to get each control WNDPROC and store it...

In general my current problam is to get the control state, and by state I mean each of the button appearance which I think are: Normal, Pressed, Highlighted, focused and disabled (XP style ....)

So far I monitored the state of the control because the control doesnt notify when it redraws itself after changing state,
I monitored its state using WM_MOUSEMOVE, WM_LBUTTONDOWN and alll related messages but that just like making a new control and not subclassing one...

So how should I do it?
I'm not using MFC, and I don't plane to right now.
The prefect case of end result i'm looking for, is just to load a dialog, and every Button in the dialog template will be subclassed automaticly (i just specify the global images used in the button class)

Thanks ahead.
[1399 byte] By [SSkillZ] at [2007-11-20 9:47:38]
# 1 Re: SubClassing BUTTON class
I want to subclass the system Button class (not MFC), so far I just changed the callback of all the button windows in a dialog to a new callback of my own, which handels WM_PAINT, and then callls the controls orignal WNDPROC function.
Understood.

I can get the class WndClass structure of the systems Button class and and get its default WNDPROC function,
You are now talking about what is called global subclassing.
but I don't know if I can reregister it so I won't have to use the method which I'm using now. It will be better that way since I won't have to get each control WNDPROC and store it...
This is not clear. Can you elaborate on this ?
In general my current problam is to get the control state, and by state I mean each of the button appearance which I think are: Normal, Pressed, Highlighted, focused and disabled (XP style ....)

So far I monitored the state of the control because the control doesnt notify when it redraws itself after changing state,
I monitored its state using WM_MOUSEMOVE, WM_LBUTTONDOWN and alll related messages but that just like making a new control and not subclassing one...
Fair enough. But, that is the way to do what you want to achieve. You may be right that, a button class is not even required. But think about other things like tabbing through controls, having hot keys for the controls, using space bar to place focus on a button and such. These come with the BUTTON class. So, if you need this, subclassing is still the way to go, else , you are better off writing your own class.
kirants at 2007-11-9 13:31:37 >
# 2 Re: SubClassing BUTTON class
Thanks for the reply.
Now I know the name "global subclassing", ill search on that for more info.
I was hoping to globaly subclass every WM_PAINT of any Button control, and just to draw the state of the control :(, the problam is the Button class redraws itself on click and not what I was hoping: changes its state and call WM_PAINT.
SSkillZ at 2007-11-9 13:32:37 >