From: Oliver Regenfelder on
Hello,

Like stated in a recent discussion most CWnd derived stuff
you should use as non pointer member variables.

But how about the CToolTipCtrl? The examples I found on
the MSDN pages typically use it via a pointer, see:

http://msdn.microsoft.com/en-us/library/dftahdhz%28VS.90%29.aspx

with the object being allocated in the OnInitDialog and deallocated
in the constructor.

Is there a reason the CToolTipCtrl is not used via a non pointer
member variable or would that be the better way?

Best regards,

Oliver
From: Goran on
On Apr 23, 9:43 am, Oliver Regenfelder <oliver.regenfel...(a)gmx.at>
wrote:
> Hello,
>
> Like stated in a recent discussion most CWnd derived stuff
> you should use as non pointer member variables.
>
> But how about the CToolTipCtrl? The examples I found on
> the MSDN pages typically use it via a pointer, see:
>
> http://msdn.microsoft.com/en-us/library/dftahdhz%28VS.90%29.aspx
>
> with the object being allocated in the OnInitDialog and deallocated
> in the constructor.
>
> Is there a reason the CToolTipCtrl is not used via a non pointer
> member variable or would that be the better way?

I would guess that there is no reason. I have a tool tip that I simply
embed in my CWnd-derived class and it's fine. Ask good MSDN
people :-)...

But normally, MSDN examples aren't to be taken lightly - they are
often poorly written, error handling is approximate, some don't work
at all. I almost never use any of them without massive scrutiny. They
are informative in the line of explaining what to do in general,
though. Examples, what more does one want :-)?

Goran.
From: Joseph M. Newcomer on
See below...
On Fri, 23 Apr 2010 06:23:38 -0700 (PDT), Goran <goran.pusic(a)gmail.com> wrote:

>On Apr 23, 9:43�am, Oliver Regenfelder <oliver.regenfel...(a)gmx.at>
>wrote:
>> Hello,
>>
>> Like stated in a recent discussion most CWnd derived stuff
>> you should use as non pointer member variables.
>>
>> But how about the CToolTipCtrl? The examples I found on
>> the MSDN pages typically use it via a pointer, see:
>>
>> http://msdn.microsoft.com/en-us/library/dftahdhz%28VS.90%29.aspx
>>
>> with the object being allocated in the OnInitDialog and deallocated
>> in the constructor.
>>
>> Is there a reason the CToolTipCtrl is not used via a non pointer
>> member variable or would that be the better way?
>
>I would guess that there is no reason. I have a tool tip that I simply
>embed in my CWnd-derived class and it's fine. Ask good MSDN
>people :-)...
>
>But normally, MSDN examples aren't to be taken lightly - they are
>often poorly written, error handling is approximate, some don't work
>at all. I almost never use any of them without massive scrutiny. They
>are informative in the line of explaining what to do in general,
>though. Examples, what more does one want :-)?
****
The MSDN examples, though often *informative*, rarely if ever represent "best practice".
My personal belief is that these are given as assignments to summer interns, who have just
finished a 1-week course in "Windows Programming" followed by a 1-week course in "MFC
programming". I'm convince some of these people also had to take a 1-week "introduction
to C++" course. There is no supervision of what they have written, there is no quality
control, and I had one client who lost over a million dollars of investment (and an entire
product) because they relied on the horrible multithreaded-network-interface example,
which was written by someone who did not understand network programming, thread
programming, OR MFC. I finally got that example killed off.

So anything they say about "style" is suspect, almost anything they try to teach about how
to use C++ or MFC is a little bit suspect, and sometimes they don't even get the APIs
right when they are trying to teach something about raw Win32 API programming.

Overall, you will get no support if you try to claim "but the MSDN example did it this
way!", and more likely, I will have to write an essay about why some MSDN article was
written by someone whose competence to program was probably marginal at best.
joe
****
>
>Goran.
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
From: DanB on
Oliver Regenfelder wrote:
> Hello,
>
> Like stated in a recent discussion most CWnd derived stuff
> you should use as non pointer member variables.
>
> But how about the CToolTipCtrl? The examples I found on
> the MSDN pages typically use it via a pointer, see:
>
> http://msdn.microsoft.com/en-us/library/dftahdhz%28VS.90%29.aspx
>
> with the object being allocated in the OnInitDialog and deallocated
> in the constructor.
>
> Is there a reason the CToolTipCtrl is not used via a non pointer
> member variable or would that be the better way?

I don't know of these methods. From my experience, the best why is to
just handle the 'Afx' tool tips, (if this is the right way to say it)

ON_NOTIFY_EX( TTN_NEEDTEXT, 0, OnToolTip )

BOOL CModelsDlg::OnToolTip( UINT id, NMHDR * pNMHDR, LRESULT * pResult )
{
return tipData.DisplayTipText( pNMHDR );
}

From there I return what is in my xml according to the ID. (Of course I
parse the source to numbers for run time from my resource.h)

But this makes it easy to maintain your tips for language releases, ease
of editing/spelling, formatting like chars per line, etc...

Just thought I'd mention it.

Best, Dan.