Microsoft & .NETVisual BasicVB Coding Tip: Testing the locked property of a text box

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

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, _
                            GWL_STYLE)
    If MyStyle And ES_READONLY Then
        MsgBox "Text Box is Locked"
    Else
        MsgBox "Text Box is Unlocked"
    End If
End Sub
Get the Free Newsletter!
Subscribe to Developer Insider for top news, trends & analysis
This email address is invalid.
Get the Free Newsletter!
Subscribe to Developer Insider for top news, trends & analysis
This email address is invalid.

Latest Posts

Related Stories