====== Flashing a Window ====== If a critical error condition occurs in a program, a visual cue such as flashing a window will more likely draw the user's attention to the problem. This topic shows how to flash a window every 1/2 second, using the window's [[TIMER_event|TIMER event]] and the Windows API function [[https://msdn.microsoft.com/library/default.asp?url=/library/en-us/debug/base/flashwindow.asp|FlashWindow().]] === The Code === In the window's [[TIMER_event|TIMER event]], code the following: declare function FlashWindow hwnd = Get_Property(@window , 'HANDLE') invert = 1 fv = FlashWindow (hwnd, invert) The code gets the window's [[HANDLE|HANDLE property]], and then passes it to [[https://msdn.microsoft.com/library/default.asp?url=/library/en-us/debug/base/flashwindow.asp|FlashWindow(),]] with the second argument (invert) indicating that the window should be flashed. To start the flashing effect, simply start the timer by setting the [[TIMER|TIMER property]], passing the number of milliseconds between calling the [[TIMER_event|TIMER event]]. To flash the window every 1/2 second (500 milliseconds), code the following: rv = Set_Property(@window , 'TIMER', 500) To turn off the flashing, disable the call to the TIMER event by passing a 0, as shown below: rv = Set_Property(@window , 'TIMER', 0) === The Windows API Declaration === The code above will not run until the declaration for [[https://msdn.microsoft.com/library/default.asp?url=/library/en-us/debug/base/flashwindow.asp|FlashWindow()]] has been added. To add the declarations, do the following: * Log out of the application. * Log into the SYSPROG application. * Add a row, (call it DLL_APICALLS_USER32), with the first line as USER32 and containing the declaration as shown below. USER32 ULONG STDCALL FlashWindow (ULONG, ULONG) //....add any other declarations in USER32 here..... * Save the row. * Run [[declare_FCNS|Declare_FCNS]] at the System Editor Exec Line to create the declaration header, as shown below: RUN DECLARE_FCNS 'DLL_APICALLS_USER32' * Exit the editor. * Log out of SYSPROG. * Log into your application. * Run the window.