Home

Add

Edit

With Linenumbers

Code in Textfield

Download

'##############################################################################################################
Dim Shared G_Screen_ReDraw  As Ubyte



'--------------------------------------------------------------------------------------------------------------
Type Vektor_2D_Type
    X   As Integer
    Y   As Integer
End Type



'--------------------------------------------------------------------------------------------------------------
Type Debug_Type
    V_FPS_Calc  As Integer
    V_FPS_Draw  As Integer
End Type



'--------------------------------------------------------------------------------------------------------------
Type Form_Mouse_Type
    V_BV        As Integer
    V_X         As Integer
    V_Y         As Integer
    V_Z         As Integer
    V_Button    As Integer
End Type
'--------------------------------------------------------------------------------------------------------------
Type Form_Control_Type
    V_InUse         As Ubyte
    
    V_Type          As Uinteger
    V_Pos           As Vektor_2D_Type
    V_Dimension     As Vektor_2D_Type
    V_Visible       As Ubyte
    V_Enable        As Ubyte
    
    T_DrawMem       As Any Ptr
    T_Redraw        As Ubyte
End Type
'--------------------------------------------------------------------------------------------------------------
Type Form_Color_Type
    V_Back          As Uinteger
    V_Border        As Uinteger
    V_BorderFill    As Uinteger
    V_Text          As Uinteger
    V_BarBack       As Uinteger
    V_BarText       As Uinteger
End Type
Type Form_Style_Type
    V_Bar           As Ubyte
    V_Border        As Ubyte
    V_ButtonMax     As Ubyte
    V_ButtonMin     As Ubyte
    V_ButtonExit    As Ubyte
End Type
Type Form_Type
    V_InUse         As Ubyte
    
    V_FID           As Uinteger
    V_Pos           As Vektor_2D_Type
    V_Dimension     As Vektor_2D_Type
    V_Visible       As Ubyte
    V_Enable        As Ubyte
    V_Color         As Form_Color_Type
    V_Style         As Form_Style_Type
    V_Caption       As String
    V_Sizeable      As Ubyte
    
    T_DrawMem       As Any Ptr
    T_Redraw        As Ubyte
    
    V_ControlD      As Form_Control_Type Ptr
    V_ControlC      As Uinteger
End Type
'--------------------------------------------------------------------------------------------------------------
Dim Shared G_FormD()        As Form_Type
Dim Shared G_FormZ()        As Uinteger
Dim Shared G_FormC          As Uinteger
Dim Shared G_FormIDC        As Uinteger
'--------------------------------------------------------------------------------------------------------------
Dim Shared G_FormMutex      As Any Ptr



'--------------------------------------------------------------------------------------------------------------
Dim Shared G_FormDefauld_Color  As Form_Color_Type
Dim Shared G_Form_Bar_Size      As Uinteger: G_Form_Bar_Size = 14
Dim Shared G_Form_Border_Size   As Uinteger: G_Form_Border_Size = 1



'--------------------------------------------------------------------------------------------------------------
Dim Shared G_Form_DebugSystem       As Ubyte: G_Form_DebugSystem = 1
Dim Shared G_Form_Debug_Time        As Double
Dim Shared G_Form_Debug_Data        As Debug_Type
Dim Shared G_Form_Debug_Last        As Debug_Type
Dim Shared G_Form_Debug_Clear       As Debug_Type



'--------------------------------------------------------------------------------------------------------------
Dim Shared G_Form_Mouse_AK      As Form_Mouse_Type
Dim Shared G_Form_Mouse_Last    As Form_Mouse_Type
Dim Shared G_Form_Mouse_Drag    As Vektor_2D_Type
Dim Shared G_Form_Mouse_Size    As Vektor_2D_Type
Dim Shared G_Form_Mouse_Pos     As Vektor_2D_Type
Dim Shared G_Form_MoveID        As Uinteger
Dim Shared G_Form_DragID        As Uinteger




'##############################################################################################################
Declare Function    MKVektor2D                  (V_X As Integer, V_Y As Integer) As Vektor_2D_Type
'--------------------------------------------------------------------------------------------------------------
Declare Function    F_Form_Add                  (V_Position As Vektor_2D_Type, V_Dimension As Vektor_2D_Type, V_Caption As String, V_Visible As Ubyte = 1, V_Enable As Ubyte = 1, V_ShowBar As Ubyte = 1, V_Sizeable As Ubyte = 1, V_Border As Ubyte = 1, V_ButtonExit As Ubyte = 1, V_ButtonMax As Ubyte = 1, V_ButtonMin As Ubyte = 1) As Integer
'--------------------------------------------------------------------------------------------------------------
Declare Function    F_Form_SetFocus             (V_FID As Uinteger) As Integer
Declare Function    F_Form_Move                 (V_FID As Uinteger, V_X As Integer, V_Y As Integer, V_MoveLock As Ubyte = 0) As Integer
Declare Function    F_Form_Resize               (V_FID As Uinteger, V_Width As Integer, V_Height As Integer) As Integer
'--------------------------------------------------------------------------------------------------------------
Declare Function    F_Form_Redraw               (V_FID As Uinteger) As Integer
Declare Function    F_Form_Refresh              () As Uinteger
'--------------------------------------------------------------------------------------------------------------
Declare Function    F_Form_CheckInput           () As Integer
Declare Function    F_Form_GetFID_OnMouse       (V_X As Integer, V_Y As Integer) As Uinteger
Declare Function    F_Form_CheckBorderDrag      (V_FID As Uinteger, V_X As Integer, V_Y As Integer) As Uinteger




'##############################################################################################################
Function MKVektor2D(V_X As Integer, V_Y As Integer) As Vektor_2D_Type
Dim T As Vektor_2D_Type
T.X = V_X
T.Y = V_Y
Return T
End Function





'##############################################################################################################
Function F_Form_Add(V_Position As Vektor_2D_Type, V_Dimension As Vektor_2D_Type, V_Caption As String, V_Visible As Ubyte = 1, V_Enable As Ubyte = 1, V_ShowBar As Ubyte = 1, V_Sizeable As Ubyte = 1, V_Border As Ubyte = 1, V_ButtonExit As Ubyte = 1, V_ButtonMax As Ubyte = 1, V_ButtonMin As Ubyte = 1) As Integer
If V_Dimension.X < G_Form_Bar_Size Or V_Dimension.Y < G_Form_Bar_Size Then Return 0
Dim FID As Uinteger
Mutexlock(G_FormMutex)
For X As Uinteger = 1 To G_FormC
    If G_FormD(X).V_InUse = 0 Then FID = X: Exit For
Next
If FID = 0 Then
    G_FormC += 1
    FID = G_FormC
    Redim Preserve G_FormD(G_FormC) As Form_Type
    Redim Preserve G_FormZ(G_FormC) As Uinteger
End If
Dim FOK As Ubyte
Do
    FOK = 1
    G_FormIDC += 1
    If G_FormIDC = 0 Then G_FormIDC = 1
    For X As Uinteger = 1 To G_FormC
        If G_FormD(X).V_InUse = 1 And G_FormD(X).V_FID = G_FormIDC Then FOK = 0: Exit For
    Next
    If FOK = 1 Then Exit Do
Loop
Dim XFIDC As Uinteger = G_FormIDC
With G_FormD(FID)
    .V_InUse        = 1
    .V_FID          = XFIDC
    .V_Enable       = V_Enable
    .V_Visible      = V_Visible
    .V_Pos          = V_Position
    .V_Dimension    = V_Dimension
    .V_Caption      = V_Caption
    .T_Redraw       = 1
    .V_Color        = G_FormDefauld_Color
    .V_Sizeable     = V_Sizeable
    With .V_Style
        .V_Bar          = V_ShowBar
        .V_Border       = V_Border
        .V_ButtonMax    = V_ButtonMax
        .V_ButtonMin    = V_ButtonMin
        .V_ButtonExit   = V_ButtonExit
    End With
    If .T_DrawMem <> 0 Then Imagedestroy(.T_DrawMem)
    .T_DrawMem      = Imagecreate(.V_Dimension.X, .V_Dimension.Y, 24)
End With
Mutexunlock(G_FormMutex)
F_Form_SetFocus(XFIDC)
Return XFIDC
End Function


'--------------------------------------------------------------------------------------------------------------
Function F_Form_Del(V_FID As Uinteger) As Integer
Mutexlock(G_FormMutex)
For X As Uinteger = 1 To G_FormC
    If G_FormD(X).V_FID = V_FID Then
        If G_FormD(X).V_InUse = 1 Then
            With G_FormD(X)
                .V_InUse = 0
                If .V_ControlC > 0 Then
                    If .V_ControlD <> 0 Then Deallocate(.V_ControlD)
                    .V_ControlD = 0
                    .V_ControlC = 0
                End If
                If .T_DrawMem <> 0 Then Imagedestroy(.T_DrawMem)
            End With
        End If
        Mutexunlock(G_FormMutex)
        Return V_FID
    End If
Next
Mutexunlock(G_FormMutex)
Return 0
End Function


'--------------------------------------------------------------------------------------------------------------
Sub F_Form_Clear()
Mutexlock(G_FormMutex)
For X As Uinteger = 1 To G_FormC
    If G_FormD(X).V_InUse = 1 Then
        With G_FormD(X)
            .V_InUse = 0
            If .V_ControlC > 0 Then
                If .V_ControlD <> 0 Then Deallocate(.V_ControlD)
                .V_ControlD = 0
                .V_ControlC = 0
            End If
            If .T_DrawMem <> 0 Then Imagedestroy(.T_DrawMem)
        End With
    End If
Next
Mutexunlock(G_FormMutex)
End Sub





'##############################################################################################################
Function F_Form_SetFocus(V_FID As Uinteger) As Integer
Mutexlock(G_FormMutex)
Dim XSID As Uinteger = 0
Dim XFID As Uinteger = 0
For X As Uinteger = 1 To G_FormC
    If G_FormZ(X) > 0 Then
        If G_FormD(G_FormZ(X)).V_FID = V_FID Then XFID = X: Exit For
    Else: If XSID = 0 Then XSID = X
    End If
Next
If XFID = 0 Then XFID = XSID
If XFID = 0 Then Mutexunlock(G_FormMutex): Return 0
If XFID = 1 And G_FormC > 1 Then Mutexunlock(G_FormMutex): Return V_FID
For X As Uinteger = XFID - 1 To 1 Step -1
    G_FormZ(X + 1) = G_FormZ(X)
Next
G_FormZ(1) = V_FID
Mutexunlock(G_FormMutex)
F_Form_Redraw(V_FID)
Return V_FID
End Function


'--------------------------------------------------------------------------------------------------------------
Function F_Form_Move(V_FID As Uinteger, V_X As Integer, V_Y As Integer, V_MoveLock As Ubyte = 0) As Integer
Mutexlock(G_FormMutex)
Dim XFID As Uinteger = 0
For X As Uinteger = 1 To G_FormC
    If G_FormD(X).V_FID = V_FID Then XFID = X: Exit For
Next
If XFID = 0 Then Mutexunlock(G_FormMutex): Return 0
With G_FormD(XFID)
    If V_MoveLock <> 1 Then .V_Pos.X = V_X
    If V_MoveLock <> 2 Then .V_Pos.Y = V_Y
End With
G_Screen_ReDraw = 1
Mutexunlock(G_FormMutex)
Return V_FID
End Function


'--------------------------------------------------------------------------------------------------------------
Function F_Form_Resize(V_FID As Uinteger, V_Width As Integer, V_Height As Integer) As Integer
Mutexlock(G_FormMutex)
Dim XFID As Uinteger = 0
For X As Uinteger = 1 To G_FormC
    If G_FormD(X).V_FID = V_FID Then XFID = X: Exit For
Next
If XFID = 0 Then Mutexunlock(G_FormMutex): Return 0
With G_FormD(XFID)
    If V_Width > 0 Then .V_Dimension.X = V_Width
    If V_Height > 0 Then .V_Dimension.Y = V_Height
    If .T_DrawMem <> 0 Then Imagedestroy(.T_DrawMem)
    .T_DrawMem = Imagecreate(.V_Dimension.X, .V_Dimension.Y, 24)
    .T_Redraw = 1
End With
G_Screen_ReDraw = 1
Mutexunlock(G_FormMutex)
Return V_FID
End Function





'##############################################################################################################
Function F_Form_Control_Add(V_FID As Uinteger, V_Type As Uinteger, V_Position As Vektor_2D_Type, V_Dimension As Vektor_2D_Type, V_Visible As Ubyte = 1, V_Enable As Ubyte = 1) As Integer
If V_Dimension.X < 1 Or V_Dimension.Y < 1 Then Return 0
Mutexlock(G_FormMutex)
Dim XFID As Uinteger = 0
For X As Uinteger = 1 To G_FormC
    If G_FormD(X).V_FID = V_FID Then XFID = X: Exit For
Next
If XFID = 0 Then Mutexunlock(G_FormMutex): Return 0
Dim XCID As Uinteger
With G_FormD(XFID)
    For X As Uinteger = 1 To .V_ControlC
        If .V_ControlD[X].V_InUse = 0 Then XCID = X: Exit For
    Next
    Dim XTCD As Form_Control_Type
    If XCID = 0 Then
        If .V_ControlC = 0 Then .V_ControlD = Allocate(Sizeof(Form_Control_Type) + 1)
        .V_ControlC += 1
        XCID = .V_ControlC
        .V_ControlD = Reallocate(.V_ControlD, Sizeof(Form_Control_Type) + 1)
    End If
    Dim FOK As Ubyte
    With XTCD
        .V_InUse        = 1
        .V_Enable       = V_Enable
        .V_Visible      = V_Visible
        .V_Pos          = V_Position
        .V_Dimension    = V_Dimension
        .T_Redraw       = 1
        If .T_DrawMem <> 0 Then Imagedestroy(.T_DrawMem)
        .T_DrawMem      = Imagecreate(.V_Dimension.X, .V_Dimension.Y, 24)
    End With
    .V_ControlD[XCID] = XTCD
    .T_Redraw = 1
End With
Mutexunlock(G_FormMutex)
G_Screen_ReDraw = 1
Return XCID
End Function





'##############################################################################################################
Function F_Form_Redraw(V_FID As Uinteger) As Integer
Mutexlock(G_FormMutex)
Dim XFID As Uinteger = 0
For X As Uinteger = 1 To G_FormC
    If G_FormD(X).V_FID = V_FID Then XFID = X: Exit For
Next
If XFID = 0 Then Mutexunlock(G_FormMutex): Return 0
If G_FormD(XFID).V_InUse = 0 Or G_FormD(XFID).T_Redraw = 0 Then Mutexunlock(G_FormMutex): Return 0
With G_FormD(XFID)
    If .V_InUse = 1 And .T_Redraw = 1 Then
        For X As Uinteger = 1 To .V_ControlC
            If .V_ControlD[X].V_InUse = 1 And .V_ControlD[X].V_Visible = 1 Then
                If .V_ControlD[X].T_Redraw = 1 Then
                    
                End If
                With .V_ControlD[X]
                    Put G_FormD(XFID).T_DrawMem, (.V_Pos.X, .V_Pos.Y), .T_DrawMem, (0, 0)-(.V_Dimension.X, .V_Dimension.Y), Pset
                End With
            End If
        Next
        Line .T_DrawMem, (0, 0)-(.V_Dimension.X - 1, .V_Dimension.Y - 1), .V_Color.V_Back, BF
        If .V_Style.V_Bar = 1 Then
            Line .T_DrawMem, (0, 0)-(.V_Dimension.X - 1, G_Form_Bar_Size + G_Form_Border_Size * 2), .V_Color.V_BarBack, BF
            If .V_Style.V_ButtonExit = 1 Then
                Draw String .T_DrawMem, (G_Form_Bar_Size * 2 + 4 + G_Form_Border_Size + 4, G_Form_Border_Size + 5), .V_Caption, .V_Color.V_BarText
            Else: Draw String .T_DrawMem, (G_Form_Border_Size + 4, G_Form_Border_Size + 5), .V_Caption, .V_Color.V_BarText
            End If
        End If
        If .V_Style.V_Border = 1 Then
            Line .T_DrawMem, (0, 0)-(.V_Dimension.X - 1, .V_Dimension.Y - 1), .V_Color.V_Border, B
            For X As Uinteger = 1 To G_Form_Border_Size
                Line .T_DrawMem, (X, X)-(.V_Dimension.X - X - 1, .V_Dimension.Y - X - 1), .V_Color.V_BorderFill, B
            Next
            If .V_Style.V_Bar = 1 Then
                Line .T_DrawMem, (G_Form_Border_Size + 1, G_Form_Bar_Size + G_Form_Border_Size + 3)-(.V_Dimension.X - G_Form_Border_Size - 2, G_Form_Bar_Size + (G_Form_Border_Size * 2) + 2), .V_Color.V_BorderFill, BF
                Line .T_DrawMem, (G_Form_Border_Size + 1, G_Form_Border_Size + 1)-(.V_Dimension.X - G_Form_Border_Size - 2, G_Form_Bar_Size + G_Form_Border_Size + 2), .V_Color.V_Border, B
                Line .T_DrawMem, (G_Form_Border_Size + 1, G_Form_Bar_Size + (G_Form_Border_Size * 2) + 3)-(.V_Dimension.X - G_Form_Border_Size - 2, .V_Dimension.Y - G_Form_Border_Size - 2), .V_Color.V_Border, B
                If .V_Style.V_ButtonMax = 1 Then
                    Line .T_DrawMem, (.V_Dimension.X - (G_Form_Border_Size + 2), G_Form_Border_Size + 2)-(.V_Dimension.X - (G_Form_Border_Size + G_Form_Bar_Size * 2 + 1), G_Form_Border_Size + G_Form_Bar_Size + 1), .V_Color.V_BorderFill, BF
                    Line .T_DrawMem, (.V_Dimension.X - (G_Form_Border_Size + 2), G_Form_Border_Size + 2)-(.V_Dimension.X - (G_Form_Border_Size + G_Form_Bar_Size * 2  + 1), G_Form_Border_Size + G_Form_Bar_Size + 1), .V_Color.V_Border, B
                End If
                If .V_Style.V_ButtonExit = 1 Then
                    Line .T_DrawMem, (G_Form_Border_Size + 2, G_Form_Border_Size + 2)-(G_Form_Border_Size + G_Form_Bar_Size * 2  + 1, G_Form_Border_Size + G_Form_Bar_Size + 1), .V_Color.V_BorderFill, BF
                    Line .T_DrawMem, (G_Form_Border_Size + 2, G_Form_Border_Size + 2)-(G_Form_Border_Size + G_Form_Bar_Size * 2  + 1, G_Form_Border_Size + G_Form_Bar_Size + 1), .V_Color.V_Border, B
                    Draw String .T_DrawMem, (G_Form_Bar_Size - (G_Form_Bar_Size / 2) + 2 + G_Form_Border_Size + 4, G_Form_Border_Size + 5), "X", .V_Color.V_BarText
                End If
            Else: Line .T_DrawMem, (G_Form_Border_Size + 1, G_Form_Border_Size + 1)-(.V_Dimension.X - G_Form_Border_Size - 2, .V_Dimension.Y - G_Form_Border_Size - 2), .V_Color.V_Border, B
            End If
        End If
        .T_Redraw = 0
    End If
End With
Mutexunlock(G_FormMutex)
G_Screen_ReDraw = 1
Return V_FID
End Function


'--------------------------------------------------------------------------------------------------------------
Function F_Form_Control_Redraw(V_FID As Uinteger) As Integer
Mutexlock(G_FormMutex)
Mutexunlock(G_FormMutex)
Return V_FID
End Function





'##############################################################################################################
Function F_Form_Refresh() As Uinteger
If G_Screen_ReDraw = 0 Then Return 0
Dim FCR As Uinteger
Dim XFID As Uinteger
Mutexlock(G_FormMutex)
For X As Uinteger = 1 To G_FormC
    If G_FormZ(X) > 0 Then
        With G_FormD(G_FormZ(X))
            If .V_InUse = 1 And .T_Redraw = 1 Then
                XFID = G_FormZ(X)
                Mutexunlock(G_FormMutex)
                F_Form_Redraw(XFID)
                Mutexlock(G_FormMutex)
                FCR += 1
            End If
        End With
    End If
Next
Screenlock
Line (0, 0)-(1024, 768), 0, BF
For X As Uinteger = G_FormC To 1 Step -1
    If G_FormZ(X) > 0 Then
        With G_FormD(G_FormZ(X))
            Put (.V_Pos.X, .V_Pos.Y), .T_DrawMem, (0, 0)-(.V_Dimension.X, .V_Dimension.Y), Pset
        End With
    End If
Next

If G_Form_DebugSystem = 1 Then
    With G_Form_Mouse_AK
        Locate 1, 1
        Print "FPS_Calc: " & G_Form_Debug_Data.V_FPS_Calc
        Print "FPS_Draw: " & G_Form_Debug_Data.V_FPS_Draw
        Print ""
        Print "Maus_X:" & .V_X
        Print "Maus_Y:" & .V_Y
        Print "Maus_Z:" & .V_Z
        Print "Maus_B:" & .V_Button
        Print ""
        Print "FormC: " & G_FormC
        Print "FormZ: ";
        For X As Uinteger = 1 To G_FormC
            Print G_FormZ(X) & " ";
        Next
        Print ""
        Print "FID_Move: " & G_Form_MoveID
        Print "FID_Drag: " & G_Form_DragID
    End With
End If

Screenunlock
If G_Form_DebugSystem = 1 Then G_Form_Debug_Last.V_FPS_Draw += 1
Mutexunlock(G_FormMutex)
Return FCR
End Function





'##############################################################################################################
Function F_Form_CheckInput() As Integer
If G_Form_DebugSystem = 1 Then
    If G_Form_Debug_Time <= Timer Then
        G_Form_Debug_Data = G_Form_Debug_Last
        G_Form_Debug_Last = G_Form_Debug_Clear
        G_Form_Debug_Time = Timer + 1
    End If
End If
Dim MX As Integer
Dim MY As Integer
Dim MZ As Integer
Dim MB As Integer
Dim BV As Integer
If G_Form_DebugSystem = 1 Then G_Form_Mouse_Last = G_Form_Mouse_AK
With G_Form_Mouse_AK
    .V_BV = Getmouse(.V_X, .V_Y, .V_Z, .V_Button)
    If .V_BV <> 0 Then
        If G_Form_DebugSystem = 1 Then F_Form_Refresh()
        Return -1 'unbekannter Fehler
    End If
    If .V_Button = -1 Then
        If G_Form_DebugSystem = 1 Then F_Form_Refresh()
        Return -2 'Keine Maus gefunden
    End If
    If .V_X = G_Form_Mouse_Last.V_X And G_Form_Mouse_Last.V_Y = .V_Y And G_Form_Mouse_Last.V_Z = .V_Z And G_Form_Mouse_Last.V_Button = .V_Button Then F_Form_Refresh(): Return 0
    G_Form_Debug_Last.V_FPS_Calc += 1
    Dim XFID As Uinteger
    If .V_Button = 1 Then
        If G_Form_MoveID = 0 Then
            XFID = F_Form_GetFID_OnMouse(.V_X, .V_Y)
            If XFID > 0 Then
                G_Form_DragID = F_Form_CheckBorderDrag(XFID, .V_X, .V_Y)
                If G_Form_Mouse_Last.V_Button = 0 Then
                    G_Form_MoveID = XFID
                    Mutexlock(G_FormMutex)
                    If G_Form_DragID > 0 Then
                        G_Form_Mouse_Drag.X = .V_X
                        G_Form_Mouse_Drag.Y = .V_Y
                        G_Form_Mouse_Size = G_FormD(XFID).V_Dimension
                    End If
                    G_Form_Mouse_Pos.X = G_FormD(XFID).V_Pos.X - .V_X
                    G_Form_Mouse_Pos.Y = G_FormD(XFID).V_Pos.Y - .V_Y
                    Mutexunlock(G_FormMutex)
                    F_Form_SetFocus(XFID)
                End If
            Else: G_Form_DragID = 0
            End If
        Else
            If G_Form_MoveID > 0 Then
                Select Case G_Form_DragID
                    Case 0: If F_Form_Move(G_Form_MoveID, G_Form_Mouse_Pos.X + .V_X, G_Form_Mouse_Pos.Y + .V_Y) = 0 Then G_Form_MoveID = 0
                    Case 1
                        If F_Form_Resize(G_Form_MoveID, G_Form_Mouse_Size.X - .V_X + G_Form_Mouse_Drag.X, 0) = 0 Then G_Form_MoveID = 0
                        If F_Form_Move(G_Form_MoveID, G_Form_Mouse_Drag.X + .V_X - G_Form_Mouse_Drag.X + G_Form_Mouse_Pos.X, 0, 2) = 0 Then G_Form_MoveID = 0
                    Case 2: If F_Form_Resize(G_Form_MoveID, G_Form_Mouse_Size.X + .V_X - G_Form_Mouse_Drag.X, 0) = 0 Then G_Form_MoveID = 0
                    Case 4
                        If F_Form_Resize(G_Form_MoveID, 0, G_Form_Mouse_Size.Y - .V_Y + G_Form_Mouse_Drag.Y) = 0 Then G_Form_MoveID = 0
                        If F_Form_Move(G_Form_MoveID, 0, G_Form_Mouse_Drag.Y + .V_Y - G_Form_Mouse_Drag.Y + G_Form_Mouse_Pos.Y, 1) = 0 Then G_Form_MoveID = 0
                    Case 8: If F_Form_Resize(G_Form_MoveID, 0, G_Form_Mouse_Size.Y + .V_Y - G_Form_Mouse_Drag.Y) = 0 Then G_Form_MoveID = 0
                    Case 5
                        If F_Form_Resize(G_Form_MoveID, G_Form_Mouse_Size.X - .V_X + G_Form_Mouse_Drag.X, G_Form_Mouse_Size.Y - .V_Y + G_Form_Mouse_Drag.Y) = 0 Then G_Form_MoveID = 0                      
                        If F_Form_Move(G_Form_MoveID, G_Form_Mouse_Drag.X + .V_X - G_Form_Mouse_Drag.X + G_Form_Mouse_Pos.X, G_Form_Mouse_Drag.Y + .V_Y - G_Form_Mouse_Drag.Y + G_Form_Mouse_Pos.Y, 0) = 0 Then G_Form_MoveID = 0
                    Case 6
                        If F_Form_Resize(G_Form_MoveID, G_Form_Mouse_Size.X + .V_X - G_Form_Mouse_Drag.X, G_Form_Mouse_Size.Y - .V_Y + G_Form_Mouse_Drag.Y) = 0 Then G_Form_MoveID = 0
                        If F_Form_Move(G_Form_MoveID, 0, G_Form_Mouse_Drag.Y + .V_Y - G_Form_Mouse_Drag.Y + G_Form_Mouse_Pos.Y, 1) = 0 Then G_Form_MoveID = 0
                    Case 9
                        If F_Form_Resize(G_Form_MoveID, G_Form_Mouse_Size.X - .V_X + G_Form_Mouse_Drag.X, G_Form_Mouse_Size.Y + .V_Y - G_Form_Mouse_Drag.Y) = 0 Then G_Form_MoveID = 0
                        If F_Form_Move(G_Form_MoveID, G_Form_Mouse_Drag.X + .V_X - G_Form_Mouse_Drag.X + G_Form_Mouse_Pos.X, 0, 2) = 0 Then G_Form_MoveID = 0
                    Case 10: If F_Form_Resize(G_Form_MoveID, G_Form_Mouse_Size.X + .V_X - G_Form_Mouse_Drag.X, G_Form_Mouse_Size.Y + .V_Y - G_Form_Mouse_Drag.Y) = 0 Then G_Form_MoveID = 0
                End Select
            End If
        End If
    Else
        G_Form_MoveID = 0
        G_Form_DragID = 0
    End If
    F_Form_Refresh()
End With
Return XFID
End Function


'--------------------------------------------------------------------------------------------------------------
Function F_Form_GetFID_OnMouse(V_X As Integer, V_Y As Integer) As Uinteger
Mutexlock(G_FormMutex)
For X As Uinteger = 1 To G_FormC
    With G_FormD(G_FormZ(X))
        If .V_InUse = 1 And .V_Visible = 1 Then
            If V_X >= .V_Pos.X And V_X <= .V_Pos.X + .V_Dimension.X And V_Y >= .V_Pos.Y And V_Y <= .V_Pos.Y + .V_Dimension.Y Then
                Dim XFID As Uinteger = G_FormD(G_FormZ(X)).V_FID
                Mutexunlock(G_FormMutex)
                Return XFID
            End If
        End If
    End With
Next
Mutexunlock(G_FormMutex)
Return 0
End Function


'--------------------------------------------------------------------------------------------------------------
Function F_Form_CheckBorderDrag(V_FID As Uinteger, V_X As Integer, V_Y As Integer) As Uinteger
Mutexlock(G_FormMutex)
Dim XFID As Uinteger = 0
For X As Uinteger = 1 To G_FormC
    If G_FormD(X).V_FID = V_FID Then XFID = X: Exit For
Next
If XFID = 0 Then Mutexunlock(G_FormMutex): Return 0
If G_FormD(XFID).V_InUse = 0 Then Mutexunlock(G_FormMutex): Return 0
Dim XDID As Uinteger
With G_FormD(XFID)
    If V_X >= .V_Pos.X And V_X <= .V_Pos.X + G_Form_Border_Size + 2 Then XDID = XDID Or 1
    If V_X <= .V_Pos.X + .V_Dimension.X And V_X >= .V_Pos.X + .V_Dimension.X - G_Form_Border_Size - 2 Then XDID = XDID Or 2
    If V_Y >= .V_Pos.Y And V_Y <= .V_Pos.Y + G_Form_Border_Size + 2 Then XDID = XDID Or 4
    If V_Y <= .V_Pos.Y + .V_Dimension.Y And V_Y >= .V_Pos.Y + .V_Dimension.Y - G_Form_Border_Size - 2 Then XDID = XDID Or 8
End With
Mutexunlock(G_FormMutex)
Return XDID
End Function