Archived

This topic is now archived and is closed to further replies.

Shadowflare

C++ Windows Programming Question

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
...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...

Share this post


Link to post
Share on other sites