473,385 Members | 1,324 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to fade a form in?

please help me find out.. i have tried to reverse enginere the fade out code but it just isnt working

thanks
Oct 9 '07 #1
3 1058
Killer42
8,435 Expert 8TB
please help me find out.. i have tried to reverse enginere the fade out code but it just isnt working
I'd suggest you take some time to play with it and understand how it works. I've just had a quick play and was able to get it to fade in. You just have to make sure you reverse the starting and ending conditions, and the "- 25".
Oct 9 '07 #2
Ali Rizwan
925 512MB
please help me find out.. i have tried to reverse enginere the fade out code but it just isnt working

thanks
I have made fade in and out effects to my form.
use this code.

add a timer name tmr

Expand|Select|Wrap|Line Numbers
  1. Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
  2.    (ByVal hwnd As Long, ByVal nIndex As Long) As Long
  3. Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
  4.    (ByVal hwnd As Long, ByVal nIndex As Long, _
  5.    ByVal dwNewLong As Long) As Long
  6. Private Const GWL_STYLE = (-16)
  7. Private Const GWL_EXSTYLE = (-20)
  8. Private Declare Function SetLayeredWindowAttributes Lib "user32" _
  9.    (ByVal hwnd As Long, ByVal crKey As Long, _
  10.    ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
  11. Private Const LWA_COLORKEY = &H1
  12. Private Const LWA_ALPHA = &H2
  13. Private Const WS_EX_LAYERED = &H80000
  14.  
  15.  
  16. Private m_lAlpha As Long
  17.  
  18. Dim lStyle As Long
  19. Dim lAlpha
  20.  
  21.  
  22.  
  23. Private Sub Form_Load()
  24.  
  25. m_lAlpha = 255
  26.  
  27.    If (m_lAlpha = 255) Then
  28.  
  29.       lStyle = GetWindowLong(Me.hwnd, GWL_EXSTYLE)
  30.       lStyle = lStyle Or WS_EX_LAYERED
  31.       SetWindowLong Me.hwnd, GWL_EXSTYLE, lStyle
  32.    End If
  33.  
  34.    m_lAlpha = m_lAlpha - 255
  35.    lAlpha = m_lAlpha
  36.    If (lAlpha < 0) Then
  37.       lAlpha = 0
  38.    End If
  39.  
  40. end sub
  41.  
  42. Private Sub tmr_Timer()
  43.  
  44. If (m_lAlpha = 255) Then
  45.  
  46.       lStyle = GetWindowLong(Me.hwnd, GWL_EXSTYLE)
  47.       lStyle = lStyle Or WS_EX_LAYERED
  48.       SetWindowLong Me.hwnd, GWL_EXSTYLE, lStyle
  49.    End If
  50.  
  51.    m_lAlpha = m_lAlpha + 25
  52.    lAlpha = m_lAlpha
  53.    If (lAlpha > 150) Then
  54.       lAlpha = 150
  55.    End If
  56.    SetLayeredWindowAttributes Me.hwnd, 150, lAlpha, LWA_ALPHA
  57.    If (m_lAlpha > 150) Then
  58.       m_lAlpha = 150
  59.       tmr.Enabled = False
  60.    End If
  61. End If
  62.  
  63. End Sub
  64.  
  65.  
Set timer interval to 40 and play the form
When you play the form there is a transperancy in form if you dont want this in timer code replace 150 to 255
Oct 9 '07 #3
Killer42
8,435 Expert 8TB
hannibaal, if you have a look at Ali's other thread in the Articles area, I've added an example which shows both fade in and out effects when you click buttons. It also includes some comments, and I tried to simplify the code down to the bare minimum.
Oct 9 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Robert Skidmore | last post by:
I am building an application that will fade one panel to another panel. Both panels will have picture boxes in them (thumbnails). This is what I have tried: private void...
1
by: Robert Skidmore | last post by:
I am building an application that will fade one panel to another panel. Both panels will have picture boxes in them (thumbnails). This is what I have tried: private void...
1
by: Cylix | last post by:
I have a form with a irregular background image, let say a circle. I would like the form shows and that fade out and close slowly. I have already done the fade out part by the timmer to set the...
0
by: tristanlbailey | last post by:
I have been attempting to solve this problem for a few weeks now, but I'm not having much luck... I would like to create a seamless fading effect on each form/window in my program; one that, when...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.