[comp.windows.ms.programmer] C++ vs. Windows

ronb@burklabs (Ron Burk ) (05/20/91)

Turbo Pascal for Windows (TPW), in addition to C++-style virtual methods,
supplies "dynamic" methods.  These seem to be an attempt to deal with
cases where you inherit a large number of virtual functions but generally
only override a few.  Rather than giving you yet another copy of that large
virtual function table, dynamic methods do a search through a list at
runtime to find the right method.  If you only overrode a few functions,
the list should be much smaller than the virtual function table.  I am
lying about some of this, but I believe the gist is correct.

My question is for folks who use any of the various C++ class libraries
for windows.  How do they deal with the large number of window messages?
Do they bite the bullet and define each message as a virtual function?
To they decide on a subset of messages that they deem important enough
to be virtual functions?

whisd@sersun1.essex.ac.uk (Whiteside S D B) (05/31/91)

Reply to: question about handling messages in C++ vs. TPW's "dynamic" methods

I use my own C++ library for windows and deal with messages in the following way:

I have the derived class declare a static array of pairs: <windows message><member function>

The array contains only those messages a derived class is interested in responding to. 

The "top-level" class, I call it "window", has a WndProc loop that received messages and
checks in the array whether the derived class wishes to receive them. If so it calls
the function specified in the array.

I use a technique called "bloom filtering" to decide whether the message received by WndProc
is in the array. This is a technique used, for example, by Credit Card companies when
checking if a card number is in a "wanted" list.

The technique has a high success rate, so the system performance is not degraded too much.

Hope the above is suggestive!

Regards,

Simon Whiteside