For Programmers: Free Programming Magazines  


Home > Archive > VC Language > November 2005 > catching messages for control in dialog









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author catching messages for control in dialog
Steve

2005-11-23, 7:04 pm

I am creating a dialog without MFC and have run into yet another problem.
When I make my call to DialogBoxParam() to create and show the dialog, I
supply it with a function that will handle the messages from the dialog.
This has been working fine and things are coming along, until... I wanted to
catch mouse messages for my list view that is in the dialog. If I click
anywhere else in the dialog, I can catch the button down message, but if I
click in the list view area, the message is not sent to the function. Where
is it sent?

I can only supply one DLGPROC so I'm not sure what to do at this point.
Anyone have any ideas?

Thanks,
Steve


Igor Tandetnik

2005-11-23, 7:04 pm

Steve <sss@sss.com> wrote:
> I am creating a dialog without MFC and have run into yet another
> problem. When I make my call to DialogBoxParam() to create and show
> the dialog, I supply it with a function that will handle the messages
> from the dialog. This has been working fine and things are coming
> along, until... I wanted to catch mouse messages for my list view
> that is in the dialog. If I click anywhere else in the dialog, I can
> catch the button down message, but if I click in the list view area,
> the message is not sent to the function. Where is it sent?


To the list view control of course. It's a window in its own right, with
its own window proc.

You can handle NM_CLICK notification (sent in the form of WM_NOTIFY
message). The control sends this and other notifications to its parent
window - in this case, your dialog.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


Doug Harrison [MVP]

2005-11-23, 7:04 pm

On Wed, 23 Nov 2005 10:11:48 -0800, "Steve" <sss@sss.com> wrote:

>I am creating a dialog without MFC and have run into yet another problem.
>When I make my call to DialogBoxParam() to create and show the dialog, I
>supply it with a function that will handle the messages from the dialog.
>This has been working fine and things are coming along, until... I wanted to
>catch mouse messages for my list view that is in the dialog. If I click
>anywhere else in the dialog, I can catch the button down message, but if I
>click in the list view area, the message is not sent to the function. Where
>is it sent?
>
>I can only supply one DLGPROC so I'm not sure what to do at this point.
>Anyone have any ideas?


The message is posted to the listview control. To intercept it, you'll have
to subclass the control by replacing its WNDPROC. See here for explanation
and links to documentation:

Safer subclassing
http://blogs.msdn.com/oldnewthing/a...1/11/55653.aspx

--
Doug Harrison
Visual C++ MVP
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com