Using Variant to Store Point
?
??????Variant is a very powerful data type to store 'any' data. With the help of COM class _variant_t, VARIANT bacomes very easy to use. But _variant_t dosen't support all kinds of data type, for example, point data with two or three elements. Variant can hold pointer, but the memory management becomes a stubborn problem when copying variant. I'm trying to find a better way to solve the problem, but I don't want to rewrite a variant. So,? dose the way exist?
??????Many UI-libs use variant to hold data of properties, such as BCGPControlBar, and they do support point displaying. Actually the point elements are formated to a string so that they be stored into one property. But it's very boring to parse values between points and variant, so it's a good idea to write a adapter for them. This adapter takes charge to format point data to string, extract point data from string, and ex-convert with _variant_t.
if we have a point class like this:
?















?
we can write our point adapter as following:
?















?
now, we can use the classes:
?



?