
ARCHIVE: TIPS & TRICKS
Force entry type with a simple API Call
Paul Mcguinness 03.20.2001
Rating: -4.00- (out of 5)




Force entry type with a simple API Call
Paul McGuinness
You can require the entries into your text entry box to be the kind of
entry you want, according to Reader Paul McGuinness, with a very simple
procedure. This will stop you from getting numbers in a name, for
example, or names in an amount entry. For more information about the
SetWindowsLong call, click here:
http://msdn.microsoft.com/library/psdk/winui/winclass_64tj.htm
Have you ever wanted to force a simple text box to be a numeric entry
or upper or lower case? You can do it with a simple API Call.
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)
Private Const ES_UPPERCASE As Long = &H8&
Private Const ES_LOWERCASE As Long = &H10&
Private Const ES_NUMBER As Long = &H2000
Private Sub Form_Load()
Dim DefStyle&
DefStyle = GetWindowLong(Text1.hwnd, GWL_STYLE)
Call SetWindowLong(Text1.hwnd, GWL_STYLE, DefStyle Or ES_NUMBER)
End Sub
------------------------------------------------------
Thanks, Paul. For your interest in SearchVB, we'll be sending you a
denim shirt.
Paul McGuinness is a co-director of a Computer Telephony company in the
UK. His skills include VB and x86 assembly language along with in-depth
knowledge of VoiceCard / Telecom's protocols.
 |

|
|
 |
|
 |