Tech Support > Microsoft Windows > Development Resources > button subclassing
button subclassing
Posted by Tom on January 31st, 2007


He

How properly make 'subclassing' of a button?



If I have only one button everything is OK, but when I subclass more then
one button pressing one make that another is also shown as pressed.

VC++ .NET (WIN32)



oldproc = (WNDPROC)SetWindowLong(hwnd, GWL_WNDPROC, (LPARAM)ButtonProc);
SetWindowLong(hwnd, GWL_USERDATA, (LPARAM)oldproc);
static LRESULT CALLBACK ButtonProc(HWND hwnd, UINT msg, WPARAM wParam,
LPARAM lParam);
I am changing messages:
case WM_PAINT:
case WM_LBUTTONDBLCLK:
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:

t.




Posted by Sten Westerback \(MVP SDK\) on January 31st, 2007



"Tom" <ee@w.e> wrote in message news:epphmt$dl8$1@nemesis.news.tpi.pl...
Is it always just one other that is changed. Are there pairs or is it
perhaps a random one?

I would guess that your processing of WM_LBUTTON* messages and/or WM_PAINT
is somewhat flawed.
Perhaps you don't use the HWND passed to the callback but some local or
global variable that isn't containing the value you think.

Also, are you sure you call CallWindowProc() everywhere? I assume you didn't
use SetClassLong accidentally....

- Sten



Posted by r_z_aret@pen_fact.com on January 31st, 2007


On Wed, 31 Jan 2007 08:45:09 +0100, "Tom" <ee@w.e> wrote:

Are you using the same ID for multiple buttons? That can certainly
cause problems for some code.


-----------------------------------------
To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).

Robert E. Zaret, eMVP
PenFact, Inc.
20 Park Plaza, Suite 478
Boston, MA 02116
www.penfact.com


Similar Posts