[API]
CallWindowProcAnsi
CallWindowProcWide
GetWindowLongA
GetWindowLongW

[INCLUDE]
Unicode
GetClassInfoEx
RegisterClassEx

[DIRECTIVE]
CustomClassesInDialogs

[DEFINE]
Public Const EditNumeric_ClassName As String = "EditNumeric"
Public Const EditNumeric_DECIMAL As Long = &H8&
Public Const EditNumeric_NEGATIVE As Long = &H10&
Private EditNumeric_OldProc As Long

[CODE]
Public Function EditNumeric_Register() As Boolean
  Dim xType1 As WNDCLASSEX
  
  If GetClassInfoEx("EDIT", xType1) Then
    EditNumeric_OldProc = xType1.lpfnWndProc
    xType1.ClassName = EditNumeric_ClassName
    EditNumeric_Register = RegisterClassEx(xType1, AddressOf EditNumeric_ClassHandler)
    End If
  End Function

Public Function EditNumeric_Unregister()
  Call UnregisterClass(EditNumeric_ClassName)
  End Function

Private Function EditNumeric_ClassHandler(ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  If Msg = &H102& Then
    Select Case wParam
      Case Is < 32&, 48& To 57&
        If IsUnicode Then
          EditNumeric_ClassHandler = CallWindowProcWide(EditNumeric_OldProc, hwnd, Msg, wParam, lParam)
          Else
          EditNumeric_ClassHandler = CallWindowProcAnsi(EditNumeric_OldProc, hwnd, Msg, wParam, lParam)
          End If
      Case Asc(Mid(CStr(1.1), 2&, 1&)) '44& 'comma
        If IsUnicode Then
          If Not (GetWindowLongW(hwnd, -16&) And EditNumeric_DECIMAL) = 0& Then
            EditNumeric_ClassHandler = CallWindowProcWide(EditNumeric_OldProc, hwnd, Msg, wParam, lParam)
            End If
          ElseIf Not (GetWindowLongA(hwnd, -16&) And EditNumeric_DECIMAL) = 0& Then
          EditNumeric_ClassHandler = CallWindowProcAnsi(EditNumeric_OldProc, hwnd, Msg, wParam, lParam)
          End If
      Case 45& 'minus?
        If IsUnicode Then
          If Not (GetWindowLongW(hwnd, -16&) And EditNumeric_NEGATIVE) = 0& Then
            EditNumeric_ClassHandler = CallWindowProcWide(EditNumeric_OldProc, hwnd, Msg, wParam, lParam)
            End If
          ElseIf Not (GetWindowLongA(hwnd, -16&) And EditNumeric_NEGATIVE) = 0& Then
          EditNumeric_ClassHandler = CallWindowProcAnsi(EditNumeric_OldProc, hwnd, Msg, wParam, lParam)
          End If
      End Select
    ElseIf IsUnicode Then
    EditNumeric_ClassHandler = CallWindowProcWide(EditNumeric_OldProc, hwnd, Msg, wParam, lParam)
    Else
    EditNumeric_ClassHandler = CallWindowProcAnsi(EditNumeric_OldProc, hwnd, Msg, wParam, lParam)
    End If
  End Function
