|
Creating a bitmap button without an identifier is considered
creating it from scratch. Creating a bitmap button is more practical because you
can easily use the messages of such a button and refer to it in code. Therefore,
before creating a bitmap button, you can first add a button to a dialog box and specify
its identifier. For a button to display a picture, it must have the BS_OWNERDRAW
style. This means that you should check or set to True the Owner Draw option.
Visually, the most appealing aspect of a bitmap button is
the picture it displays. The bitmap can be designed following the same tools and
instructions we reviewed for the icons. To give a 3-D or realistic appearance to
the button, you should mimic the focus effect when designing the bitmaps.
Therefore, you should create one to four bitmaps for the
control. Here is how they would work:
- If you create one bitmap, it would be used for all clicks of the button.
Since the button would always appear the same, you should avoid using only
one picture
- If you create two bitmaps, the first would display as the regular picture
for the button, that is, when the button is not being clicked. The second
would be used when the button is clicked and the mouse is down on the button
- If you create three bitmaps, the first would display when the button is
not being accessed and another control has focus. The second picture would
display when the user is clicking the button and as long as the mouse is
down on the button. The third would be used when the button has focus but it
is not being used
- If you create three bitmaps, the first would display when the button is
not being accessed and another control has focus. The second picture would
display when the user is clicking the button and as long as the mouse is
down on the button. The third would be used when the button has focus but it
is not being used. The fourth would be used when the button is disabled
Since these options, to use a bitmap button to its fullest,
you should strive to provide four bitmaps. After creating the bitmaps, you can
load them into the button. This is done using the LoadBitmaps() method.
It comes in two versions as follows:
BOOL LoadBitmaps( LPCTSTR lpszBitmapResource, LPCTSTR lpszBitmapResourceSel = NULL,
LPCTSTR lpszBitmapResourceFocus = NULL, LPCTSTR lpszBitmapResourceDisabled = NULL );
BOOL LoadBitmaps( UINT nIDBitmapResource, UINT nIDBitmapResourceSel = 0,
UINT nIDBitmapResourceFocus = 0, UINT nIDBitmapResourceDisabled = 0 );
Each version takes four arguments. The first version uses
the bitmaps as string resources while the second version uses resource
identifiers.
As stated above, you can one to four bitmaps. As seen on
these functions, the first bitmap is required. The first argument must specify
the first or default bitmap and is required. The second argument is the name or
identifier of the bitmap that would be used when the button is selected. The
third is used when the button has focus. The last bitmap is used when the button
is disabled. Here is an example:
|