hey guy can you help in this one close the form and it will slowly disappear
Printable View
hey guy can you help in this one close the form and it will slowly disappear
Hi,
In the Form_Closing event, use e.cancel to stop it. Then activate a timer with suitable interval (e.g. 100) which changes the Opacity property of the form in question to "Opacity - 10". Include a check so that if Opacity <=0 then you can finally close the form. In the Form_Closing event, you'll also want to check the Opacity so that you only do the disappearing act if it hasn't already been done.
HTH
zaza
You have to intercept form's closing event and there you have to decrease form's opacity from 1 to 0, for example in 0.05 step, using a timer....I think! :rolleyes:
thank you zaza ! that would be a great help another thing , in vb 6 how can i do this ?
Here is how you can do form transparency in VB6. This demo uses a slider control
to adjust the transparency in and out. Windows 2000+ though.
HTHVB Code:
Option Explicit 'Add a slider control to the project (Slider1) Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" _ (ByVal lpLibFileName As String) As Long Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, _ ByVal lpProcName As String) As Long Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule 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 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 Const GWL_EXSTYLE = (-20) Private Const WS_EX_LAYERED = &H80000 Private Const LWA_ALPHA = &H2 Private mlHwnd As Long Public Sub AlphaBlendForm(ByVal lHwnd As Long, ByVal intTranslucenceLevel As Integer) If APIExists("SetLayeredWindowAttributes", "User32") Then SetWindowLong lHwnd, GWL_EXSTYLE, WS_EX_LAYERED SetLayeredWindowAttributes lHwnd, 0, intTranslucenceLevel, LWA_ALPHA Else MsgBox "Your OS does not support Alpha Blending.", vbExclamation, "Alpha Blend" End If End Sub Public Function APIExists(ByVal pstrFunctionName As String, ByVal pstrDllName As String) As Boolean Dim lngHandle As Long Dim lngAddr As Long lngHandle = LoadLibrary(pstrDllName) If Not (lngHandle = 0) Then lngAddr = GetProcAddress(lngHandle, pstrFunctionName) FreeLibrary lngHandle End If APIExists = Not (lngAddr = 0) End Function Private Sub Form_Load() Slider1.Max = 255 Slider1.Min = 10 Slider1.LargeChange = 5 If mlHwnd = 0 Then mlHwnd = Me.hwnd End If AlphaBlendForm mlHwnd, 255 'MAX VALUE = OPAIC/ MIN VALUE = 0 CANT SEE Slider1.Value = 255 End Sub Private Sub Slider1_Scroll() AlphaBlendForm mlHwnd, Slider1.Value End Sub
thanks for the help but how do it in closing the form .......i want something like when i close the form it will slowly disappear
thanks a lot
Place a timer on your form and in the timer1_timer event you call the procedure AlphaBlendForm
passing a variable (which would be dimmed as a static var in the timer procedure)
decrementing from 255 to 0.
thanks for you help guys