Take out the R, G, and B components of the backcolor, subtract each from
255, and use those new R, G, and B values for the forecolor. This works
almost all the time, except when the backcolor is close to the middle of the
range for the three components (128,128,128). In this problem case the
forecolor comes out about the same as the backcolor. So if you use this
technique, test for that case and do something different such as choosing an
arbitrary contrasting color.
Tom Dacon
Dacon Software Consulting