Skip to main content
gamedev.net
🔒 Locked

C++ Windows Programming Question

Started by Shadowflare Jul 27, 2002 at 8:52 AM 4 replies 1k views
Original Post
Shadowflare
Shadowflare
I have created a Button on my window, using CreateWindowEx(), and I need to change the WndProc that the Button uses. Is there any way to reset the WndProc? Or to remotely access and change the setting in the "Button" class? Any help is greatly appreciated.
VGASteve
VGASteve
Shadowflare,

Check out SetWindowLong() with the nIndex parameter as GWL_WNDPROC.

Hope this helps...
Shadowflare
Shadowflare
Thanks, this seems to be what I''m looking for, but how do I declare the pointer to my new WndProc to pass as dwNewLong?
CWizard
CWizard
Do you mean you want to change the window''s (=button) wndproc, after you''ve created it? Beats me why you want to do that, but anyhoo. What do you mean by how to declare the pointer? If you mean how you should cast it when calling SetWindowLong(), give it what it wants, probably (void *) or (ULONG). Perhaps you could explain better what you''re up to, and provide some code.
VGASteve
VGASteve
...Just found something I did once:

oldhandler = (WNDPROC)SetWindowLong( GetDlgItem( hwnd, IDC_PREVIEW ), GWL_WNDPROC, (LONG)thumbnail_2 );

oldhandler was a WNDPROC variable to store the address of the old handler subroutine, and the new handler was thumbnail_2().

In case you''re wondering, I was working with a control in a dialog box to generate a thumbnail preview for a graphics editor (hence the GetDlgItem() call)...

To answer your question more directly, all you''ve gotta do is typecast the function name to LONG.

Hope this helps...
Oluseyi
Oluseyi
quote:
Original post by CWizard
Beats me why you want to do that...

It''s called control subclassing and is standard practice to customize control behavior. VGASteve provides the solution.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.