CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2007
    Posts
    115

    How to show the caps lock is on balloon warning like Windows

    Dear Sir,

    I want to show "the caps lock is on balloon" warning message like Windows in login form in passward text box. but I have no idea using window's api function. but i tried using tooltip but it can't work like window. I am working on Visual Studio 2010.

    Please give me any idea or sample code.


    Thanking You


    Debasis Bag

  2. #2
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: How to show the caps lock is on balloon warning like Windows

    With VS2008, on Win 7 .... If the textbox has been set as a password IE: PasswordChar = "*" then the Balloon tip automatically pops up ...

    ..

    however if you want to test for caps lock ... here's some sample code.. (NO API's ..)

    on a Form add a text box (Default Name 'TextBox1') and add this code to the form ...
    Code:
        Private Sub Text_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Textbox1.KeyDown
            If e.KeyCode = Keys.CapsLock Then
                If My.Computer.Keyboard.CapsLock Then
                    MsgBox("CAPS LOCK is on")
                Else
                    MsgBox("CAPS LOCK is off")
                End If
            End If
        End Sub
    Now start the project and with focus on the text box... press the caps key ... The msgbox will will give you the state of the CapsLock ...

    Now .. You could put the Code into the Textbox_GotFocus sub (with out the If e.KeyCode = Keys.CapsLock) and set/display your tooltip, Change a Lable, etc, etc...
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  3. #3
    Join Date
    May 2002
    Location
    Boston
    Posts
    67

    Re: How to show the caps lock is on balloon warning like Windows

    Hi,

    you could also use the keyboard object.

    Try something like this in a timer.

    Code:
    If My.Computer.Keyboard.CapsLock = True Then
           'display something or show a mesage
    End If
    Curt

  4. #4
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: How to show the caps lock is on balloon warning like Windows

    Quote Originally Posted by curt_c View Post
    you could also use the keyboard object.
    Code:
    If My.Computer.Keyboard.CapsLock = True Then
           'display something or show a mesage
    End If
    My example does use the Keyboard object .... Also putting it on a Timer is not advisable, do you want a msgbox every timer tick popping up telling you that Capslock is on...

    Best is to use the Keypess/Keydown events...

    you can even set the Forms Keypreview to true and have the forms Keydown/press event trigger for every key pressed while the form has focus..
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured