Results 1 to 24 of 24

Thread: show if caps is on in text box ?[solved]

  1. #1

    Thread Starter
    Lively Member Neo-dark's Avatar
    Join Date
    Oct 2004
    Location
    The neather world
    Posts
    114

    Resolved show if caps is on in text box ?[solved]

    i got a small question is there a way to show if caps are on or off in a text box ? i used the search but i coulndt find a thing im just wondering if theres a way...like the box below(the vbcode is: on box) i need that,but then for caps
    Last edited by Neo-dark; Dec 6th, 2004 at 01:01 PM.
    i got kicked out of barnes and noble once for moving all the bibles into the fiction section"--FD

    Of course I'm a real doctor! I'll draw up my own diploma some time to prove it!-Dr Dis

  2. #2
    Hyperactive Member mudfish's Avatar
    Join Date
    Feb 2004
    Location
    Chit Chat
    Posts
    353

    Re: show if caps is on ?

    I think you can do it, would be an API call to find out if caps are on or off!
    Then just display in a textbox. Never tried
    Mudfish AKA Bowfin
    I can spell "If" all day right, just a coder!


    "Always do sober what you said you'd do drunk. That will teach you to keep your mouth shut." -- Ernest Hemingway

    Member of the ECCC

  3. #3

    Thread Starter
    Lively Member Neo-dark's Avatar
    Join Date
    Oct 2004
    Location
    The neather world
    Posts
    114

    Unhappy Re: show if caps is on in text box ?

    isnt there a way without a api..?
    got some code i could work from ?


    I declare myself n00B
    i got kicked out of barnes and noble once for moving all the bibles into the fiction section"--FD

    Of course I'm a real doctor! I'll draw up my own diploma some time to prove it!-Dr Dis

  4. #4
    Lively Member
    Join Date
    Aug 2003
    Location
    Philadelphia, Pa.
    Posts
    123

    Re: show if caps is on in text box ?

    Here is an explanation of how to do it. I dont think you can without an API.

    http://www.mentalis.org/apilist/GetKeyState.shtml

  5. #5
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: show if caps is on in text box ?

    You could use the keypress event and check if the ascii value is in the "caps" range.

    Quote Originally Posted by Neo-dark
    isnt there a way without a api..?
    got some code i could work from ?


    I declare myself n00B

  6. #6
    Hyperactive Member mudfish's Avatar
    Join Date
    Feb 2004
    Location
    Chit Chat
    Posts
    353

    Re: show if caps is on in text box ?

    Look on your machine for a program called APIloader.exe (Think I spelled it right).
    I think you would have to use the API!
    I have lots of API code but nothing like this.
    Mudfish AKA Bowfin
    I can spell "If" all day right, just a coder!


    "Always do sober what you said you'd do drunk. That will teach you to keep your mouth shut." -- Ernest Hemingway

    Member of the ECCC

  7. #7
    Hyperactive Member mudfish's Avatar
    Join Date
    Feb 2004
    Location
    Chit Chat
    Posts
    353

    Re: show if caps is on in text box ?


    It is APILOAD.exe
    Mudfish AKA Bowfin
    I can spell "If" all day right, just a coder!


    "Always do sober what you said you'd do drunk. That will teach you to keep your mouth shut." -- Ernest Hemingway

    Member of the ECCC

  8. #8

    Thread Starter
    Lively Member Neo-dark's Avatar
    Join Date
    Oct 2004
    Location
    The neather world
    Posts
    114

    Talking Re: show if caps is on in text box ?

    now i found it ! heheh
    so what should i look for now ? this is hard
    i got kicked out of barnes and noble once for moving all the bibles into the fiction section"--FD

    Of course I'm a real doctor! I'll draw up my own diploma some time to prove it!-Dr Dis

  9. #9

    Thread Starter
    Lively Member Neo-dark's Avatar
    Join Date
    Oct 2004
    Location
    The neather world
    Posts
    114

    Re: show if caps is on in text box ?

    i tried typing in'capital' and CAPS but found nothing on both :'( it would be the same effect for scrl lock and such right ? imma look for it again on the search
    i got kicked out of barnes and noble once for moving all the bibles into the fiction section"--FD

    Of course I'm a real doctor! I'll draw up my own diploma some time to prove it!-Dr Dis

  10. #10
    Hyperactive Member mudfish's Avatar
    Join Date
    Feb 2004
    Location
    Chit Chat
    Posts
    353

    Re: show if caps is on in text box ?

    To load it you must first click File then load text.
    Then pick win32api.txt
    Mudfish AKA Bowfin
    I can spell "If" all day right, just a coder!


    "Always do sober what you said you'd do drunk. That will teach you to keep your mouth shut." -- Ernest Hemingway

    Member of the ECCC

  11. #11

    Thread Starter
    Lively Member Neo-dark's Avatar
    Join Date
    Oct 2004
    Location
    The neather world
    Posts
    114

    Re: show if caps is on in text box ?

    i did that :P it dint find anything bout caps,like i said before im looking for code now i found some but where should i place this..?

    Code:
    Private Declare Function GetKeyboardState Lib "user32" (pbKeyState As Byte) As Long
    Private Declare Function SetKeyboardState Lib "user32" (lppbKeyState As Byte) As Long
    
    Private Const VK_CAPITAL = &H14
    Private Const VK_NUMLOCK = &H90
    Private Const VK_SCROLL = &H91
    
    ReDim KeyboardBuffer(256) As Byte
    GetKeyboardState KeyboardBuffer(0)
    'This example show you how to press the Caps Lock button. if you want
    'to press the Num Lock button, Replace all the following 3 'VK_CAPITAL'
    'with 'VK_NUMLOCK' or VK_SCROLL as desired.
    If KeyboardBuffer(VK_CAPITAL) And 1 Then
    KeyboardBuffer(VK_CAPITAL) = 0
    Else
    KeyboardBuffer(VK_CAPITAL) = 1
    End If
    SetKeyboardState KeyboardBuffer(0)
    
    Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
    
    'To check if Num Lock is on Replace the 'vbKeyCapital' below with 'vbKeyNumlock'
    
    Dim lngWhatState As Long
    lngWhatState = GetKeyState(vbKeyCapital)
    If lngWhatState = 1 Then
    MsgBox "The Caps Lock Is On"
    Else
    MsgBox "The Caps Lock Is Off"
    End If
    i got kicked out of barnes and noble once for moving all the bibles into the fiction section"--FD

    Of course I'm a real doctor! I'll draw up my own diploma some time to prove it!-Dr Dis

  12. #12
    Hyperactive Member mudfish's Avatar
    Join Date
    Feb 2004
    Location
    Chit Chat
    Posts
    353

    Re: show if caps is on in text box ?

    Declare Function GetKeyboardState Lib "user32" Alias "GetKeyboardState" (pbKeyState As Byte) As Long

    That what I found all so! Do not know how it work google "GetKeyboardState"
    and see what you find
    Mudfish AKA Bowfin
    I can spell "If" all day right, just a coder!


    "Always do sober what you said you'd do drunk. That will teach you to keep your mouth shut." -- Ernest Hemingway

    Member of the ECCC

  13. #13

    Thread Starter
    Lively Member Neo-dark's Avatar
    Join Date
    Oct 2004
    Location
    The neather world
    Posts
    114

    Re: show if caps is on in text box ?

    coulnd find nothing big im trying it ou on a form i hope it works...
    i got kicked out of barnes and noble once for moving all the bibles into the fiction section"--FD

    Of course I'm a real doctor! I'll draw up my own diploma some time to prove it!-Dr Dis

  14. #14

    Thread Starter
    Lively Member Neo-dark's Avatar
    Join Date
    Oct 2004
    Location
    The neather world
    Posts
    114

    Re: show if caps is on in text box ?

    nope wont function i tried putting it in a module,class,ect but it works in nothing..? i dunno where to place itttt :'(

    i am such a n00b
    i got kicked out of barnes and noble once for moving all the bibles into the fiction section"--FD

    Of course I'm a real doctor! I'll draw up my own diploma some time to prove it!-Dr Dis

  15. #15
    Hyperactive Member mudfish's Avatar
    Join Date
    Feb 2004
    Location
    Chit Chat
    Posts
    353

    Re: show if caps is on in text box ?

    You must declare it like this
    Code:
    Option Explicit
    
       
    Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _
        (ByVal lpBuffer As String, nSize As Long) As Long
    This at the top of a form.
    Mudfish AKA Bowfin
    I can spell "If" all day right, just a coder!


    "Always do sober what you said you'd do drunk. That will teach you to keep your mouth shut." -- Ernest Hemingway

    Member of the ECCC

  16. #16
    Hyperactive Member mudfish's Avatar
    Join Date
    Feb 2004
    Location
    Chit Chat
    Posts
    353

    Re: show if caps is on in text box ?

    Then in form load I call it.
    Code:
    If GetUserName(strUserName_Form_Load, Len(strUserName_Form_Load)) = 0 Then
        MsgBox "Unable to get user ID. Program terminating", , "PBDT120 - ERROR"
        Unload Me
    Else
        strUserID_Form_Load = Left$(strUserName_Form_Load, InStr(strUserName_Form_Load, Chr$(0)) - 1)
    End If
    Mudfish AKA Bowfin
    I can spell "If" all day right, just a coder!


    "Always do sober what you said you'd do drunk. That will teach you to keep your mouth shut." -- Ernest Hemingway

    Member of the ECCC

  17. #17

    Thread Starter
    Lively Member Neo-dark's Avatar
    Join Date
    Oct 2004
    Location
    The neather world
    Posts
    114

    Re: show if caps is on in text box ?

    Its keeps giving me the line"compile error: invalid outside call procedure"
    i got kicked out of barnes and noble once for moving all the bibles into the fiction section"--FD

    Of course I'm a real doctor! I'll draw up my own diploma some time to prove it!-Dr Dis

  18. #18

    Thread Starter
    Lively Member Neo-dark's Avatar
    Join Date
    Oct 2004
    Location
    The neather world
    Posts
    114

    Re: show if caps is on in text box ?

    really thanks allot for helping me find it out this is my code right now:


    Code:
    Option Explicit
    
       
    Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _
        (ByVal lpBuffer As String, nSize As Long) As Long
        
    
    Private Declare Function GetKeyboardState Lib "user32" (pbKeyState As Byte) As Long
    Private Declare Function SetKeyboardState Lib "user32" (lppbKeyState As Byte) As Long
    
    Private Const VK_CAPITAL = &H14
    Private Const VK_NUMLOCK = &H90
    Private Const VK_SCROLL = &H91
    
    ReDim KeyboardBuffer(256) As Byte
    GetKeyboardState KeyboardBuffer(0)
    'This example show you how to press the Caps Lock button. if you want
    'to press the Num Lock button, Replace all the following 3 'VK_CAPITAL'
    'with 'VK_NUMLOCK' or VK_SCROLL as desired.
    If KeyboardBuffer(VK_CAPITAL) And 1 Then
    KeyboardBuffer(VK_CAPITAL) = 0
    Else
    KeyboardBuffer(VK_CAPITAL) = 1
    End If
    SetKeyboardState KeyboardBuffer(0)
    
    Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
    
    'To check if Num Lock is on Replace the 'vbKeyCapital' below with 'vbKeyNumlock'
    
    Dim lngWhatState As Long
    lngWhatState = GetKeyState(vbKeyCapital)
    If lngWhatState = 1 Then
    MsgBox "The Caps Lock Is On"
    Else
    MsgBox "The Caps Lock Is Off"
    End If
    
    Private Sub Form_Load()
    If GetUserName(strUserName_Form_Load, Len(strUserName_Form_Load)) = 0 Then
        MsgBox "Unable to get user ID. Program terminating", , "PBDT120 - ERROR"
        Unload Me
    Else
        strUserID_Form_Load = Left$(strUserName_Form_Load, InStr(strUserName_Form_Load, Chr$(0)) - 1)
    End If
    End Sub
    i got kicked out of barnes and noble once for moving all the bibles into the fiction section"--FD

    Of course I'm a real doctor! I'll draw up my own diploma some time to prove it!-Dr Dis

  19. #19
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: show if caps is on in text box ?

    Try this.

    Code:
    Option Explicit
    Private Type KeyboardBytes
         kbByte(0 To 255) As Byte
    End Type
    Private Declare Function GetKeyboardState Lib "user32" (kbArray As KeyboardBytes) As Long
    
    Private Const VK_CAPITAL = &H14
    Private Const VK_NUMLOCK = &H90
    Private Const VK_SCROLL = &H91
    
    Private Sub Text1_GotFocus()
    Dim KeyboardBuffer As KeyboardBytes
    GetKeyboardState KeyboardBuffer
    If KeyboardBuffer.kbByte(VK_CAPITAL) = 0 Then
        MsgBox "Caps off"
    Else
        MsgBox "Caps on"
    End If
    End Sub

  20. #20
    Hyperactive Member mudfish's Avatar
    Join Date
    Feb 2004
    Location
    Chit Chat
    Posts
    353

    Re: show if caps is on in text box ?

    Option Explicit


    Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _
    (ByVal lpBuffer As String, nSize As Long) As Long


    Private Declare Function GetKeyboardState Lib "user32" (pbKeyState As Byte) As Long
    Private Declare Function SetKeyboardState Lib "user32" (lppbKeyState As Byte) As Long
    Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer

    Private Const VK_CAPITAL = &H14
    Private Const VK_NUMLOCK = &H90
    Private Const VK_SCROLL = &H91

    ReDim KeyboardBuffer(256) As Byte
    GetKeyboardState KeyboardBuffer(0)
    'This example show you how to press the Caps Lock button. if you want
    'to press the Num Lock button, Replace all the following 3 'VK_CAPITAL'
    'with 'VK_NUMLOCK' or VK_SCROLL as desired.
    If KeyboardBuffer(VK_CAPITAL) And 1 Then
    KeyboardBuffer(VK_CAPITAL) = 0
    Else
    KeyboardBuffer(VK_CAPITAL) = 1
    End If
    SetKeyboardState KeyboardBuffer(0)

    Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer

    'To check if Num Lock is on Replace the 'vbKeyCapital' below with 'vbKeyNumlock'

    Dim lngWhatState As Long
    lngWhatState = GetKeyState(vbKeyCapital)
    If lngWhatState = 1 Then
    MsgBox "The Caps Lock Is On"
    Else
    MsgBox "The Caps Lock Is Off"
    End If

    Private Sub Form_Load()
    Call lngWhatState
    If GetUserName(strUserName_Form_Load, Len(strUserName_Form_Load)) = 0 Then
    MsgBox "Unable to get user ID. Program terminating", , "PBDT120 - ERROR"
    Unload Me
    Else
    strUserID_Form_Load = Left$(strUserName_Form_Load, InStr(strUserName_Form_Load, Chr$(0)) - 1)
    End If
    End Sub

    This might work I moved " Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer" and call the funtion in form load
    Mudfish AKA Bowfin
    I can spell "If" all day right, just a coder!


    "Always do sober what you said you'd do drunk. That will teach you to keep your mouth shut." -- Ernest Hemingway

    Member of the ECCC

  21. #21
    Hyperactive Member mudfish's Avatar
    Join Date
    Feb 2004
    Location
    Chit Chat
    Posts
    353

    Re: show if caps is on in text box ?


    Marty, his code looks better
    Mudfish AKA Bowfin
    I can spell "If" all day right, just a coder!


    "Always do sober what you said you'd do drunk. That will teach you to keep your mouth shut." -- Ernest Hemingway

    Member of the ECCC

  22. #22

    Thread Starter
    Lively Member Neo-dark's Avatar
    Join Date
    Oct 2004
    Location
    The neather world
    Posts
    114

    Re: show if caps is on in text box ?

    marti,mudfish,i have 2 new gods

    []bows[]it works now thanks allot :> im so happy now i cant thank you enough :>
    i got kicked out of barnes and noble once for moving all the bibles into the fiction section"--FD

    Of course I'm a real doctor! I'll draw up my own diploma some time to prove it!-Dr Dis

  23. #23
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: show if caps is on in text box ?

    Quote Originally Posted by Neo-dark
    marti,mudfish,i have 2 new gods

    []bows[]it works now thanks allot :> im so happy now i cant thank you enough :>
    Glad we could help. Now please help us by editing the first post and adding the green checkmark.

  24. #24

    Thread Starter
    Lively Member Neo-dark's Avatar
    Join Date
    Oct 2004
    Location
    The neather world
    Posts
    114

    Re: show if caps is on in text box ?

    TADAAAA :P done it so much of my post are left un-awnsered..i guess i always ask hard questions ?:P
    i got kicked out of barnes and noble once for moving all the bibles into the fiction section"--FD

    Of course I'm a real doctor! I'll draw up my own diploma some time to prove it!-Dr Dis

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