|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Prerequisites |
None. |
|
This
is pretty close to the minimum code required to flash an application's
window or taskbar via the FlashWindow API using VB's
intrinsic Timer control. Flashing a window means changing the appearance of its caption bar as if the window were changing from inactive to active status, or vice versa. (An inactive caption bar changes to an active caption bar; an active caption bar changes to an inactive caption bar.) Typically, a window is flashed to inform the user that the window requires attention but that it does not currently have the keyboard focus. The FlashWindow function flashes the window only once; for repeated flashing, the application requires calling via a VB or system timer. When FlashWindow's bInvert parameter is TRUE, the window is flashed from one state to the other. If it is FALSE, the window is returned to its original state (either active or inactive). When an application is minimized and this parameter is TRUE, the taskbar window button flashes active/inactive. If it is FALSE, the taskbar window button flashes inactive, meaning that it does not change colors. It flashes, as if it were being redrawn, but it does not provide the visual invert clue to the user. With SetTimer, the nIDEvent member specifies a non-zero timer identifier. If the hwnd parameter of SetTimer is null, nIDEvent is ignored. If hwnd is non-null and the window specified by hwnd already has a timer with the value nIDEvent, then the existing timer is replaced by the new timer. When SetTimer replaces a timer, the timer is reset. Therefore, a message will be sent after the current time-out value elapses, but the previously set time-out value is ignored. The hwnd parameter specifies the handle to the window to be associated with the timer --- this window must be owned by the calling thread. If this parameter is null (0&) no window is associated with the timer and the nIDEvent parameter is ignored. |
BAS Module Code |
None. |
|
Form Code |
Add the following to a form containing a combo (Combo1), a Timer (Timer1) and two command buttons (Command1, Command2): |
|
Option Explicit '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Copyright ©1996-2011 VBnet/Randy Birch, All Rights Reserved. ' Some pages may also contain other copyrights by the author. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Distribution: You can freely use this code in your own ' applications, but you may not reproduce ' or publish this code on any web site, ' online service, or distribute as source ' on any media without express permission. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Private Declare Function FlashWindow Lib "user32" _ (ByVal hwnd As Long, _ ByVal bInvert As Long) As Long Private Sub Form_Load() With Combo1 .AddItem "50" .AddItem "100" .AddItem "250" .AddItem "500" .AddItem "1000" .ListIndex = 2 End With Command1.Caption = "Begin Flash" Command2.Caption = "Stop Flash" Timer1.Enabled = False End Sub Private Sub Command1_Click() Call FlashBegin(Me.hwnd, Val(Combo1.List(Combo1.ListIndex))) Combo1.Enabled = False Command1.Enabled = False End Sub Private Sub Command2_Click() Call FlashEnd(Me.hwnd) Command1.Enabled = True Combo1.Enabled = True End Sub Private Sub FlashBegin(ByVal hwnd As Long, ByVal Frequency As Long) If Timer1.Enabled = False Then If Frequency > 0 Then Timer1.Interval = Frequency Timer1.Enabled = True End If End If End Sub Private Sub FlashEnd(ByVal hwnd As Long) If Timer1.Enabled Then Call FlashWindow(hwnd, False) Timer1.Enabled = False End If End Sub Private Sub Timer1_Timer() Call FlashWindow(hwnd, True) End Sub |
Comments |
|
|
|
|||||
|
|||||
|
|||||
Copyright ©1996-2011 VBnet and Randy Birch. All Rights Reserved. |