Re: Channel 9 video: Visual C++ 10 is the new 6
"Doug Harrison [MVP]" <dsh@mvps.org> ha scritto nel messaggio
news:kffji49mvnhdgfgip4n0qephp24fau0b0b@4ax.com...
It wasn't the clock speed so much as it was memory.
Consider a vtbl with
(say) 1000 slots multiplied by several dozen derived classes in MFC alone,
[... interesting explanation...]
Thanks Doug and Joe for your insights and your time.
It does make lots of sense.
Every MFC programmer should be able to describe what's wrong with the
following and how to fix it:
MyListBox c_lb;
...
CListBox& lb = c_lb;
lb.InsertString(...);
I think that the problem here is that CListBox::InsertString() is not
virtual, so lb.InsertString() actually calls CListBox::InsertString()
instead of the derived class MyListBox::InsertString() implementation.
I would solve that overriding CWnd::WindowProc that is *virtual* in
MyListBox class, and process LB_INSERTSTRING in this override of WindowProc,
something like this following:
<code>
LRESULT MyListBox::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
switch( message )
{
case LB_INSERTSTRING:
TRACE("Processing MyListBox::LB_INSERTSTRING message; Index = %d,
String = %s\n", wParam, (LPCTSTR)lParam);
break;
}
return CListBox::WindowProc(message, wParam, lParam);
}
</code>
Is this what you had in mind?
Or is there a better solution?
(Or am I wrong?)
Thanks,
Giovanni