Caps Lock and Num Lock ?

J

JerryWEC

What is the best way to do Caps Lock and Num Lock for a statusbar control in
vs2005?

I was doing this in vs2003...

Private Sub SetPanelLocks()

Try

Dim numLockValue As Integer = 0

Dim capsLockValue As Integer = 0

With Me.sbrApplication.Panels(panelIndex.AppCapsLock)

capsLockValue = GetKeyState(Keys.CapsLock)

If CType(capsLockValue, Boolean) = True Then

.Text = "Caps On"

Else

.Text = "Caps Off"

End If

End With

With Me.sbrApplication.Panels(panelIndex.AppNumLock)

numLockValue = GetKeyState(Keys.NumLock)

If CType(numLockValue, Boolean) = True Then

.Text = "Num On"

Else

.Text = "Num Off"

End If

End With

Catch ex As Exception

End Try

End Sub

I'm using the api GetKeyState with the Keys.NumLock and Keys.CapsLock.
However, this is not converting to VS2005. What is the best way to set the
status of these keys using VB2005?

Thanks in advance!
Jerry M
 
R

RobinS

Did this get answered in the newsgroup, and my newsreader
(OE) is keeping it a secret from me? Can you re-post the
answer?

Original question was:
What is the best way to do Caps Lock and Num Lock for
a statusbar control in vs2005?

Thanks,
Robin S.
 
J

JerryWEC

RobinS

here is the code I ended up with to set the num lock and caps lock....

Private Sub SetStatusLabels()

Try

Me.sslNumLock.Text = IIf(My.Computer.Keyboard.NumLock(), "Num On",
"Num Off")

Me.sslCapsLock.Text = IIf(My.Computer.Keyboard.CapsLock(), "Caps
On", "Caps Off")

Catch ex As Exception

ParentLogging.ProcessException(ParentLogging.CurrentMethodName(),
ex)

End Try

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top