The new vbAccelerator Site - more VB and .NET Code and Controls
Source Code
3 Code Libraries Source Code &nbsp


NOTE: this code has been superceded by the version at the new site.



&nbsp

Simple but Effective Text Animation effects using Kerning

Attempt to show text animation in a non-animated picture...

Download the Text Effect Demonstration (9kb)

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"
&nbsp &nbsp (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!

Back to top

Back to Source Code Overview

&nbsp

AboutContributeSend FeedbackPrivacy

Copyright 1998-1999, Steve McMahon ( steve@vbaccelerator.com). All Rights Reserved.
Last updated: 15 June 1998