Welcome to Dream.In.Code
Getting VB.NET Help is Easy!

Join 136,545 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,837 people online right now. Registration is fast and FREE... Join Now!




Caplock and Toolstrip visible

2 Pages V  1 2 >  
Reply to this topicStart new topic

Caplock and Toolstrip visible, I want to know if i can make a toolstrip visible when Capslock is enab

yapper99
22 Aug, 2008 - 08:37 PM
Post #1

New D.I.C Head
*

Joined: 20 Aug, 2008
Posts: 31

I am creating a program in which a user is required to enter a password.... i was just wondering if there is a way for a toolstrip to become visible when the caps lock key is enabled (warning the user). I am still relatively new to vb.net so if you could please explain or provide code that would be greatly appreciated!

Thanks a lot in advance,

This post has been edited by yapper99: 22 Aug, 2008 - 08:38 PM
User is offlineProfile CardPM
+Quote Post

gbertoli3
RE: Caplock And Toolstrip Visible
22 Aug, 2008 - 10:20 PM
Post #2

DIC at Heart + Code
Group Icon

Joined: 23 Jun, 2008
Posts: 1,046



Thanked: 17 times
Dream Kudos: 950
My Contributions
Yes you can, You need to put htis in the KeyDown() event

CODE

'If the user presses the Caps Lock
If e.KeyCode = Keys.CapsLock Then
    'ToolStrip Becomes Visible
    capsToolStrip.Visible = True
Else
    'ToolStrip Becomes InVisible
    capsToolStrip.Visible = False
End If



This post has been edited by gbertoli3: 22 Aug, 2008 - 10:21 PM
User is offlineProfile CardPM
+Quote Post

yapper99
RE: Caplock And Toolstrip Visible
23 Aug, 2008 - 08:54 AM
Post #3

New D.I.C Head
*

Joined: 20 Aug, 2008
Posts: 31

QUOTE(gbertoli3 @ 22 Aug, 2008 - 11:20 PM) *

Yes you can, You need to put htis in the KeyDown() event

CODE

'If the user presses the Caps Lock
If e.KeyCode = Keys.CapsLock Then
    'ToolStrip Becomes Visible
    capsToolStrip.Visible = True
Else
    'ToolStrip Becomes InVisible
    capsToolStrip.Visible = False
End If





the warning will tell the user when they are entering a password in a webbrowser control so how would the keydown() event be??
User is offlineProfile CardPM
+Quote Post

gbertoli3
RE: Caplock And Toolstrip Visible
23 Aug, 2008 - 09:03 AM
Post #4

DIC at Heart + Code
Group Icon

Joined: 23 Jun, 2008
Posts: 1,046



Thanked: 17 times
Dream Kudos: 950
My Contributions
Here try this.
CODE

Private Sub webBrowser1_DocumentCompleted(ByVal sender As Object, ByVal e As WebBrowserDocumentCompletedEventArgs)
    Dim args As New KeyEventArgs(Keys.CapsLock)
    If args.KeyCode = Keys.CapsLock Then
        'TODO CODE
            'OR SHOW THE TOOLSTRIP
        MessageBox.Show("CapsLock is On")
    End If
End Sub


It works for me


This post has been edited by gbertoli3: 23 Aug, 2008 - 09:13 AM
User is offlineProfile CardPM
+Quote Post

gbertoli3
RE: Caplock And Toolstrip Visible
23 Aug, 2008 - 09:11 AM
Post #5

DIC at Heart + Code
Group Icon

Joined: 23 Jun, 2008
Posts: 1,046



Thanked: 17 times
Dream Kudos: 950
My Contributions
Nevermind it doesn't let me try again
User is offlineProfile CardPM
+Quote Post

gbertoli3
RE: Caplock And Toolstrip Visible
23 Aug, 2008 - 09:32 AM
Post #6

DIC at Heart + Code
Group Icon

Joined: 23 Jun, 2008
Posts: 1,046



Thanked: 17 times
Dream Kudos: 950
My Contributions
Ok try this
CODE

Private Sub webBrowser1_PreviewKeyDown(ByVal sender As Object, ByVal e As PreviewKeyDownEventArgs)
    If e.KeyCode = Keys.CapsLock Then
            'TODO CODE
    End If
End Sub

User is offlineProfile CardPM
+Quote Post

AdamSpeight2008
RE: Caplock And Toolstrip Visible
23 Aug, 2008 - 02:14 PM
Post #7

LINQ D.I.C.
Group Icon

Joined: 29 May, 2008
Posts: 799



Thanked: 51 times
Dream Kudos: 2175
My Contributions
How about doing this?
vb

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.KeyCode = Keys.CapsLock Then
DisplayCapsLockState
End If
End Sub

Private Sub DisplayCapsLockState()
capsToolStrip.Visible = My.Computer.Keyboard.CapsLock
If My.Computer.Keyboard.CapsLock Then
Me.Label1.Text = "CAPSLOCK ON"
Me.Label1.ForeColor = Color.Red
Else
Me.Label1.Text = "CapsLock OFF"
Me.Label1.ForeColor = Color.Black
End If
End Sub


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
DisplayCapsLockState()
End Sub


User is offlineProfile CardPM
+Quote Post

gbertoli3
RE: Caplock And Toolstrip Visible
23 Aug, 2008 - 02:37 PM
Post #8

DIC at Heart + Code
Group Icon

Joined: 23 Jun, 2008
Posts: 1,046



Thanked: 17 times
Dream Kudos: 950
My Contributions
QUOTE(AdamSpeight2008 @ 23 Aug, 2008 - 03:14 PM) *

How about doing this?
vb

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.KeyCode = Keys.CapsLock Then
DisplayCapsLockState
End If
End Sub

Private Sub DisplayCapsLockState()
capsToolStrip.Visible = My.Computer.Keyboard.CapsLock
If My.Computer.Keyboard.CapsLock Then
Me.Label1.Text = "CAPSLOCK ON"
Me.Label1.ForeColor = Color.Red
Else
Me.Label1.Text = "CapsLock OFF"
Me.Label1.ForeColor = Color.Black
End If
End Sub


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
DisplayCapsLockState()
End Sub




Adam what he wants is it to work from the WebBrowser() Control

This post has been edited by gbertoli3: 23 Aug, 2008 - 02:37 PM
User is offlineProfile CardPM
+Quote Post

AdamSpeight2008
RE: Caplock And Toolstrip Visible
23 Aug, 2008 - 02:51 PM
Post #9

LINQ D.I.C.
Group Icon

Joined: 29 May, 2008
Posts: 799



Thanked: 51 times
Dream Kudos: 2175
My Contributions
Changed to
vb

Private Sub DisplayCapsLockState()
capsToolStrip.Visible = My.Computer.Keyboard.CapsLock
If My.Computer.Keyboard.CapsLock Then
Me.Label1.Text = "CAPSLOCK ON"
Me.Label1.ForeColor = Color.Red
Else
Me.Label1.Text = "CapsLock OFF"
Me.Label1.ForeColor = Color.Black



End If
End Sub


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
DisplayCapsLockState()
End Sub


Private Sub WebBrowser1_PreviewKeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.PreviewKeyDownEventArgs) Handles WebBrowser1.PreviewKeyDown
If e.KeyCode = Keys.CapsLock Then
DisplayCapsLockState()
End If
End Sub


User is offlineProfile CardPM
+Quote Post

gbertoli3
RE: Caplock And Toolstrip Visible
23 Aug, 2008 - 03:00 PM
Post #10

DIC at Heart + Code
Group Icon

Joined: 23 Jun, 2008
Posts: 1,046



Thanked: 17 times
Dream Kudos: 950
My Contributions
QUOTE(AdamSpeight2008 @ 23 Aug, 2008 - 03:51 PM) *

Changed to
vb

Private Sub DisplayCapsLockState()
capsToolStrip.Visible = My.Computer.Keyboard.CapsLock
If My.Computer.Keyboard.CapsLock Then
Me.Label1.Text = "CAPSLOCK ON"
Me.Label1.ForeColor = Color.Red
Else
Me.Label1.Text = "CapsLock OFF"
Me.Label1.ForeColor = Color.Black



End If
End Sub


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
DisplayCapsLockState()
End Sub


Private Sub WebBrowser1_PreviewKeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.PreviewKeyDownEventArgs) Handles WebBrowser1.PreviewKeyDown
If e.KeyCode = Keys.CapsLock Then
DisplayCapsLockState()
End If
End Sub




It's not working for me.
User is offlineProfile CardPM
+Quote Post

AdamSpeight2008
RE: Caplock And Toolstrip Visible
23 Aug, 2008 - 03:10 PM
Post #11

LINQ D.I.C.
Group Icon

Joined: 29 May, 2008
Posts: 799



Thanked: 51 times
Dream Kudos: 2175
My Contributions
QUOTE(gbertoli3 @ 24 Aug, 2008 - 12:00 AM) *

It's not working for me.

Wow that one one useful message.

vb

Private Sub DisplayCapsLockState()
capsToolStrip.Visible = My.Computer.Keyboard.CapsLock
' If My.Computer.Keyboard.CapsLock Then
' Me.Label1.Text = "CAPSLOCK ON"
' Me.Label1.ForeColor = Color.Red
' Else
' Me.Label1.Text = "CapsLock OFF"
' Me.Label1.ForeColor = Color.Black
' End If
End Sub


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
DisplayCapsLockState()
End Sub


Private Sub WebBrowser1_PreviewKeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.PreviewKeyDownEventArgs) Handles WebBrowser1.PreviewKeyDown
If e.KeyCode = Keys.CapsLock Then
DisplayCapsLockState()
End If
End Sub



This post has been edited by AdamSpeight2008: 23 Aug, 2008 - 03:12 PM
User is offlineProfile CardPM
+Quote Post

gbertoli3
RE: Caplock And Toolstrip Visible
23 Aug, 2008 - 03:36 PM
Post #12

DIC at Heart + Code
Group Icon

Joined: 23 Jun, 2008
Posts: 1,046



Thanked: 17 times
Dream Kudos: 950
My Contributions
QUOTE(AdamSpeight2008 @ 23 Aug, 2008 - 04:10 PM) *

QUOTE(gbertoli3 @ 24 Aug, 2008 - 12:00 AM) *

It's not working for me.

Wow that one one useful message.

vb

Private Sub DisplayCapsLockState()
capsToolStrip.Visible = My.Computer.Keyboard.CapsLock
' If My.Computer.Keyboard.CapsLock Then
' Me.Label1.Text = "CAPSLOCK ON"
' Me.Label1.ForeColor = Color.Red
' Else
' Me.Label1.Text = "CapsLock OFF"
' Me.Label1.ForeColor = Color.Black
' End If
End Sub


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
DisplayCapsLockState()
End Sub


Private Sub WebBrowser1_PreviewKeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.PreviewKeyDownEventArgs) Handles WebBrowser1.PreviewKeyDown
If e.KeyCode = Keys.CapsLock Then
DisplayCapsLockState()
End If
End Sub



Sorry I was in a rush. I was not getting an error but It would only show Caps Lock is Off.
User is offlineProfile CardPM
+Quote Post

2 Pages V  1 2 >
Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 10:56PM

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month