百度空间 | 百度首页 
 
查看文章
 
轻松实现限制用户输入类型
2008-05-09 16:37
Option Explicit


Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long

Private Const GWL_STYLE = (-16)

Enum TextInputStyles
ES_UPPERCASE = &H8&
ES_LOWERCASE = &H10&
ES_NUMBER = &H2000&
End Enum

Public Sub SetTextInputStyle(hWndTextControl As Long, InputStyle As TextInputStyles)
Dim Style As Long
Style = GetWindowLong(hWndTextControl, GWL_STYLE)
Style = Style Or InputStyle
SetWindowLong hWndTextControl, GWL_STYLE, Style
End Sub

Private Sub optStyle_Click(Index As Integer)
Select Case Index
Case 0: SetTextInputStyle txtTest.hWnd, ES_UPPERCASE
Case 1: SetTextInputStyle txtTest.hWnd, ES_LOWERCASE
Case 2: SetTextInputStyle txtTest.hWnd, ES_NUMBER
End Select
End Sub

类别:『visual basic』 | 添加到搜藏 | 浏览() | 评论 (3)
 
最近读者:
 
网友评论:
1
2008-05-10 14:47 | 回复
... 全是英文
 
2
2008-05-11 18:37 | 回复
是VB啊, 用SetWindowLong就可以实现输入限制啊,哈哈不错,以前还不知道,学了一招。。。
 
3
2008-05-11 19:05 | 回复
你也好 回访
 
发表评论:
姓 名:
网址或邮箱: (选填)
内 容:
验证码: 请点击后输入四位验证码,字母不区分大小写
      

     

©2009 Baidu