Re: Message Reflection




"John Carson" <jcarson_n_o_sp_am_@xxxxxxxxxxxxxxx> wrote in message
news:%23S8AgPIcFHA.132@xxxxxxxxxxxxxxxxxxxxxxx
> "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
>

I've been giving the problem a bit more thought and have decided to try and
use a message hook instead. When I receive a WM_NOTIFY message I will pass
it to the child control and if it's not handled I will allow it to go
through to the parent control.

Thanks for trying to help.

Steve.


.



Relevant Pages

  • Re: ? Create Not Called in Dialog for Subclassed Control
    ... So a control which does not will cause an assertion ... you could ideally have PreSublcassWindow PostMessage a notice to the window that ... It is created before it is bound to a subclass, and the behavior cannot be monitored until ... kernel object represented by an HWND, ...
    (microsoft.public.vc.mfc)
  • Re: Unicode Button in VB6
    ... "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal ... know how to subclass my window to avoid to conversion Unicode -> Ansi. ... You are subclassing a window by replacing the original window procedure ...
    (microsoft.public.vb.winapi)
  • Re: Unicode Button in VB6
    ... (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) ... know how to subclass my window to avoid to conversion Unicode -> Ansi. ... You are subclassing a window by replacing the original window procedure ...
    (microsoft.public.vb.winapi)
  • Re: The memory could not be "read". Application Crash??
    ... Basically, this control handles all the ... lpPrevWndProc variable for every window subclassed (notice I said window and not ... you can subclass all of them as needed), and see what all is really happening, ... The subclass control allows you to subclass and still set breakpoints in your ...
    (microsoft.public.vb.enterprise)
  • Re: The memory could not be "read". Application Crash??
    ... Basically, this control handles all the ... lpPrevWndProc variable for every window subclassed (notice I said window and not ... you can subclass all of them as needed), and see what all is really happening, ... The subclass control allows you to subclass and still set breakpoints in your ...
    (microsoft.public.vb.general.discussion)