Re: Message Reflection



"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@xxxxxxxxxxxxxxxxxxxx
Can 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

.



Relevant Pages

  • Re: Message Reflection
    ... 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. ... The parent window is still sub-classed with no way to work out the address for the parents original window procedure. ... 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. ...
    (microsoft.public.win32.programmer.ui)
  • Re: Trapping Listview column changes
    ... possible goals and each has a different way of achieving that goal. ... If you want to prevent resizing of columns, subclass the header control ... send the ListView an LVM_GETHEADER message. ... You need to subclass the Listview and handle a WM_NOTIFY message. ...
    (microsoft.public.vb.general.discussion)
  • Message Reflection
    ... Can anyone tell me how message reflection should be implemented or point me ... the parent control to my window procedure for the header control. ...
    (microsoft.public.win32.programmer.ui)
  • Re: Connecting own header control to dynamically created list control
    ... If a list control is statically created I can overwrite PreSubclassWindow and subclass my header control there. ...
    (microsoft.public.vc.mfc)
  • How to use different imagelist in header control and CListView?
    ... Later I found that the imagelist of the header control is changed to the one ... I set for the CListView. ... the Header control imagelist will be set to the same as its parent ... CListCtrl. ...
    (microsoft.public.vc.mfc)