Dim lngRet As Long ' Don't start flashing yet Timer1.Enabled = False lngRet = FlashWindow(Me.hwnd, 0)
End Sub
在窗体中放一个Timer控件Timer1,设置其Inteval=200 *API函数声明 Private Declare Function FlashWindow Lib "user32" (ByVal hwnd As Long, ByVal bInvert As Long) As Long 注释:在窗体中写下如下代码: Private Sub Timer1_Timer() FlashWindow Me.hwnd, True End Sub
Private Declare Function FlashWindow Lib "user32" (ByVal hwnd As Long, ByVal bInvert As Long) As Long 然后每次 FlashWindow Me.hwnd, True 会使窗口闪烁一次
如果需要我有例子。
[email protected]
Private Declare Function FlashWindow Lib "user32" (ByVal hwnd As Long, ByVal bInvert As Long) As Long
Private Sub timer1_Timer()
Dim lngRet As Long
' Flash the window
lngRet = FlashWindow(Me.hwnd, 1)
End SubPrivate Sub Command1_Click() ' Flash every 0.5 seconds
Timer1.Interval = 500
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
'first Don't start flashing
Timer1.Enabled = False
End SubPrivate Sub Command2_Click()
Dim lngRet As Long
' Don't start flashing yet
Timer1.Enabled = False
lngRet = FlashWindow(Me.hwnd, 0)
End Sub
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton Command2
Caption = "Command2"
Height = 615
Left = 2040
TabIndex = 1
Top = 1800
Width = 855
End
Begin VB.Timer Timer1
Left = 240
Top = 720
End
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 615
Left = 480
TabIndex = 0
Top = 1800
Width = 975
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Declare Function FlashWindow Lib "user32" (ByVal hwnd As Long, ByVal bInvert As Long) As Long
Private Sub timer1_Timer()
Dim lngRet As Long
' Flash the window
lngRet = FlashWindow(Me.hwnd, 1)
End SubPrivate Sub Command1_Click() ' Flash every 0.5 seconds
Timer1.Interval = 500
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
'first Don't start flashing
Timer1.Enabled = False
End SubPrivate Sub Command2_Click()
Dim lngRet As Long
' Don't start flashing yet
Timer1.Enabled = False
lngRet = FlashWindow(Me.hwnd, 0)
End Sub
*API函数声明
Private Declare Function FlashWindow Lib "user32" (ByVal hwnd As Long, ByVal bInvert As Long) As Long
注释:在窗体中写下如下代码:
Private Sub Timer1_Timer()
FlashWindow Me.hwnd, True
End Sub
然后每次 FlashWindow Me.hwnd, True 会使窗口闪烁一次