How do you make a ToolStripStatusLabel have a 'CAPS' feature (like, say, if CAPS LOCK is on, it'll say CAPS in black, but if it's off, it'll say CAPS in gray)
Right! Like I said, I'm pretty new to all of this and I'm just trying to get the fundamentals down and see the bigger picture of oop. I'm sure there's a simple trick to doing it. But it'll have to come from someone else. Be patient - I'm sure someone will come along and help ya.
I think I get what you're saying. If I understood correctly, he wanted to Globally monitor the condition of the Caps Lock key, in the app, and use a label to emit it's status.
If Caps Lock is on The label will display Caps Lock Else The label will display Caps Lock End if
I, myself, don't know how to do it without putting the code in all of the keypress events of all controls on the form. Unless, maybe he didn't use any of the keypress events for anything else - maybe he could change the handles so only one of them would handle the keypress event for all of the controls That would probably be dumb though, if there were alot of controls, I guess.
I'm new, and I'm just curious about this little issue, just for the sake of learning. I'm hoping he comes back to let me know how he made out and what he found - if anything.
I looked at several solutions to this. Apparently there is no asynch detection for the caps lock key and it seems in all the examples that I saw... they pole for that key with a timer.
So ... here is a very unroket science solution ..but nonetheless is a typical solution to this problem. Good luck.... have fun.
Imports System< xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Imports System.Windows.Forms
Imports System.Drawing
PublicClass Form1
ProtectedFriendWithEvents tmr AsNew Timer
PrivateSub cbGo_Click(ByVal sender AsObject, ByVal e As System.EventArgs) Handles cbGo.Click
tmr.Interval = 500
tmr.Enabled = True
tmr.Start()
EndSub
PrivateSub tmr_Tick(ByVal sender AsObject, ByVal e As System.EventArgs) Handles tmr.Tick
I think that samples at 2/sec. I have one pixel sampling program that samples at 10 samples per second... and I can't even see the program running on the taskmanager real time graph when I start it an stop it.
You samling rate is tiny and there's ony one timet and it doesn't demand more resources across time.
I can only partially answer your question. My.Computer.KeyBoard.CapsLock is a boolean type property. It will tell you the status of the Caps Lock Key. But I can't tell you how you would constantly monitor for any changes made to it. As a newbie, first instincts would tell me to put an if then else in the KeyUp Event of the form that holds the StatusStrip. However, I believe this wouldn't work if, you would hit the Caps Lock Key while a TextBox or other control on your form had the actual focus. Maybe someone with Experience could help you out in that manner. Also, I haven't played with the StatusStrip yet. But I believe that if you set a Label's .Enabled property to false, it will give you greyed out text.
ToolStripStatusLabels
PugJ
Thanks for all of your help!
Theo du Toit
SerSanchus
Right! Like I said, I'm pretty new to all of this and I'm just trying to get the fundamentals down and see the bigger picture of oop. I'm sure there's a simple trick to doing it. But it'll have to come from someone else. Be patient - I'm sure someone will come along and help ya.
Good luck Mad,
Mike
aryasheel
I think I get what you're saying. If I understood correctly, he wanted to Globally monitor the condition of the Caps Lock key, in the app, and use a label to emit it's status.
If Caps Lock is on
The label will display Caps Lock
Else
The label will display Caps Lock
End if
I, myself, don't know how to do it without putting the code in all of the keypress events of all controls on the form. Unless, maybe he didn't use any of the keypress events for anything else - maybe he could change the handles so only one of them would handle the keypress event for all of the controls That would probably be dumb though, if there were alot of controls, I guess.
I'm new, and I'm just curious about this little issue, just for the sake of learning. I'm hoping he comes back to let me know how he made out and what he found - if anything.
Thanks for your input Renee,
Mike
SmokeyPete
Mike,
I looked at several solutions to this. Apparently there is no asynch detection for the caps lock key and it seems in all the examples that I saw... they pole for that key with a timer.
So ... here is a very unroket science solution ..but nonetheless is a typical solution to this problem. Good luck.... have fun.
Imports System< xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Imports System.Windows.Forms
Imports System.Drawing
Public Class Form1
Protected Friend WithEvents tmr As New Timer
Private Sub cbGo_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cbGo.Click
tmr.Interval = 500
tmr.Enabled = True
tmr.Start()
End Sub
Private Sub tmr_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmr.Tick
If System.Console.CapsLock() Then
lbCL.Text = "Caps Lock: On."
Else
lbCL.Text = ""
End If
End Sub
End Class
Ultrahead
No..... not at all.
I think that samples at 2/sec. I have one pixel sampling program that samples at 10 samples per second... and I can't even see the program running on the taskmanager real time graph when I start it an stop it.
You samling rate is tiny and there's ony one timet and it doesn't demand more resources across time.
Craig Roberts Minnesota
Thanks for the code, Renee. I haven't worked with timers yet but it looks like a solution worth looking into.
Mike
SystemOfSystems
Just use the KeyDown event of the...
Uh oh.
Which control's event
Clifton G. Collins III
I can only partially answer your question.
My.Computer.KeyBoard.CapsLock is a boolean type property. It will tell you the status of the Caps Lock Key. But I can't tell you how you would constantly monitor for any changes made to it. As a newbie, first instincts would tell me to put an if then else in the KeyUp Event of the form that holds the StatusStrip. However, I believe this wouldn't work if, you would hit the Caps Lock Key while a TextBox or other control on your form had the actual focus. Maybe someone with Experience could help you out in that manner.
Also, I haven't played with the StatusStrip yet. But I believe that if you set a Label's .Enabled property to false, it will give you greyed out text.
Mike
ODilbert
Think of it like this...... UC is a boolean that you set when you want capslock for a givencontrol
(Typed from memory)
If UC then textbox1.text = textbox1.text.toUpper
This would most likely be in Textbox1's keypress event.