October 23, 2018
Hot Topics:

VB Coding Tip: Testing the locked property of a text box

  • November 19, 2002
  • By Sam Huggill
  • Send Email »
  • More Articles »

This sample again uses the GetWindowLong API call and the GWL_STYLE constant.

Private Declare Function _
   GetWindowLong _
      Lib "user32" Alias _
   "GetWindowLongA" (ByVal hWnd As Long, _
           ByVal nIndex As Long) As Long
Private Const GWL_STYLE As Long = (-16)
Private Const ES_READONLY As Long = &H800
Private MyStyle As Long
Private Sub Command1_Click()
    Text1.Locked = Not Text1.Locked
End Sub
Private Sub Command2_Click()
    MyStyle = GetWindowLong(Text1.hWnd, _
    If MyStyle And ES_READONLY Then
        MsgBox "Text Box is Locked"
        MsgBox "Text Box is Unlocked"
    End If
End Sub

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

By submitting your information, you agree that developer.com may send you developer offers via email, phone and text message, as well as email offers about other products and services that developer believes may be of interest to you. developer will process your information in accordance with the Quinstreet Privacy Policy.


Thanks for your registration, follow us on our social networks to keep up-to-date