Reader Level:
ARTICLE

Flash Window in VB.NET

On November 10, 2012 Articles | Visual Basic .NET
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).
  • 0
  • 0
  • 8066
Download Files:
 

The FlashWindow function flashes the specified window once, whereas the FlashWindowEx function flashes a specified number of times.

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 should create a system timer. 

This API is useful when the application wants to drag the attention of the user that a particular process is complete.  

  • Run the code. A small window will open with one button 
  • Click the button "Flash". 
  • The window will start flashing at once. Irrespective of the other windows this window will flash.

Source Code

API
structure :
Public Shared Function <DllImport("user32")> _
FlashWindow(ByVal hwnd As Integer, _
ByVal bInvert As Integer) As Integer
End
Function

This API class is imported by writing the following statement. This makes the code written in the API class available to the form.

Imports FlashWindow.API

After a form is shown the button "Flash" is pressed. This enables the timer.

timer1.Interval = 2000
timer1.Enabled = True

And the following statement thus calls the API.

Dim iInt As Integer
'imports flashwindow.api imports the api class.
iInt = FlashWindow(form1.Handle, 1)

General Description

Typically, you flash a window to inform the user that the window requires attention but does not currently have the keyboard focus. When a window flashes, it appears to change from inactive to active status. An inactive caption bar changes to an active caption bar; an active caption bar changes to an inactive caption bar.

Vishal Kulkarni

Vishal Kulkarni presently working with E-Forum systems Pvt. Ltd. in Nagpur, India. He is working as a software developer. HisĀ fields of expertise are VB 6.0, VB.NET, ASP, ASP.NET, COM/DCOM, XML, XSL, ...

  • 333rank
  • 184K readers
COMMENT USING

Trending up