Ciao Scorpion69,
posto un esempio di dissolvenza sia all'avvio del prog., sia in chiusura. In un modulo della Frm inserisci un controllo Image che prenda tutta la superfice della Frm, un CmdButton e due Lbl (Label1 Label2). Poi inserisci una Bmp in un file di risorse, che servirà come sfondo della Frm.
Inserisci nel modulo della Frm:
codice:
Dim sglSZ As Single
Dim sglSZ2 As Single
'---------------------------------------------------------------
Private Sub Form_Load()
' Stabilisce le dimensioni della Frm:
With Form1
.Top = 0
.Left = 0
.Height = 11520
.Width = 15360
End With
' Carica Immagine Sfondo - Sfondo7xyy3.bmp:
Set Form1.Image1.Picture = LoadResPicture(101, vbResBitmap)
With Form1.Image1
.Top = 100
.Left = 100
.Height = 10620
.Width = 14880
End With
Dim t As Single
' Proprietà della Label con testo scorrevole:
With Label1
.AutoSize = True
.WordWrap = False
.Caption = "APPLICAZIONI ...... "
sglSZ = .Width
End With
With Label2
.AutoSize = True
.WordWrap = False
.Caption = "Determinazione del ....... "
sglSZ2 = .Width
End With
' La Frm si materializza ed il testo scorre:
For t = 0 To 254 Step 15
FormFade Form1, t
Label1.Width = (t * (sglSZ / 255))
Label2.Width = (t * (sglSZ2 / 255))
Next t
't = Opacity = Max 255
Form1.Refresh
Form1.Image1.Refresh
End Sub
'---------------------------------------------------------------
Private Sub Command1_Click()
Dim p As Single
' La Frm si Dematerializza ed il testo scorre:
For p = 0 To 254 Step 15
FormFade Form1, (255 - p)
Label1.Width = sglSZ - (p * (sglSZ / 255))
Label2.Width = sglSZ2 - (p * (sglSZ2 / 255))
Next p
' Chiude la Frm:
End
End Sub
Inserisci in un Modulo bas:
codice:
Private Const GWL_EXSTYLE = (-20)
Private Const LWA_ALPHA = &H2
Private Const WS_EX_LAYERED = &H80000
Private Declare Function SetLayeredWindowAttributes _
Lib "user32" _
(ByVal hwnd As Long, _
ByVal crKey As Long, _
ByVal bAlpha As Byte, _
ByVal dwFlags As Long) As Long
Private Declare Function GetWindowLong _
Lib "user32" Alias "GetWindowLongA" _
(ByVal hwnd As Long, _
ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong _
Lib "user32" Alias "SetWindowLongA" _
(ByVal hwnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
'------------------------------------------------------------------
Public Sub FormFade(ByRef frmForm As Form, ByVal Opacity As Long)
Dim Msg As Long
frmForm.Show vbModeless
Msg = GetWindowLong(frmForm.hwnd, GWL_EXSTYLE)
Msg = Msg Or WS_EX_LAYERED
SetWindowLong frmForm.hwnd, GWL_EXSTYLE, Msg
SetLayeredWindowAttributes frmForm.hwnd, 0, Opacity, LWA_ALPHA
frmForm.Refresh
End Sub