BITMAP

From Liberty BASIC Family
Jump to navigation Jump to search
Supported in Just BASIC Supported in Liberty BASIC Not supported in Liberty BASIC 5 Not supported in Run BASIC

Description

This is the command of bmpbutton, allowing to change bitmap displayed on bmpbutton. The bitmap is first loaded with loadbmp or captured with getbmp.

Syntax

  1. #handle.ext "bitmap bitmapname"
bitmapname is the name given the bitmap when loaded or captured, not the file name.

Hints

The button size and the bitmap size should be the same. Normally, the button size is automatically set by the size of the bitmap.
If new bitmap size differs, new bitmap will be scaled to occupy same place as old button.
(so to cover bmpbutton, it is enough to have bitmap of size 1x1 of buttonface color).

Example

An example of the command.

  'run this program from the JB installation folder in order
  ' to have relative access to the bmps
  'demonstrate the bitmap command for bmpbuttons
    WindowWidth = 248
    WindowHeight = 175
     nomainwin

     loadbmp "arrow", "bmp\arrwbttn.bmp"
     loadbmp "blue", "bmp\bluebttn.bmp"
     bmpbutton #main.button1, "bmp\blank4.bmp", [button1Click], UL, 22, 11
     bmpbutton #main.button2, "bmp\blank4.bmp", [button2Click], UL, 22, 46

     open "Bitmap Demo" for window as #main
     #main "trapclose [quit]"

     'wait here for input events
     wait

[button1Click] 'Perform action for the button named 'button1'
     #main.button2 "setfocus"
     #main.button2 "bitmap arrow"
     #main.button1 "bitmap blue"
     wait

[button2Click] 'Perform action for the button named 'button2'
     #main.button1 "setfocus"
     #main.button1 "bitmap arrow"
     #main.button2 "bitmap blue"
     wait

[quit]
     close #main
     end

Useful Procedures

' Place a useful function using this keyword here