Article ID: 114298
Article Last Modified on 8/16/2005
SendMessage Lib "User"(hWnd As Integer, wMsg As Integer, wParam As Integer, lParam As String) As Longwhere:
hWnd Specifies the handle to the edit control.
wParam Specifies the maximum number of bytes that can be entered.
If the user attempts to enter more characters, the edit
control beeps and does not accept the characters.
lParam Is not used.
Declare Function GetFocus Lib "User32"() As Long Declare Function SendMessageA Lib "User32"(hWnd As Long, wMsg As Integer, wParam As Integer, lParam As String) As Long Dim Shared WM_USER, EM_LIMITTEXT, TextLimit Sub MAIN WM_USER = 1024 EM_LIMITTEXT = WM_USER + 21 TextLimit = 4 'Sets the number of chars Begin Dialog UserDialog 320, 144, "MyApp", .dlgfun OKButton 10, 6, 88, 21 TextBox 10, 30, 160, 18, .TextBox1 PushButton 10, 51, 88, 21, "Push", .Push1 End Dialog Dim dlg As UserDialog Dialog dlg End Sub Function dlgfun(id$, action, wValue) Select Case action Case 1 DlgVisible "TextBox1", 0 Case 2 If id$ = "Push1" Then DlgVisible "TextBox1", 1 DlgFocus "TextBox1" hWnd = getfocus retVal = SendMessageA(hWnd, EM_LIMITTEXT, TextLimit, "") dlgfun = 1 End If Case 3 Case 4 Case 5 Case 6 Case Else End Select End Function
Declare Function GetFocus Lib "User"() As Integer Declare Function SendMessage Lib "User"(hWnd As Integer, wMsg As Integer, wParam As Integer, lParam As String) As Long Dim Shared WM_USER, EM_LIMITTEXT, TextLimit Sub MAIN WM_USER = 1024 EM_LIMITTEXT = WM_USER + 21 TextLimit = 2 'Sets the number of chars Begin Dialog UserDialog 320, 144, "MyApp", .dlgfun OKButton 10, 6, 88, 21 TextBox 10, 30, 160, 18, .TextBox1 PushButton 10, 51, 88, 21, "Push", .Push1 End Dialog Dim dlg As UserDialog Dialog dlg End Sub Function dlgfun(id$, action, wValue) Select Case action Case 1 DlgVisible "TextBox1", 0 Case 2 If id$ = "Push1" Then DlgVisible "TextBox1", 1 DlgFocus "TextBox1" hWnd = getfocus retVal = SendMessage(hWnd, EM_LIMITTEXT, TextLimit, "") dlgfun = 1 End If Case 3 Case 4 Case 5 Case 6 Case Else End Select End Function
Additional query words: 6.00a winword word6 6.00c word95 word7
Keywords: KB114298