Simple Text Animation effects using Kerning Changing character spacing using the GDI APIs  This article demonstrates how to create an basic text animation by modifying the character spacing using Kerning. Kerning describes the spacing between characters when a font is written out. By default, fonts have a preset default kerning, but this very easy to modify under the Win32 API. The following (rather unusally named?) API function is all you need:
Private Declare Function SetTextCharacterExtra Lib "gdi32"
(ByVal hdc As Long, ByVal nCharExtra As Long) As Long
By setting nCharExtra to a negative value, you bring the characters closer together, and by setting to a positive values the characters space out. It works with VB's print methods too. Download the sample to see this used in an 'accelerator' animation effect using DrawText. In the animation the characters pull together from the right hand side, squash together and then slide out to their default positions. Could be pretty neat in an About Box, I think. By playing about with it you should be able to create some wicked animated boxes where the text is continually dancing in and out! |