Re: MFC and c++ problems



There's a serious question of why it would ever make sense to have the subclass B ever
call any method of any class, let alone a method in class A.  This is incredibly poor
methodology, and should be avoided.  Touching any variable in class A is equally poor
design.

If control B needs to perform some action in its parent, it must do it by doing
GetParent()->SendMessage(...)
of some user-defined message that defines what should be done.  
				joe

On 1 Feb 2006 08:35:49 -0800, "Benry" <henrybg@xxxxxxxxx> wrote:

>Forgive me if I'm overlooking the obvious.  Basically, this is my
>problem:
>
>I have a derived Dialog:
>
>class A : public CDialog{
>}
>
>I have a derived CTreeCtrl:
>
>class B : public CTreeCtrl{
>}
>
>In A, there is an instance of B, as well as a bunch of other controls,
>which should contain information relating to the text for a tree item
>(HTREEITEM) in B.  The information is stored in an INI file.
>
>Ok, I can get some of the windows messages to work in B, but
>begindrag() does not work at all (I've checked the create() settings,
>and it's not the TVS_DISABLEDRAGDROP flag).
>
>Basically, my question is, how can I call A.method from B?  How can I
>change A.m_sStringVariable from B?  I have no problems doing this from
>A to B, as there is an instance of B in A....but vice versa?
>
>Thanks.
>Ben
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Re: MFC and c++ problems
    ... >>class A: public CDialog{ ... >>I have a derived CTreeCtrl: ... >>which should contain information relating to the text for a tree item ... > MVP Tips: http://www.flounder.com/mvp_tips.htm ...
    (microsoft.public.vc.mfc)
  • MFC and c++ problems
    ... Forgive me if I'm overlooking the obvious. ... class A: public CDialog{ ... I have a derived CTreeCtrl: ... which should contain information relating to the text for a tree item ...
    (microsoft.public.vc.mfc)