代驾柱哥:定制化窗体之闪烁窗体标题栏(2)
来源:百度文库 编辑:中财网 时间:2024/04/29 22:56:08
Option Explicit
'//****************************************************************************************************************************************
'//以下是窗体过程
'//****************************************************************************************************************************************
'//以下声明API函数
'//用来设置Settimer过程。
Private Declare Function SetTimer _
Lib "user32" ( _
ByVal hwnd As Long, _
ByVal nIDEvent As Long, _
ByVal uElapse As Long, _
ByVal lpTimerfunc As Long) _
As Long
'//结束Settimer过程
Private Declare Function KillTimer _
Lib "user32" ( _
ByVal hwnd As Long, _
ByVal nIDEvent As Long) _
As Long
'//查找窗体
Private Declare Function FindWindow _
Lib "user32" _
Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) _
As Long
'//以下定义变量
Private hwnd As Long, TID As Long
'//****************************************************************************************************************************************
'// 过程
'//****************************************************************************************************************************************
Private Sub UserForm_Initialize()
'//取得窗口句柄
hwnd = FindWindow(vbNullString, Me.Caption)
'//设置Settimer 过程
TID = SetTimer(hwnd, 0, 1000, AddressOf TimeOutProc)
End Sub
'//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
'//结束Settimer过程
If TID <> 0 Then KillTimer hwnd, TID
End Sub