Re: Message Reflection
- From: "John Carson" <jcarson_n_o_sp_am_@xxxxxxxxxxxxxxx>
- Date: Tue, 14 Jun 2005 11:52:05 +1000
"Steve Thresher" <steve.thresher@xxxxxxxxxxxxxx> wrote in message news:ePXSC5EcFHA.3464@xxxxxxxxxxxxxxxxxxxx
"John Carson" <jcarson_n_o_sp_am_@xxxxxxxxxxxxxxx> wrote in message news:u0OBGHDcFHA.580@xxxxxxxxxxxxxxxxxxxxxxx"Steve Thresher" <steve.thresher@xxxxxxxxxxxxxx> wrote in message news:eLuyi5CcFHA.3808@xxxxxxxxxxxxxxxxxxxxCan anyone tell me how message reflection should be implemented or point me at a reference on the topic. I am NOT using MFC. I am attempting to custom draw a header control and need to know how to get the WM_NOTIFY message from the parent control to my window procedure for the header control. I can subclass the parent of the header control when it is created but what happens when you destroy the header control? The parent window is still sub-classed with no way to work out the address for the parents original window procedure. Any help would be greatly appreciated.
Steve.
I am puzzled by your question. When you subclass a window procedure, the address of the original window procedure is received as the return value of SetWindowLong. You need this address so you can call the original window procedure for those messages you don't choose to process. You can choose to remove the subclass when you destroy the header control for the sake of a slight efficiency gain, but it should continue to work if you just leave it there unless you have written it in some strange way. -- John Carson
You MUST NOT unsubclass a window on operating systems prior to XP / 2003 as you cannot guarantee that no-one else has subclassed the window; XP / 2003 provide functions to subclass / unsubclass a window.
You could presumably check (using GetWindowLong) if the current window
procedure is the one you set. If it is, then no-one else has subclassed it after you. If it isn't, you leave the subclass in place. Easier still, just leave it in place.
Also once the header control has been destroyed, so has the data attached to the window which includes the original window procedure address.
I am still puzzled.
MFC includes some kind of message relection technique which I was hoping to implement in pure Win32 code. I was just hoping someone would have some idea how to do it.
When it receives the WM_NOTIFY method, the parent checks the ID of the sender to see if it comes from the header control. If so, it calls
return SendMessage(((NMHDR)lParam).hwndFrom, message, wParam, lParam);
If you want reflection to every child control, you can skip the check.
-- John Carson
.
- Follow-Ups:
- Re: Message Reflection
- From: Steve Thresher
- Re: Message Reflection
- References:
- Message Reflection
- From: Steve Thresher
- Re: Message Reflection
- From: John Carson
- Re: Message Reflection
- From: Steve Thresher
- Message Reflection
- Prev by Date: Re: Hide main window, show dialog
- Next by Date: RE: How should I port my Win32 application to the Win64 platform??
- Previous by thread: Re: Message Reflection
- Next by thread: Re: Message Reflection
- Index(es):
Relevant Pages
|