' modulo di classe per ridurre a icona la useform
'Chiamo le API
Private Declare Function FindWindow Lib "user32" _
Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
'prende lo stile corrente
Private Declare Function GetWindowLong Lib "user32" _
Alias "GetWindowLongA" _
(ByVal hWnd As Long, _
ByVal nIndex As Long) As Long
'Imposta il nuovo stile
Private Declare Function SetWindowLong Lib "user32" _
Alias "SetWindowLongA" (ByVal hWnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Private Declare Function DrawMenuBar Lib "user32" _
(ByVal hWnd As Long) As Long
Private Declare Function SetFocus Lib "user32" _
(ByVal hWnd As Long) As Long
'stile della finestra
Private Const GWL_STYLE As Long = (-16)
'stile della finestra esteso
Private Const GWL_EXSTYLE As Long = (-20)
'imposta barra del titolo
Private Const WS_CAPTION As Long = &HC00000
'imposta barra di chiusura
Private Const WS_SYSMENU As Long = &H80000
'imposta finestra ridimensionabile
Private Const WS_THICKFRAME As Long = &H40000
'imposta pulsante riduci
Private Const WS_MINIMIZEBOX As Long = &H20000
'imposta pulsante ingrandisci
Private Const WS_MAXIMIZEBOX As Long = &H10000
Private mhWndForm As Long
'Imposto le nuove proprietà
Public Property Set Form(oForm As Object)
'Ottengo le impostazioni di UserForm in base alle versioni
If Val(Application.Version) < 9 Then
'Excel 97
mhWndForm = FindWindow("ThunderXFrame", oForm.Caption)
Else
'Excel 2000 o superiori
mhWndForm = FindWindow("ThunderDFrame", oForm.Caption)
End If
SetFormStyle
End Property
Private Sub SetFormStyle()
Dim lStyle As Long
lStyle = GetWindowLong(mhWndForm, GWL_STYLE)
'(1) Crea una finestra senza barra del titolo
'SetWindowLong mhWndForm, GWL_STYLE, lStyle And Not WS_CAPTION
'(2) Crea una finestra senza pulsante di chiusura
'SetWindowLong mhWndForm, GWL_STYLE, lStyle And Not WS_SYSMENU
'(3) Crea una finestra ridimensionabile
'SetWindowLong mhWndForm, GWL_STYLE, lStyle Or WS_THICKFRAME
'(4) Crea una finestra ridimensionabile e riducibile a icona
SetWindowLong mhWndForm, GWL_STYLE, lStyle _
Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX
'Aggiorno i cambiamenti
DrawMenuBar mhWndForm
SetFocus mhWndForm
End Sub
///////////////////////////////////////////////////////////////////////////////
' questa invece sulla useform
Option Explicit
#If Win64 Then
Private Declare PtrSafe Function FindWindow& Lib "user32" _
Alias "FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String)
Private Declare PtrSafe Function SetWindowLong& Lib "user32" Alias _
"SetWindowLongA" (ByVal hWnd&, ByVal nIndex&, _
ByVal dwNewLong As LongLong)
Private Declare PtrSafe Function EnableWindow& Lib "user32" _
(ByVal hWnd As LongLong, ByVal fEnable As LongLong)
Private Declare PtrSafe Function ShowWindow& Lib "user32" _
(ByVal hWnd As LongLong, ByVal nCmdShow As LongLong)
#Else
Private Declare Function FindWindow& Lib "user32" _
Alias "FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String)
Private Declare Function SetWindowLong& Lib "user32" Alias _
"SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long)
Private Declare Function EnableWindow& Lib "user32" _
(ByVal hWnd As Long, ByVal fEnable As Long)
Private Declare Function ShowWindow& Lib "user32" _
(ByVal hWnd As Long, ByVal nCmdShow As Long)
#End If
/////////////////////////////////////////////////////////
' questa è per popolare le texbox
Public Sub mPopolaTextBox()
Dim lng As Long
Set sh = ThisWorkbook.Worksheets("Pianificazione_indoor")
With sh
For lng = 3 To lRiga
If .Range("A" & lng).Value = _
Me.ListBox1.List(Me.ListBox1.ListIndex, 0) Then
Me.TextBox1.Text = .Range("B" & lng).Value ' lancio
Me.TextBox68.Text = .Range("C" & lng).Value ' cliente
Me.TextBox53.Text = .Range("D" & lng).Value ' data
Me.TextBox3.Text = .Range("E" & lng).Value ' commessa
Me.TextBox4.Text = .Range("F" & lng).Value ' Descrizione
Me.TextBox5.Text = .Range("G" & lng).Value ' prodotto
Me.TextBox7.Text = .Range("H" & lng).Value ' descr.
Me.TextBox8.Text = .Range("I" & lng).Value ' Quantità
Me.TextBox54.Text = .Range("J" & lng).Value ' Data
Me.TextBox10.Text = .Range("K" & lng).Value ' Note
Me.TextBox12.Text = .Range("M" & lng).Value ' Stato
Me.TextBox14.Text = .Range("N" & lng).Value '
Me.TextBox15.Text = .Range("O" & lng).Value '
Me.TextBox16.Text = .Range("P" & lng).Value ' Ore
Me.TextBox17.Text = .Range("Q" & lng).Value ' data
Me.TextBox47.Text = .Range("R" & lng).Value ' Inizio
Me.TextBox18.Text = .Range("S" & lng).Value ' FINE
.
Me.TextBox48.Text = .Range("T" & lng).Value ' Fine
Me.TextBox32.Text = .Range("U" & lng).Value ' FINE
Me.TextBox61.Text = .Range("V" & lng).Value ' FINE
Me.TextBox62.Text = .Range("W" & lng).Value ' NOTE.
Me.TextBox26.Text = .Range("X" & lng).Value ' Data
Me.TextBox20.Text = .Range("Y" & lng).Value '
Me.TextBox21.Text = .Range("Z" & lng).Value ' Data
Me.TextBox65.Text = .Range("AA" & lng).Value ' NOTE
Me.TextBox22.Text = .Range("AB" & lng).Value '
Me.TextBox66.Text = .Range("AC" & lng).Value ' NOTE
Me.TextBox19.Text = .Range("AD" & lng).Value '
Me.TextBox23.Text = .Range("AE" & lng).Value '
Me.TextBox70.Text = .Range("AF" & lng).Value '
Me.TextBox24.Text = .Range("AG" & lng).Value '
Me.TextBox25.Text = .Range("AH" & lng).Value '
Me.TextBox67.Text = .Range("AI" & lng).Value '
Me.TextBox58.Text = .Range("AJ" & lng).Value '
Me.TextBox59.Text = .Range("AK" & lng).Value '
Me.TextBox27.Text = .Range("AL" & lng).Value '
Me.TextBox28.Text = .Range("AM" & lng).Value '
Me.TextBox29.Text = .Range("AN" & lng).Value '
Me.TextBox30.Text = .Range("AO" & lng).Value '
Me.TextBox31.Text = .Range("AP" & lng).Value '
dato1 = .Range("AL" & lng).Value '
dato2 = .Range("AM" & lng).Value '
dato3 = .Range("AN" & lng).Value '
dato4 = .Range("AO" & lng).Value '
dato5 = .Range("AP" & lng).Value '
Me.TextBox34.Text = Me.TextBox1.Text '
Me.TextBox69.Text = Me.TextBox68.Text '
Me.TextBox49.Text = Me.TextBox53.Text '
Me.TextBox36.Text = Me.TextBox3.Text '
Me.TextBox33.Text = Me.TextBox4.Text '
Me.TextBox35.Text = Me.TextBox5.Text '
Me.TextBox37.Text = Me.TextBox7.Text '
Me.TextBox38.Text = Me.TextBox8.Text '
Me.TextBox50.Text = Me.TextBox54.Text '
Me.TextBox39.Text = Me.TextBox10.Text '
Me.TextBox40.Text = Me.TextBox12.Text '
Me.TextBox41.Text = Me.TextBox14.Text '
Me.TextBox42.Text = Me.TextBox15.Text '
Me.TextBox43.Text = Me.TextBox17.Text '
Me.TextBox63.Text = Me.TextBox16.Text '
Me.TextBox64.Text = Me.TextBox62.Text '
Me.TextBox51.Text = .Range("R" & lng).Value
Me.TextBox60.Text = .Range("S" & lng).Value '
Me.TextBox44.Text = .Range("T" & lng).Value '
Me.TextBox46.Text = .Range("U" & lng).Value
Me.TextBox52.Text = .Range("V" & lng).Value
Me.TextBox62.Text = .Range("W" & lng).Value
End If
Next
End With
End Sub
|