by Scott A. Moss (2 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: Visual Basic 4.0 (32-bit)
Difficulty: Unknown Difficulty
Originally Published: Wed 8th September 1999
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Mouse Role Over (MRO) - A simple piece of Code that allows you to create a border on the icon that the mouse pointer is hovering over.
MROS As Long, MROX As Single, MROY As Single)
'//
'// ------------------------------------------------------
'// Oddity MRO (Mouse Roll Over) Script
'// Written By: Scott A. Moss
'// Date: 09/08/99
'// Visit my Website for More Visual Basic Help at:
'// www.oddi7y.cjb.net
'// Any problems or suggestions contact me at:
'// [email protected]
'//
'// If you use this in any major program that is to be
'// used to gain profit, please put some thanks to me even
'// if this is a little script, and tell me of your
'// program, so I know what it's being used in.
'//
'// ------------------------------------------------------
'// Please read the following infromation so that it will
'// work for you. Thankyou for choosing to use this code.
'// ------------------------------------------------------
'//
'// +-------------------(Legend)------------------+
'// | MROT = Mouse Roll Over Top |
'// | MROL = Mouse Roll Over Left |
'// | MROS = Mouse Roll Over Size |
'// | MROX = Mouse Roll Over X (Pointer Position) |
'// | MROY = Mouse Roll Over Y (Pointer Position) |
'// +---------------------------------------------+
'//
'// ------------------------------------------------------
'// Introduction
'// ------------------------------------------------------
'// This script can use both an Icon for the border or a
'// Shape. If you are using an Icon please add the Icon to
'// the Form and change it's values as these:
'// Name - MROB
'// Visible - False
'// You will need a transparent Icon or GIF with a Border
'// around the edge for the Icon. If you can't make one
'// then you can goto my website, and in the Visual Basic
'// page you will be able to find some there.
'// Next thing to do if you are using an Icon is to delete
'// the nine lines that are further down the code. They
'// are marked clearly with !!START CUTTING HERE!! and
'// !!STOP CUTTING HERE!! these lines are for use if you
'// are not using a icon for this MRO.
'//
'// If you are going to use a Shape then place it on the
'// Form and change it's values as these:
'// Name - MROB
'// BackStyle - 0 - Transparent
'// Shape - 0 - Rectangle
'// Visible - False
'//
'// ------------------------------------------------------
'// How to make the script work for you!
'// ------------------------------------------------------
'// Well for every Icon that you want the border to appear
'// over you have to put this in it's MouseMove Sub:
'// MROBorder = MRO(Top, Left, Size, X, Y)
'// You have to place in these values into the code above:
'// Top = This is where the Top of the Border is going
'// to be. This is usualy the top of your Icon.
'// Left = This is the same as the Top variable, but
'// instead of putting the Top you put where it
'// will be on the Left, usually the same as the
'// icon.
'// Size = This is the size of the Icon that you want
'// the Border to be (ie. 16, 32 or 64)
'// You do not need to place anything where X and Y are,
'// you just leave them as they were. Here is an example:
'// MROBorder = MRO(240, 340, 32, X, Y)
'// This would place a border for a 32x32 Icon at the
'// co-ordinates of 240,340.
'//
'// Next you have to put this in your Form's MouseMove Sub:
'// MROBorder = MRO(0, 0, 0, 0, 0)
'// This will make the Border disappear when the pointer
'// goes over a section of the Form that has not got an
'// icon on it.
'//
'// Happy Rolling!!!
'//
'//
'//
'// !!START CUTTING HERE!! (IF USING ICON IN MRO)
If MROB.Width < MROS * 15 Or _
MROB.Width > MROS * 15 Or _
MROB.Height < MROS * 15 Or _
MROB.Height > MROS * 15 Then
'// This checks to see if the Border is the right
'// size for the Icon defined in MROS, and if it
'// is not then it resizes it to the right size.
MROB.Width = MROS * 15
MROB.Height = MROS * 15
End If
'// !!STOP CUTTING HERE!!
'//
'//
'//
If MROT = 0 And MROL = 0 Then
'// This checks to see where the Borders location is
'// and if it is in the wrong place, then it will move
'// it to the right Icon it should be over.
'// The Visible = False is to stop un-sightly black
'// boxes from appearing when the Border icon moves.
MROB.Visible = False
MROB.Top = 0
MROB.Left = 0
ElseIf MROB.Top = MROT And MROB.Left = MROL Then
'// This will just check to see if your mouse pointer
'// is still on the Icon, and if it isn't then it will
'// get rid of the Border.
If MROX > MROB.Width Or _
(MROX + MROB.Left) < MROB.Left Or _
MROY > MROB.Height Or _
(MROY + MROB.Top) < MROB.Top Then
'// The Visible = False is to stop un-sightly
'// black boxes from appearing when the Border
'// icon moves.
MROB.Visible = False
MROB.Top = 0
MROB.Left = 0
End If
Else
'// This places the Border around the selected Icon.
'// This is what hould happen if it get's past every
'// other If thing.
MROB.Visible = False '// This is to stop un-sightly
MROB.Top = MROT '// black boxes from appearing
MROB.Left = MROL '// When the Border icon moves
MROB.Visible = True '// Brings Border Icon back
End If
End Function
No comments have been posted about Mouse Role Over (MRO) - A simple piece of Code that allows you to create a border on the icon that . Why not be the first to post a comment about Mouse Role Over (MRO) - A simple piece of Code that allows you to create a border on the icon that .