Attribute VB_Name = "modDeclaration"
Option Explicit

Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Declare Function GetTextExtentPoint Lib "gdi32" Alias _
    "GetTextExtentPointA" (ByVal Hdc As Long, ByVal lpsz As String, _
    ByVal cbString As Long, lpSIZE As Size) As Long



Type Size
    cx As Long
    cy As Long
End Type

Public Const cEcart = 30
Public Const cNonAffecter = "Non affecter"
Public Const cVide = "Vide"
Public Const cNonVide = "Non Vide"

Public Sub RetailleLvw(Hdc As Long, lvw As ListView)
Dim Itm     As ListItem
Dim Col     As ColumnHeader
Dim lngCount As Long
Dim mSIZE   As Size
Dim strText As String
Dim Max     As Long
Dim SousItm As ListItem


    With lvw
        .Visible = False
        For Each Col In .ColumnHeaders
            lngCount = lngCount + 1
            strText = Col
            GetTextExtentPoint Hdc, strText, Len(strText), mSIZE
            Max = mSIZE.cx
            
            For Each Itm In .ListItems
                If lngCount = 1 Then
                    strText = Itm
                Else
                    strText = Itm.SubItems(lngCount - 1)
                End If
                GetTextExtentPoint Hdc, strText, Len(strText), mSIZE
                If mSIZE.cx > Max Then
                    Max = mSIZE.cx
                End If
                            
            Next Itm
            If Max = 0 Then
                Col.Width = 0
            Else
                Col.Width = (Max * 15) + 195
                If lngCount = 1 And .CheckBoxes Then
                    Col.Width = Col.Width + 180
                End If
            End If
        Next Col
        
        .Visible = True
        
    End With
    
    
    
End Sub
