Overloading the PROGRESS_CLASS window class.

Overloading the PROGRESS_CLASS window class.

Post by David Olss » Thu, 31 Mar 2005 18:20:57


I'm working on an application where I would like to overload some of the
windows classes provided by Windows. These are the window classes for
"BUTTON" and for PROGRESS_CLASS (i.e. progress bar controls). Everything
works fine for the BUTTON class but I fail to overload the
PROGRESS_CLASS window class.

This is how I do it; first I call InitCommonControlsEx() to load the
progress bar control. Next, I create the window class I will use for my
overloaded progress bar control:

WNDCLASSEX wc;
GetClassInfoEx(0, PROGRESS_CLASS, &wc);
wc.lpfnWndProc = myWindowProc;
wc.hInstance = GetModuleHandle(0);
wc.lpszClassName = TEXT("MyProgressBar");
RegisterClassEx(&wc);

I then create a window using this window class and this works perfectly
fine. It is however in my window proc (myWindowProc()) things get weird.
At some messages I do some custom things. I do however call
PROGRESS_CLASS' original window proc for every message that arrives to
the window proc. I end each type of message with the following (or
something very similar):

WNDCLASSEX wc;
GetClassInfoEx(0, PROGRESS_CLASS, &wc);
return(CallWindowProc(wc.lpfnWndProc, hWnd, uMsg, wParam, lParam));

The problem is that the pointer in wc.lpfnWndProc doesn't seem to be a
valid pointer (a call to IsBadCodePtr() confirms that it is invalid).
What am I doing wrong? The same thing works when I overload the BUTTON
class. Any suggestions greatly appreciated!

Best regards
David Olsson
 
 
 

Overloading the PROGRESS_CLASS window class.

Post by Christian » Thu, 31 Mar 2005 20:48:02


You must save the old WndProc and call it in the new one.
BTW, this is called superclassing...

 
 
 

Overloading the PROGRESS_CLASS window class.

Post by David Olss » Thu, 31 Mar 2005 20:56:21

Christian ASTOR skrev:


Oh right! I knew I wasn't using the correct terminology but I just
couldn't remember what it was called. :-)

Does it matter if I save the old window proc or fetch it every time I
need it (which is what I currently do)? It seems to me it shouldn't
matter and it appears to not. I get the same bad pointer either way.

Best regards
David Olsson