Create Animated Buttons

Problem

You’d like to add some pizzazz to your application. You’ve seen animated buttons in other applications; how do you create them on your forms?

Solution

Access command buttons have an under-documented property called PictureData that stores the bitmap displayed on the button face. This solution examines two ways to use this property. First, you will learn how to create “two-state” buttons with pictures that change when you click on them. Next, you will learn how to create continuously animated buttons that cycle through a set of pictures at all times, using the form’s Timer event to display a smooth succession of bitmaps.

Load 09-07.MDB and open frmAnimateDemo in form view (Figure 9-20). The top two buttons are two-state buttons whose pictures change when you click them. The Copy button (on the top left) shows a second document, and the Exit button (on the top right) shows the door closing just before it closes the form. The bottom two buttons are examples of animated button faces. (Only the Exit button on this form actually does anything when you press it.)

The frmAnimateDemo form

Figure 9-20. The frmAnimateDemo form

Two-state buttons

To add a two-state animated button to your form, follow these steps:

  1. Open your form in design view. Place a pair of command buttons on the form. The first button should be sized correctly for your pictures and be located where you want the ...

Get Access Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.