home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Tool Box
/
SIMS_2.iso
/
vb_code1
/
buttons
/
bdemo.frm
(
.txt
)
< prev
next >
Wrap
Visual Basic Form
|
1995-02-26
|
55KB
|
553 lines
ButtonTest
Picture-Button Demo
wwwwwwwwwwwwwwp
wwwwwwwwwwwwwp
Form1%
ButtonStrip
PictureUP
DDD@w
PictureDN
tDHDD
PushButton
ButtonPict
3338333
33338
PushButton
ButtonPict
PushButton
ButtonPict
PushButton
ButtonPict
"""'p
PushButton
ButtonPict
DDD@w
Picture1
UUUUUUU
UUUUUUUU
UUUUUUUUP
UUUUUUUU
UUUUUUUUP
UUUUUUUUU
UUUUUUUUU
UUUUUUUUP
UUUUUUUUU
UUUUUUUUU
UUUUUUUUUP
UUUUUUUUU
UUUUUUUUUP
UUUUUUUUUP
UUUUUUUUU
UUUUUUUUU
wwwww
UUUUUUUUUP
UUUUUUUUUP
wwwwwwwww
UUUUUUUUU
UUUUUUUUUP
UUUUUUUUUU
ppwpw
UUUUUUUUU
wwpppw
fffffff`
UUUUUUUUUP
fffffffffff
UUUUUUUUP
fffffffffffffff
UUUUUUUUU
fffffffffffffffff
UUUUUUUUU
ffffffffffffffffffff
UUUUUUUUP
fffffffffffffffffffff`
UUUUUUUUP
ffffffffffffffffffffffff
UUUUUUUU
ffffffffffffffffffffffffff
UUUUUUUU
fffffffffffffffffffffffffff`w
UUUUUUP
fffffffffffffffffffffffffffff
UUUUUUP
fffffffffffffffffffffffffffffff
UUUUUU
ffffffffffffffffffffffffffffff`
UUUUU
ffffffffffffffffffffffffffffff
UUUUP
Ppwwwwpp
0fffffffffffffffffffffffffffffff
ffffffffffffffffffffffffffffff`
ffffffffffffffffffffffffffffff
0wwpfffffffffffffffffffffffffffffff
ffffffffffffffffffffffffff
ffffffffffffffffffffff`
fffffffffffffffffff
pffffffffffffffff`
UUUPw
wppwww
ffffffffffffff
pwwwww
fffffffffff`
UUUUP
wwpffffffffff
wwwwwww
UUUUUP
fffffff`
UUUUUU
fffff`
UUUUUU
UUUUUU
UUUUUUU
UUUUUUUP
UUUUUUUUU
pwwww
UUUUUUUUUP
UUUUUUUUUU
UUUUUUUUUU
wwwpwww
UUUUUUUUUUPwp
UUUUUUUUUUP
wwwww
UUUUUUUUUUU
wwwww
pUUUUUUUUUUUPwww
UUUUUUUUUUUU
ppwwwww
UUUUUUUUUUUU
UUUUUUUUUUUPpww
pwwwpw
UUUUUUUUUUUPp
wpUUUUUUUUUUUU
wwpwp
ffffff`
pwpppUUUUUUUUUUUU
pwwpw
fffffffff
UUUUUUUUUUU
wwppp
wwwww
ffffffffffff`
UUUUUUUUUUUP
pwpww
wwwwwwp
fffffffffffffff`
UUUUUUUUUUUP
ffffffffffffffffff
pUUUUUUUUUUUU
wpwww
fffffffffffffffffffff`
UUUUUUUUUUU
wwpwp
fffffffffffffffffffffffff`
ppUUUUUUUUUUU
pwwwww
wwwww
fffffffffffffffffffffffff
pUUUUUUUUUUUP
ffffffffffffffffffffffffff
wpppw
UUUUUUUUUUP
ffffffffffffffffffffffffff`
UUUUUUUUUUPpww
wwwwww
wwwww
ffffffffffffffffffffffffff
UUUUUUUUUUPppwpw
fffffffffffffffffffffffffff
UUUUUUUUUU
ffffffffffffffffffffffffff`
UUUUUUUUUU
wwwww
p`fffffffffffffffffffffffffff`ww
UUUUUUUUU
wpwwp
fffffffffffffffffffffffffff
UUUUUUUU
wwwww
fffffffffffffffffffffffffff`
UUUUUUUPwwpp
fffffffffffffffffffffffffff`
UUUUUUUP
wppwww
ffffffffffffffffffffffffffff
UUUUUPw
ffffffffffffffffffff`
ffffffffffffffffff
pwwpwp
wwwwp
wwwww
ffffffffffffffff`
wwwww
fffffffffffff`
wwwwwww
fffffffff
pwpppp
wwpwpwp
wwwwp
wwwwwww
wwwwww
wwwww
wppwppp
wwwww
ppwpp
wwwpwww
wwwww
wwwww
wppwpp
wpwppwwww
ppwpppw
wpwpw
wpwwp
wwwwp
wwwpwwp
ppwpppp
sspwpw
wppww
wwwwwpwp
spwww
pwwww
wwwww
ppwww
wwwwww
wwwwwww
pwwww
pwppw
pwwwp
wwwwww
wwwpwp
0pwpw
wwwwww
wpppw
wwwwwp
wwwwwww
pppww
pwwwwww
wpwwwpw
wwwppw
wwwwwww
pwwpppw
wwwwpp
ffffffffff`
fffffffffff
sspwp
ffffffffff`
pwwwp
wwpwww
pwwwwpwww
fffffffffff`
pppwpp
wwwpwp
ffffffffffff
ppwwp
pwwpw
fffffffffff`
ppwwww
ffffffffffff
70ppp
pwwwwp
wwwww
ffffffffffff
ppppwwww
`ffffffffffff`
wpwww
ffffffffffff
pwwpw
fffffffffffff
pwpwww
ffffffffffff`
ppwwwp
fffffffffffff
ffffffffffff`
ppppwpw
wpwwpwpw
wwwppwwwwwpwwp
ffffffffffff`
fffffffffff
DDDDD
wwwwwwww
ffffffffff`
ppwppww
DDDDDDDDDDDDD@
fffffff
wppwpww
DDDDDDDDDDDDDDDDDDDDD
DDDDDDDDDDDDDDDDDDDD@
wwwww
DDDDDDDDDDDDDDDDDDD@
ppwwwww
DDDDDDDDDDDDDDDDDDD@
pDDDDDDDDDDDDDDDDDDD@
DDDDDDDDDDDDDDDDDD@
wwwwwpDDDDDDDDDDDDDDDDDD@
wwwww
DDDDDDDDDDDDDDD
ppwpwp
wpwww
DDDDDDDD@wpww
pwppw
wpwpwp
wwwwww
wpwww
pppwp
ppwww
wwwwwp
wwwww
wwwwpw
wwppp
wwwwpw
wpwwpw
DDDDD@
pwwww
DDDDDDDDDDDD
DDDDDDDDDDDDDDD
70DDDDDDDDDDDDDD@
DDDDDDDDDDDDD
0DDDDDDDDDDDD@
pwwpwp
pppwp
DDDDDDDDDDD@
pwwww
ppwwpp
DDDDDDDDDD@
ppwww
pwppw
wwpwwwpw
DDDD@
pDDDDDDDDDD@
wwwpw
wwwwww
wpwww
DDDDDD
DDDDDDDDD@
DDDDDDD
DDDDDDDDD
wwwpw
DDDDDDD@
0DDDDDDDD
pppwpw
pwwppwpw
DDDDDDDD@
DDDDDDD@
wwpwppp
DDDDDDDD
DDDDDDDD
DDDDDDD
DDDDDDD
DDDDDDDDDDDDDD@
wwppw
DDDDDDDDDDDDD
DDDDDDDDDD@
DDDDDDD
wwpwww
DDDDD
wwpwwp
pwppw
pwwwp
wpppw
ppppw
pppww
pwwww
pwppww
wwppw
wwpwpww
pwppp
pwwwp
pppwwpwpww
pwwppww
pppwp
wpwwww
wwwwp
wppppppw
pwwwpwwpwww
pwpwpp
pwwwpw
wwwww
wwpppp
wpwpp
wppppw
wwwwww
wwwww
wpwwp
ppwpww
wpwpwwwwww
wwwppwwww
wpwww
pppwpwpwpppwwww
wpwwppp
pwppwwwwww
wwppww
DDDDDDDDDDD
DDDDDDDDDDDDDDDDDD
DDDDDDDDDDDDDDDDDDD@
DDDDDDDDDDDDDDDDDD@
DDDDDDDDDDDDDDDDDD@
DDDDDDDDDDDDDDDDDDD
UUUUP
DDDDDDDDDDDDDDDDDDD
DDDDDDDDDDDDDDDDDDD
UUUUU
DDDDDDDDDDDDDDDDDD@
UUUUUU
DDDDDDDDDDD
UUUUUUP
UUUUUU
UUUUUUU
UUUUUUP
UUUUUUU
MS Sans Serif
NumButtons
ButtPictTop
ButtPictLeft
@ Form_Load
ButtonPict{
LeftH
ButtonUP
PictureUP_MouseDown
ButtonL
Shift
PictureDN
VisibleX
PictureUP
picture1
CurrentXe
CurrentY
PictureUP_MouseUp0
ButtonDown
PushButton
DrawWidth^
ScaleWidth
ScaleHeight
PushButton_MouseDown
index
PushButton_MouseUp
Picture1_MouseDown
Picture1_MouseUp
ButtonPict_MouseDown
ButtonPict_MouseUpm
placed
The main procedures in this program are the generall
procedures ButtonUp and ButtonDown. Form_Load initializess
the buttons in the up position and stores the locationss
of their pictures.
To use these procedures in your program:
1. Create a picture box control with the CtlName set
to "PushButton"
2. Create a picture box control on top of the PushButttonn
picture box and set the CtlName to "ButtonPict".i
3. Copy both picture boxes by selecting the PushButton
picture box and executing the "Edit-Copy" command.m
4. Paste a copy for each button you want to create and
create the control arrays PushButton() and ButtonPict().c
These procedures were obviously designed to control
more than one button. You can, however, modify them
if you need only one simulated button.t
6. Adjust the buttons to the sizes you want. Although thee
routines should work with any size buttons, there isr
a practical limit because of the time it takes for VB
to draw the lines on them.t
5. Load your pictures (icon, bmp, etc) into the picturee
boxes on top of your buttons (ButtonPict()), size and
position them as necessary.
6. Copy the subs ButtonUp and ButtonDown into the.
(general) (declarations) section for your form and thed
initializing routine into your Form_Load procedure.
7. Put a CALL to ButtonDown in your PushButton_MouseDown and
ButtonPict_MouseDown event procedures. Likewise, put callsc
to ButtonUp in your PushButton_MouseUp and ButtonPict_P
MouseUp event procedures. t
8. Copy the declarations below into your program and changee
the value of NumButtons% to the number of simulated
buttons on your form.
That is all there is to it. See the comments in ButtonUp and
ButtonDown for more information.
The camera button (the camera that is a button) is handled differently.
it is simply two separate pictures (not an array). The picture
that represents the object in the up position is called PictureUp andd
is placed over the other (PictureDn). Your code only needs too
handle the MouseUp and MouseDown events for the top picture, since
the user cannot access the bottom picture. In your mouse event
handlers, you just have to switch visibility between the two pictures.
You could, of course, do all of your buttons this way by makingg
two control arrays for the pictures, just like the other buttons,,
but this method requires a little more manual work, because you have
to create both up and down representations of each picture. The camera
was first drawn (using Iconwrks) in the up position with shadows on the
right and bottom. Then the icon was copied and pasted into another
icon - offset one pixel to the right and one pixel down from the original.
The shadow was removed from the right and bottom and shadow was addedd
to the top and left. You can load both icons into Icon Works to seee
what I mean.
Change the Constant NumButtons% to the actual number of simulateds
buttons on your form.
used to pass the index to the general procedures
These are used for
coordinates when
moving the pictures
on the buttons.
These will store the locations
of the button pictures when
the form is loaded.
ButtonDown
This procedure draws the button in the down position..
Remember ScaleMode must be set to 3 (pixels) on PushButton()
for this to work properly.
Set line width to one pixelt
*** First draw a black box around the button
*** Next erase the white and dark inside lines and
*** change the white outside lines to dark grey.
*** Move the picture down and right 1 pixel
***
** The following code puts the demo text on the picture. **A
** You could process your button commands here or in the **A
** ButtonUP procedure. Processing in the ButtonUP pro- **A
** cedure would act like a Command_Click event.
ix is the button index
Camera
Apple
Folder
Button
ButtonPict_MouseDown
*** This is necessary in case someone presses the mouse ***
*** button while the pointer is over the picture on the ***
*** button instead of the button itself.
ButtonPict_MouseUp
*** This is necessary in case someone pressed the mouse ***
*** button while the pointer was over the picture on
*** the button instead of the button itself.
ButtonUP
*** Draw 2 white lines accross the top of the button. ****
*** The second is 1 pixel shorter than the first.
****
*** Draw 2 dark lines on the left side of the button. **
*** The second is 2 pixels shorter than the first.
*** Draw 2 white lines down the left side of the button *
*** The second is 2 pixels shorter than the first.
*** Draw 2 dark lines at the bottom of the button.
*** The second is 2 pixels longer than the first.
****
*** Move the picture up and left 1 pixel
** You could put your button processing code here **-
** to look like a Command_Click event.
For this demo just erase the text*
on the picture.o
Form_Load
Display all the buttons-
in the up position.l
Picture1_MouseDown
This picture is just for decoration.
Picture1_MouseUp
PictureUP_MouseDown
*** This handles the camera that is not on a button ***i
** Process code here - just like a command_MouseDown **
** event. Or you could put your code in the MouseUP **
** procedure to make it look like a Command_Click. **
You're holding the camera down.
PictureUP_MouseUp
** This procedure handles the camera that is not on **
** a button.
( **
** Process code here - just like a command button **
PushButton_MouseDown
PushButton_MouseUp