Visual Basic Explorer
Visual Basic Explorer
 Navigation
 Home


 Coding
 Source Code

 FAQ Center

 VB Tips

 Downloads

 ToolBox

 Tutorials

 VB Games

 VB News

 VB Award

 VB Forums



 Affiliates
 Planet Source Code

 Rent a Coder

 DirectX4VB


 Misc
 Search

 Feedback

 Advertise

 About


Need to hire
a VB coder?

Please support our sponsor:

 Home 
 Site Map 
 Forums 
 News 
 Feedback 

 

''' Simple CoolBar by Dean Andreason - September 14, 1998'''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''' I am very new to VB (about a month), I guess I'm a "Newbie".
''' I've checked out alot of VB sites and found alot of different
''' examples of "coolbars" most seemed much more complicated than this.
''' I came up with this one using a control array and an ImageList.
''' It's free for all "as is" and I'm not responsible for any problems
''' it may cause you, your computer or any programs you use it in.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''' HOW TO DO IT:
''' Add the following controls to a form and set properties as shown:
''' 1) PictureBox - NAME = picToolBar, ALIGN = Top
''' 2) Image - NAME = imgButton
''' Copy and Paste on picToolBar desired number of buttons.
''' Be sure to answer yes to create a control array.
''' NOTE: This example has 10 buttons, if you have a different number
''' you'll need to change the For n = 0 To 9 in all the subs
''' accordingly. (For n = 0 To Z, where Z = total buttons - 1)
''' 3) Label - NAME = lblButtonPressed, AUTOSIZE = True
''' 4) ImageList - NAME = ImageList1
''' Now you need to add the pictures to the ImageList.
''' You need 3 pictures for each button, (Flat, Up & Down)
''' You can start with existing bmp or ico pictures for
''' the Flat buttons and save as NameFlat. (Substitute
''' Name for something meaningful for each picture)
''' Now with Paintbrush or other, (I use MicroAngelo)
''' Draw a white line across the Top and Left edge.
''' Draw a dark gray line across the Bottom and Right edge.
''' This makes it look like a button in the UP position.
''' Save As NameUp.
''' Draw a dark gray line across the Top and Left edge.
''' Draw a white line across the Bottom and Right edge.
''' This makes it look like a button in the DOWN position.
''' Save As NameDown.
''' Repeat this for all buttons.
''' Now add them to ImageList1.
''' NOTE: To work correctly with this code,
''' add them in this order: FLAT, DOWN, UP
''' You should now have 3 times as many images as buttons.
''' 5) Now paste the following code into the Form.
'''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit
Dim n As Integer

 
Private Sub Form_Load()
For n = 0 To 9
imgButton(n).Picture = ImageList1.ListImages((n * 3) + 1).Picture
Next
End Sub

 
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
For n = 0 To 9
imgButton(n).Picture = ImageList1.ListImages((n * 3) + 1).Picture
Next
End Sub

 
Private Sub imgButton_Click(C As Integer)
lblButtonPressed.Caption = "Button " & C & " Pressed"
End Sub

 
Private Sub imgButton_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
For n = 0 To 9
imgButton(n).Picture = ImageList1.ListImages((n * 3) + 1).Picture
Next
imgButton(Index).Picture = ImageList1.ListImages(((Index) * 3) + 2).Picture
End Sub

 
Private Sub imgButton_MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
For n = 0 To 9
imgButton(n).Picture = ImageList1.ListImages((n * 3) + 1).Picture
Next
imgButton(Index).Picture = ImageList1.ListImages(((Index) * 3) + 3).Picture
End Sub

 
Private Sub imgButton_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
For n = 0 To 9
imgButton(n).Picture = ImageList1.ListImages((n * 3) + 1).Picture
Next
imgButton(Index).Picture = ImageList1.ListImages(((Index) * 3) + 3).Picture
End Sub

 
Private Sub picToolBar_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
For n = 0 To 9
imgButton(n).Picture = ImageList1.ListImages((n * 3) + 1).Picture
Next
End Sub


Downloads

In IE right-click and select 'Save Target As...' or in Netscape right-click and select 'Save Link As...'

 

View Plain Text View Plain Text
Download Demo Project Download Demo Project
View Code Online Not Available





Home | About | What's New | Source Code | FAQ | Tips & Tricks | Downloads | ToolBox | Tutorials | Game Programming | VB Award | Search | VB Forums | Feedback | VBNews | Copyright & Disclaimer | Advertise | Privacy Policy |

Quick searches: Site Search | Advanced Site Search 

Copyright 2002 by Exhedra Solutions, Inc.
By using this site you agree to its terms and conditions
VB Explorer and VBExplorer.com are trademarks of Exhedra Solutions, Inc.