Re: How to implement 'Shift - Click' on a label
- From: "MikeD" <nobody@xxxxxxxxxxx>
- Date: Sun, 19 Feb 2006 07:43:48 -0500
"Jem" <xxxxxxxxxx> wrote in message news:zt6dnTWy3toV22XeRVnyiA@xxxxxxxxxxxx
I have a hidden label (set to same color as backcolor) on a form that when
clicked shows a hidden screen for technical support purposes. Obviously,
even though the label is very small it could be inadvertantly found and
clicked by a casual user. In order to make it a little more secure I
would like to have the user hold down the 'Shift' key (or similar) before
clicking and opening the subsequent technical support form.
It's quite some time since I was involved in VB and I seem to be
struggling with some of the simpler things, although some complex bits
i've managed quite easily. Alas, I guess thats age and alcohols effect on
the human brain ;-)
Any help is much appreciated.
You can detect if Shift is being held down by checking the Shift parameter
passed to both the MouseDown and MouseUp event.
If you want to detect if the Shift key and ONLY the Shift key (among Shift,
Ctrl, and Alt) is pressed, then do this:
Private Sub Label1_MouseUp(Button As Integer, Shift As Integer, X As Single,
Y As Single)
If Shift = vbShiftMask Then
MsgBox "Shift key was down while clicking"
Else
MsgBox "Shift key was NOT down while clicking"
End If
If you want to detect if the Shift key is pressed in any combination of it
and the Ctrl and Alt keys, then do this:
Private Sub Label1_MouseUp(Button As Integer, Shift As Integer, X As Single,
Y As Single)
If (Shift And vbShiftMask) = vbShiftMask Then
MsgBox "Shift key was down while clicking"
Else
MsgBox "Shift key was NOT down while clicking"
End If
Also, rather than "hide" the label by making it the same color as the form's
backcolor (which is OK as long as you're doing it right), it'd probably be
better to set the Label's BackStyle property to 0 - Transparent.
--
Mike
Microsoft MVP Visual Basic
.
- Follow-Ups:
- References:
- Prev by Date: How to implement 'Shift - Click' on a label
- Next by Date: Re: How to implement 'Shift - Click' on a label
- Previous by thread: How to implement 'Shift - Click' on a label
- Next by thread: Re: How to implement 'Shift - Click' on a label
- Index(es):