网站公告列表

  没有公告

加入收藏
设为首页
联系站长
您现在的位置: 网络学院 >> 程序设计 >> VB编程 >> 文章正文
  VB6中实现窗体淡入淡出            【字体:
VB6中实现窗体淡入淡出
作者:佚名    文章来源:不详    点击数:    更新时间:2007-8-6    
正在装载数据……

通过API实现窗体的淡入淡出,代码如下

添加模块,代码如下

Option Explicit
Private Declare Function GetWindowLong Lib "user32.dll" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32.dll" (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Private Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Private Const LWA_ALPHA = &H2
Private Const LWA_COLORKEY = &H1
Private Const GWL_EXSTYLE = -20
Private Const WS_EX_LAYERED = &H80000

Public Sub setfrm(frm As Form, ByVal limpid As Long) ' 设置窗体透明度
    Call SetWindowLong(frm.hWnd, GWL_EXSTYLE, GetWindowLong(frm.hWnd, GWL_EXSTYLE) Or WS_EX_LAYERED)
    Call SetLayeredWindowAttributes(frm.hWnd, 0, limpid, LWA_ALPHA)    'limpid在0--255之间
End Sub

========

窗体级变量

Option Explicit
Dim showfrm As Boolean
Dim i As Integer
Dim closefrm As Boolean

 

窗体登陆事件


Private Sub Form_Load()
Call setfrm(Me, 0)
showfrm = True
End Sub

窗体卸载事件

Private Sub Form_Unload(Cancel As Integer)
If closefrm = True Then Exit Sub
Cancel = 1
showfrm = False
Timer1.Enabled = True
End Sub

timer事件

Private Sub Timer1_Timer()
If showfrm Then
   i = i + 3
   If i >= 255 Then
        i = 255
        Timer1.Enabled = False
    End If
Else
   i = i - 2
   If i <= 0 Then
        i = 0
        closefrm = True
        Call talkewithme
        Unload Me
        Exit Sub
        Timer1.Enabled = False
    End If
End If
setfrm Me, i
End Sub

 


本文来源:http://blog.csdn.net/whgcoffee/archive/2007/07/24/1704718.aspx
站内文章搜索 高级搜索
文章录入:admin    责任编辑:admin 
  • 上一篇文章:

  • 下一篇文章:
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    最新热点 最新推荐 相关文章
     如何在ado中使用connect…
     vb 贪吃蛇 单人版游戏 (…
     关于在vb中进行com组件的…
     用vb6.0编写自我升级的程…
     vb自动登陆网络站点详解…
     vb打造超酷个性化菜单(…
  • Java Swing实现俄罗斯方块

  • c++实现系统托盘图标

  • Ajax - javascript之实现…

  • 汇编来实现OOP思想

  • 在C++实现C#中的属性(Proper…

  • 把游戏变成com组件,实现框架…

  • 在C++实现C#中的属性(Proper…

  • VB.NET类的总结(一)

  • VB.NET模块的总结(二)

  • VB.NET模块的总结(一)精简版

  •   网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    网络学院©2007 www.23book.net
    为您提供web编程,vb编程,vc编程,服务器架设管理,数据库设计等方面的知识 站长:David