From: Brad Gillepsie on
OK, something very strange is going on.



First, here is what DOES work. I put a button on a “main dialog” box,
and add an event so that a function is executed when the button is
clicked. So Visual Studio puts an association between the button and
the event handler function in the Message Map, adds the event handler
function to the *.cpp file, and adds the event handler prototype to
the *.h file. All of this works fabulously as you’d expect. When the
button is clicked, the event handler function is invoked.



Now, here is what DOESN’T work. On this same “main dialog” box, we
put a CTabCtrl object, and create two tabs. Each of these two tabs of
course has a borderless dialog box resource which provides content for
that tab. Each dialog box can be designed however we want them to be.



So I put another button on one of the tab-dialog boxes, and add the
event handler for when the button is clicked. This is done in EXACTLY
the same manner as the button added prior to this, on the “main
dialog” box. However, this doesn’t work. Clicking on the button does
not invoke the event handler. It doesn’t even change the button
graphics so that it looks like the button is being pushed. What am I
missing? The only difference between these two buttons is that one is
on a dialog box, call it dialog “A”, and the other is on a dialog box
(“B”) which is in turn providing content for a tab control which is
located on dialog “A”.



I am completely stumped and don’t know how to diagnose this problem.

Anything even a starting point might help. Thanks.
From: Joseph M. Newcomer on
On Mon, 18 Jan 2010 20:19:24 -0800 (PST), Brad Gillepsie <Webmaster(a)wSDFirm.com> wrote:

>OK, something very strange is going on.
>
>
>
>First, here is what DOES work. I put a button on a �main dialog� box,
>and add an event so that a function is executed when the button is
>clicked. So Visual Studio puts an association between the button and
>the event handler function in the Message Map, adds the event handler
>function to the *.cpp file, and adds the event handler prototype to
>the *.h file. All of this works fabulously as you�d expect. When the
>button is clicked, the event handler function is invoked.
>
>
>
>Now, here is what DOESN�T work. On this same �main dialog� box, we
>put a CTabCtrl object, and create two tabs. Each of these two tabs of
>course has a borderless dialog box resource which provides content for
>that tab. Each dialog box can be designed however we want them to be.
>
>
>
>So I put another button on one of the tab-dialog boxes, and add the
>event handler for when the button is clicked. This is done in EXACTLY
>the same manner as the button added prior to this, on the �main
>dialog� box. However, this doesn�t work. Clicking on the button does
>not invoke the event handler. It doesn�t even change the button
>graphics so that it looks like the button is being pushed. What am I
>missing? The only difference between these two buttons is that one is
>on a dialog box, call it dialog �A�, and the other is on a dialog box
>(�B�) which is in turn providing content for a tab control which is
>located on dialog �A�.
****
This does not make sense. The buttons of the child dialogs are handled in the child
dialogs. It was never intended that a button handler for a control in a child dialog be
handled in the parent dialog, so of course it doesn't work.

If you want to signal the parent dialog, you can do a SendMessage to the parent dialog
from the handler in the child dialog. But there is no mechanism that does this forwarding
automatically. And your expectation that such a mechanism exists is not based on
reasonable expectations.
****
>
>
>
>I am completely stumped and don�t know how to diagnose this problem.
****
Spy++ would have revealed what is happening. But the real diagnosis is that you were
expecting some kind of behavior that is not supported and was never intended to be
supported. It is certainly not documented as being supported, and there is nothing that
even hints that this is possible.
joe
****
>
>Anything even a starting point might help. Thanks.
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
From: Scott McPhillips [MVP] on
"Brad Gillepsie" <Webmaster(a)wSDFirm.com> wrote
>> Clicking on the button does
>> not invoke the event handler. It doesn�t even change the button
>> graphics so that it looks like the button is being pushed. What am I
>> missing?

Sounds like the button is disabled. Check its properties in the dialog
editor.

Another way this can happen is if your code is in an infinite loop. Do any
other elements of the GUI work?

--
Scott McPhillips [VC++ MVP]