Help with SetWindowLong 
Author Message
 Help with SetWindowLong

Hello I have a question about the replacement long in the API call
SetWindowLong, I have a function defined like this:

LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
lParam);

This is the window proc I want to use:

LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
lParam)
{

Quote:
}

How do I get the LONG pointer to this function to use in my SetWindowLong??

Thanks for any help!!
Ken



Sat, 29 Jun 2002 03:00:00 GMT  
 Help with SetWindowLong

Quote:
>How do I get the LONG pointer to this function to use in my SetWindowLong??

Ken,

Just cast it:

lpfnOldWndProc = (FARPROC)SetWindowLong(hWnd,
                        GWL_WNDPROC, (LONG) WindowProc );

Dave
--
Address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow up email copies.
http://www.bj.co.uk



Sat, 29 Jun 2002 03:00:00 GMT  
 Help with SetWindowLong


Quote:
> Hello I have a question about the replacement long in the API call
> SetWindowLong, I have a function defined like this:

> LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
LPARAM
> lParam);

> This is the window proc I want to use:

> LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
LPARAM
> lParam)
> {

> }

> How do I get the LONG pointer to this function to use in my
>SetWindowLong??

Use the good old typecast trick. Basically you would call:

WNDPROC g_OldWndProc;

g_OldWndProc = SetWindowLong(hWnd,GWL_WNDPROC,(LONG)WindowProc));

Note that you will need to chain the old window proc using
CallWindowProc() and reset the window long when you are done.

Also, this approach will work only on windows created by your process,
and for other windows, you will need to use Windows hooks (which is a
better apporach anyway). Note that it's better to use thread specific
window hooks and avoid system wide hooks.

Atul

Sent via Deja.com http://www.deja.com/
Before you buy.



Sat, 29 Jun 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Q: SetWindowLong/GetWindowLong calls for ActiveX IE control

2. SetWindowLong with DWL_MSGRESULT: what for???

3. SetWindowLong

4. SetWindowLong

5. Subclassing CDialog with SetWindowLong(...)

6. changing list control styles -- SetWindowLong???

7. SetWindowLong not working

8. SetWindowLong and ES_NOHIDESEL

9. HELP HELP HELP HELP HELP HELP!!!

10. Use GWL_USERDATA + SetWindowLong/GetWindowLong or SetProp/GetProp to store user data???

11. Anyone know: SetWindowLong(GWL_WNDPROC) fails, causes ASSERT wincore.cpp line 392?

12. Why SetWindowLong cannot change the style of an edit box?

 

 
Powered by phpBB® Forum Software