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 and the Windows API function FlashWindow().  

The Code

In the window's 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 property, and then passes it to 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 property, passing the number of milliseconds between calling the 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 FlashWindow() has been added.  To add the declarations, do the following:

  1. Log out of the application.

  2. Log into the SYSPROG application.

  3. 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.....
  4. Save  the row.
  5. Run Declare_FCNS at the System Editor Exec Line to create the declaration header, as shown below:

    RUN DECLARE_FCNS 'DLL_APICALLS_USER32'
  6. Exit the editor.
  7. Log out of SYSPROG.
  8. Log into your application.
  9. Run the window.
  • No labels