Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fading Forms just like Windows 2000? 2

Status
Not open for further replies.

hellferret

Programmer
Mar 15, 2001
91
0
0
GB
I'm assuming that the nice whizzy way that Windows 2000 fades in menus is done with an API call.

Anyone know how to do this?
 
not yet, I'm waiting for Dan Applemans API book for Win2k :) Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
I'm making a little bit of progress with this.

This will declare the API...

Public Declare Function AnimateWindow Lib "user32" (ByVal hWnd As Long, ByVal Tm As Long, ByVal Flags As Long) As Boolean

And putting this before you open your form will make it fade in.

DUMMY = AnimateWindow(hWnd, 500, 524288)

Unfortunately the controls on the form don't fade in with the form. I'm going to work on it - but if anyone has any ideas then I'll be gratified to the point of undulating like a baboon on heat.
 
Think I've got it. Have a look at this:

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
Private Declare Function SetLayeredWindowAttributes Lib "user32" _
(ByVal hwnd As Long, ByVal crey As Byte, ByVal bAlpha As Byte, _
ByVal dwFlags As Long) As Long

Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_LAYERED = &H80000
Private Const WS_EX_TRANSPARENT = &H20&
Private Const LWA_ALPHA = &H2&

Option Explicit

Private Sub Form_Load()
Dim lOldStyle As Long
Dim bTrans As Byte ' The level of transparency (0 - 255)
Dim ct, ct2 As Integer

bTrans = 128
lOldStyle = GetWindowLong(Me.hwnd, GWL_EXSTYLE)
SetWindowLong Me.hwnd, GWL_EXSTYLE, lOldStyle Or WS_EX_LAYERED
SetLayeredWindowAttributes Me.hwnd, 0, 0, LWA_ALPHA
Me.Visible = True

Me.Refresh
For ct = 0 To 255 Step 2
SetLayeredWindowAttributes Me.hwnd, 0, ct, LWA_ALPHA
Next ct
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top