Re: Fundamental question about visibility
Adding custom constructors for passing of desired objects works but is not
exactly an elegant solution.
I solved it with the suspected GetParent call:
((<DerivedClass >)GetParent()). <MemberName>
^
Returns base class!
....but I had to cast to the overidden class and NOT rely on C++ to know
this! I would've thought GetParent pointed to the new class and not the old
but maybe this is simply a MFC specific twist. One more lesson learned!
Thanks for the feedback,
Casper
----------
"WW" <wolof@freemail .hu> wrote in message
news:bkqp6e$c2n $1@phys-news1.kolumbus. fi...[color=blue]
> WW wrote:
> [SNIP]
> Update
>[color=green]
> > // Overide the CEdit class so we can capture CTRL + ENTER events
> > class CModifiedEdit : public CEdit
> > {
> > CMainWindow *parent;[/color]
>
> Here I hope a *lot* that CEdit does have a virtual destructor. In our[/color]
case[color=blue]
> it does not really matter (there is no descruction for a pointer and[/color]
Windows[color=blue]
> will release the memory properly) but according to Standard C++ it is[/color]
better[color=blue]
> be there. (Also in your code CMainWindow will always destroy[/color]
CModifiedEdit[color=blue]
> as CModifiedEdit, but later if you go dynamic about the GUI it might not[/color]
be[color=blue]
> the case.)
>[color=green]
> > public:
> > CModifiedEdit(C MainWindow *mamma) : parent(mamma) { ; }
> > afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
> > };[/color]
> [SNIP]
> --
> WW aka Attila
>
>[/color]
Adding custom constructors for passing of desired objects works but is not
exactly an elegant solution.
I solved it with the suspected GetParent call:
((<DerivedClass >)GetParent()). <MemberName>
^
Returns base class!
....but I had to cast to the overidden class and NOT rely on C++ to know
this! I would've thought GetParent pointed to the new class and not the old
but maybe this is simply a MFC specific twist. One more lesson learned!
Thanks for the feedback,
Casper
----------
"WW" <wolof@freemail .hu> wrote in message
news:bkqp6e$c2n $1@phys-news1.kolumbus. fi...[color=blue]
> WW wrote:
> [SNIP]
> Update
>[color=green]
> > // Overide the CEdit class so we can capture CTRL + ENTER events
> > class CModifiedEdit : public CEdit
> > {
> > CMainWindow *parent;[/color]
>
> Here I hope a *lot* that CEdit does have a virtual destructor. In our[/color]
case[color=blue]
> it does not really matter (there is no descruction for a pointer and[/color]
Windows[color=blue]
> will release the memory properly) but according to Standard C++ it is[/color]
better[color=blue]
> be there. (Also in your code CMainWindow will always destroy[/color]
CModifiedEdit[color=blue]
> as CModifiedEdit, but later if you go dynamic about the GUI it might not[/color]
be[color=blue]
> the case.)
>[color=green]
> > public:
> > CModifiedEdit(C MainWindow *mamma) : parent(mamma) { ; }
> > afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
> > };[/color]
> [SNIP]
> --
> WW aka Attila
>
>[/color]
Comment