Ebdon.Net

Web Log/Year2004/February/February26

Front Page | Recent Changes | Title Index | Amateur Radio | Software Development
» Web Log/Year2005/October/October17 » Love Is The Killer App » Cplus Plus » Front Page » Web Log/Year2004/February/February26

26th February 2004

Fun and Games with Visual Studio

Today I've been fixing an interesting little C++ problem. I had a radio group class containing a number of buttons, where the buttons forwarded the got and lost focus messages onto their parent control (the radio group) for processing. The group control then triggers the appropriate script events in an attached ECMAScript. This all has been in production for years, but I stumbled across a slight problem when testing a fix for another problem.

When moving between buttons in the same group, the following events are generated:

Obviously the first two events are redundant in this instance. But how to get rid of them? I settled on a scheme where the parent keeps a list of buttons in a std::vector, then uses std::find_if() to check whether the other control for the event is in the vector, if so the event is ignored. So far so good, all pretty simple stuff. But getting the find_if() to work was very irritating. I was comparing a HWND to a class derived from CWnd, so the predicate has to do the equivalent of:
otherHwnd == someCwnd->GetSafeHwnd()
Being too clever for my own good, and not wanting to write a trivial predicate, I decided to use the Boost Lambda Library (BLL). This is a really superb library, I strongly suggest you down-load it from the boost web site. In theory this allows me to write code like this:
it = find_if( buttons.begin(), buttons.end(), _1->GetSafeHwnd() == otherHwnd );
That's the theory, Unfortunately it doesn't work; at least not in Visual Studio 6, which generates a fatal internal compiler error as soon as I #include lamda.hpp. Argh! This is a VC++ 6 bug, and this project is tied to VC++ 6 by a third partly library.
 Posted by Terry Ebdon | Permalink |
 File under: Category Software Development, Category Blog Entry

|

Front Page | Recent Changes | Title Index | Amateur Radio | Software Development
Print this page
Find page by browsing, searching or an index
Edited October 17, 2005


Copyright (c) Terry Ebdon, all rights reserved.
Valid XHTML 1.0!Valid CSS![Valid RSS]