|
-
Feb 20th, 2005, 07:20 AM
#1
Thread Starter
Junior Member
form transparency
hey guy can you help in this one close the form and it will slowly disappear
Last edited by thermo_ll; Feb 21st, 2005 at 08:50 AM.
-
Feb 20th, 2005, 10:34 AM
#2
Re: form transparency
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
-
Feb 20th, 2005, 10:40 AM
#3
Hyperactive Member
Re: form transparency
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!
Live long and prosper (Mr. Spock)
-
Feb 21st, 2005, 12:27 AM
#4
Thread Starter
Junior Member
Re: form transparency
thank you zaza ! that would be a great help another thing , in vb 6 how can i do this ?
-
Feb 21st, 2005, 12:39 AM
#5
Re: form transparency
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.
VB 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
HTH
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 21st, 2005, 01:00 AM
#6
Thread Starter
Junior Member
Re: form transparency
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
-
Feb 21st, 2005, 01:09 AM
#7
Re: form transparency
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.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 21st, 2005, 08:49 AM
#8
Thread Starter
Junior Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|