[API]
RECT
GetClientRect
GetWindowRect
LocalAlloc
RtlMoveMemory
SetWindowPos
DestroyWindow
CreateCompatibleDC
SelectObject
DeleteDC
ShowWindow
LocalFree

[INCLUDE]
CreateWindowEx
SendMessage
DrawText
SetWindowText

[DEFINE]
Private Type tAutoInfo
  pHWnd As Long     'parent HWnd
  pWidth As Long    'parents size
  pHeight As Long   '    "
  cWidth As Long    'maxwidth (clientwidth)
  cHeight As Long   'orgCHeight (clientwidth)
  iFixX As Long     '
  iFixY As Long     '
  mHeight As Long   ' maximum height
  cHWnd As Long     'MyHWnd
  CurHeight As Long 'size reserved
  End Type
Private Const sAutoInfo As Long = 40&
Private Const AutoInfo_ExStyle As Long = &H20000
Private Const AutoInfo_Style As Long = &H40200944

[CODE]
Public Function AutoInfo_Create(ByVal hWndParent As Long, ByVal MaxInfoCtlClientHeight As Long) As Long   ', Optional ByVal MaxHeight As Long = 128&) As Long
  Dim xType1 As RECT
  Dim xType2 As tAutoInfo
  
  If Not GetClientRect(hWndParent, xType1) = 0& Then
    With xType2
      .cWidth = xType1.Right - xType1.Left
      .cHeight = xType1.Bottom - xType1.Top
      If Not GetWindowRect(hWndParent, xType1) = 0& Then
        AutoInfo_Create = LocalAlloc(0&, sAutoInfo)
        If Not AutoInfo_Create = 0& Then
          .pHWnd = hWndParent
          .pHeight = xType1.Bottom - xType1.Top
          .pWidth = xType1.Right - xType1.Left
          .mHeight = MaxInfoCtlClientHeight
          Call RtlMoveMemory(ByVal AutoInfo_Create, xType2, sAutoInfo)
          End If
        End If
      End With
    End If
  End Function

Public Sub AutoInfo_SetText(ByVal hAutoInfo As Long, ByVal xText As String)
  Dim xLong1 As Long 'new height
  Dim xLong2 As Long
  Dim xLong3 As Long
  Dim xLong4 As Long
  Dim xType1 As tAutoInfo
  Dim xType3 As RECT
  Dim xType4 As RECT
  
  Call RtlMoveMemory(xType1, ByVal hAutoInfo, sAutoInfo)
  With xType1
    If Len(xText) = 0& Then
      If Not .cHWnd = 0& Then
postrelease:
        .pHeight = .pHeight - .CurHeight
        Call SetWindowPos(.pHWnd, 0&, 0&, 0&, .pWidth, .pHeight, &H216&)
        Call DestroyWindow(.cHWnd)
        End If
      Else
      If .cHWnd = 0& Then
        .cHWnd = CreateWindowEx(AutoInfo_ExStyle, "EDIT", "", AutoInfo_Style, 0&, .cHeight, 100&, 100&, .pHWnd, &H1001, 0&)
        If Not .cHWnd = 0& Then
          If Not GetClientRect(.cHWnd, xType3) = 0& Then
            If Not GetWindowRect(.cHWnd, xType4) = 0& Then
              .iFixX = (xType4.Right - xType4.Left) - (xType3.Right - xType3.Left)
              .iFixY = (xType4.Bottom - xType4.Top) - (xType3.Bottom - xType3.Top)
              xType3.Left = 0&
              xType3.Top = 0&
              End If
            End If
          End If
        End If
      If Not .cHWnd = 0& Then
'        .CurHeight = 0&
        Call SendMessage(.cHWnd, &H30&, SendMessage(.pHWnd, &H31&, 0&, 0&), 0&)
'Public Const WM_SETFONT = &H30
'Public Const WM_GETFONT = &H31

'Public Const EM_GETRECT = &HB2

        xLong1 = CreateCompatibleDC(0&)
        If Not xLong1 = 0& Then
          xLong2 = SendMessage(.pHWnd, &H31&, 0&, 0&)
          If Not xLong2 = 0& Then
            xLong2 = SelectObject(xLong1, xLong2)
            If Not xLong2 = 0& Then
              xLong3 = Len(xText)
              xType3.Right = .cWidth - .iFixX
              xType3.Bottom = &H3FFF&
              
              If Not DrawText(xLong1, xText, xType3, &H410&) = 0& Then
              'If GetTextExtentPoint32Wide(xLong1, ByVal StrPtr(xText), xLong3, xType2) Then
                xLong4 = xType3.Bottom - xType3.Top + .iFixY
                If xLong4 > .mHeight Then xLong4 = .mHeight
                End If
              
              Call SelectObject(xLong1, xLong2)
              End If
            End If
          Call DeleteDC(xLong1)
          End If

        'xLong1 = 111&
        If Not .CurHeight = xLong4 Then
          If xLong4 = 0& Then GoTo postrelease
          .pHeight = .pHeight - .CurHeight + xLong4
          .CurHeight = xLong4
          
          Call SetWindowPos(.cHWnd, 0&, 0&, 0&, .cWidth, .CurHeight, &H216&)
          Call SetWindowPos(.pHWnd, 0&, 0&, 0&, .pWidth, .pHeight, &H216&)
          End If

        Call SetWindowText(.cHWnd, xText)
        
        
        'Call SendMessage(.cHWnd, &HB2&, 0&, VarPtr(xType2))
        'Debug.Print xType2.Left, xType2.Top, xType2.Right - xType2.Left, xType2.Bottom - xType2.Top
        
        
        Call ShowWindow(.cHWnd, -5& * CLng(Not .CurHeight = 0&))
        End If
      End If
    Call RtlMoveMemory(ByVal hAutoInfo, xType1, sAutoInfo)
    End With
  End Sub

Public Sub AutoInfo_Destroy(ByRef hAutoInfo As Long, ByVal DestroyTheWindow As Boolean)
  Dim xType1 As tAutoInfo
  
  Call RtlMoveMemory(xType1, ByVal hAutoInfo, sAutoInfo)
  With xType1
    If DestroyTheWindow Then
      If Not .cHWnd = 0& Then
        '.pHeight = .pHeight - .CurHeight
        Call SetWindowPos(.pHWnd, 0&, 0&, 0&, .pWidth, .pHeight - .CurHeight, &H216&)
        Call DestroyWindow(.cHWnd)
        End If
      End If
    End With
  Call LocalFree(hAutoInfo)
  hAutoInfo = 0&
  End Sub
