2008年12月23日火曜日

TEXTBOX の表示を大文字のみにする

'
' Win32 API 定義等
'
Public Const GWL_STYLE = (-16)

Public Const ES_LOWERCASE = &H10&
Public Const ES_NUMBER = &H2000&
Public Const ES_UPPERCASE = &H8&

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


'
' フォーム初期化
'
Private Sub Form_Load()
Dim iStyle As Long

' TextBox に ES_UPPERCASE の付与
iStyle = GetWindowLong(txtKey1.hWnd, GWL_STYLE)
iStyle = iStyle Or ES_UPPERCASE
SetWindowLong txtKey1.hWnd, GWL_STYLE, iStyle

End Sub