Attribute VB_Name = "Utilities"
Public Declare Function PaintDesktop Lib "user32" (ByVal hDC As Long) As Long
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetWindowRect Lib "user32" _
    (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long



Private Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
End Type

Private Type POINTAPI
        X As Long
        Y As Long
End Type


Public Screen_On_Picture As Picture

Public Sub SelectInside(ByVal NObject As Object)
    NObject.SelStart = 0
    NObject.SelLength = Len(NObject.Text)
End Sub

Public Function IsSingleClicked(NObject As Object, NForm As Object) As Boolean
    Dim TempCoord As POINTAPI
    Dim DumpyX, DumpyY, XDumpyX, XDumpY As Single
    IsSingleClicked = False
    DumpyX = NObject.Left + NForm.Left
    DumpyY = NObject.Top + NForm.Top
    GetMouseXY TempCoord
    XDumpyX = DumpyX - TempCoord.X
    XDumpY = DumpyY - TempCoord.Y
    If XDumpyX <= 0 And Abs(XDumpyX) < NObject.Width Then
        If XDumpY <= 0 And Abs(XDumpY) < NObject.Height Then
            IsSingleClicked = True
        End If
    End If
End Function

Public Function IsHwndClicked(NHwnd As Long) As Boolean
    Dim TempCoord As POINTAPI
    Dim TempRect As RECT
    IsHwndClicked = False
    GetWindowRect NHwnd, TempRect
    TempRect.Bottom = TempRect.Bottom * Screen.TwipsPerPixelY
    TempRect.Left = TempRect.Left * Screen.TwipsPerPixelX
    TempRect.Right = TempRect.Right * Screen.TwipsPerPixelX
    TempRect.Top = TempRect.Top * Screen.TwipsPerPixelY
    GetMouseXY TempCoord
    If TempCoord.X > TempRect.Left And TempCoord.X < TempRect.Right Then
        If TempCoord.Y > TempRect.Top And TempCoord.Y < TempRect.Bottom Then
            IsHwndClicked = True
        End If
    End If
End Function

Private Function GetMouseXY(Buffer As POINTAPI)
    GetCursorPos Buffer
    Buffer.X = Buffer.X * Screen.TwipsPerPixelX
    Buffer.Y = Buffer.Y * Screen.TwipsPerPixelY
End Function


Public Function IsDoubleClicked(NObject1 As Object, NObject2 As Object, NForm As Object) As Boolean
    Dim TempCoord As POINTAPI
    Dim DumpyX, DumpyY, XDumpyX, XDumpY As Single
    IsDoubleClicked = False
    DumpyX = NObject1.Left + NObject2.Left + NForm.Left
    DumpyY = NObject1.Top + NObject2.Top + NForm.Top
    GetMouseXY TempCoord
    XDumpyX = DumpyX - TempCoord.X
    XDumpY = DumpyY - TempCoord.Y
    If XDumpyX <= 0 And Abs(XDumpyX) < NObject1.Width Then
        If XDumpY <= 0 And Abs(XDumpY) < NObject1.Height Then
            IsDoubleClicked = True
        End If
    End If
End Function

Public Function SuperTrim(eText As String) As String
    Dim ActAsc As Long
    Dim TextLen As Long
    Dim mlCnt As Long
    Dim success As String
    TextLen = Len(eText)
    If TextLen = 0 Then Exit Function
    For mlCnt = 1 To TextLen
        ActAsc = Asc(Mid(eText, mlCnt, 1))
        If ActAsc <= 32 Then
            
        Else
            success = success & Asc(ActAsc)
        End If
    Next mlCnt
    eText = success
    SuperTrim = success
End Function

Public Function DoFadeOut(eHwnd As Long)
    EnableWindow eHwnd, 0
    Dim foCnt As Long
    For foCnt = 128 To 50 Step -10
        fSetTranslucency eHwnd, foCnt
        DoEvents
    Next foCnt
    EnableWindow eHwnd, 1
End Function

Public Function RevertBin(ByVal eBin As Long) As Long
    If eBin = 0 Then
        RevertBin = 1
    Else
        RevertBin = 0
    End If
End Function

Public Function GetTimeOnly(ByVal eDate As Date) As Date
    Dim TmpDate As String
    TmpDate = DatePart("h", eDate) & ":" & DatePart("n", eDate) & ":" & DatePart("s", eDate)
    GetTimeOnly = CDate(TmpDate)
End Function

Public Function DateToHexa(ByVal eDate As Date) As String
    DateToHexa = HexaCrypt(CStr(eDate))
End Function

Public Function HexaToDate(ByVal eHexa As String) As Date
    HexaToDate = CDate(HexaUncrypt(eHexa))
End Function
