
'====================================================================
'' FlashWindow/FlashWindowEx demo, modal dialog as main.
'====================================================================

#include "dialogs.bas"

'====================================================================

#define FLASHW_CAPTION    1
#define FLASHW_TRAY       2
#define FLASHW_ALL        3
#define FLASHW_TIMER      4
#define FLASHW_STOP       0
#define FLASHW_TIMERNOFG  12

enum
  FW_EX
  FW_TRUE
  FW_FALSE
End enum

Function DialogProc( Byval hDlg As  HWND, _
                     Byval uMsg As UINT, _
                     Byval wParam As WPARAM, _
                     Byval lParam As LPARAM ) As Integer

  Static As FLASHWINFO fw
  Static As Integer state

  Select Case uMsg

    Case WM_INITDIALOG

      fw.cbSize = sizeof(FLASHWINFO)
      fw.hwnd = hDlg
      fw.dwTimeout = 100

      Return true

    Case WM_COMMAND

      '' The two second delay provides an opportunity to
      '' minimize the window or make some other window
      '' the foreground window.

      Select Case wParam
        Case 100
          SetTimer( hDlg, 1, 2000, null )
          state = FW_TRUE
        Case 101
          SetTimer( hDlg, 1, 2000, null )
          state = FW_FALSE
        Case 102
          fw.dwFlags = FLASHW_CAPTION
          fw.uCount = 40
          state = FW_EX
          SetTimer( hDlg, 1, 2000, null )
        Case 103
          fw.dwFlags = FLASHW_TRAY
          fw.uCount = 40
          state = FW_EX
          SetTimer( hDlg, 1, 2000, null )
        Case 104
          fw.dwFlags = FLASHW_ALL
          fw.uCount = 40
          state = FW_EX
          SetTimer( hDlg, 1, 2000, null )
        Case 105
          fw.dwFlags = FLASHW_TIMER Or FLASHW_ALL
          fw.uCount = 1000
          state = FW_EX
          SetTimer( hDlg, 1, 2000, null )
        Case 106
          fw.dwFlags = FLASHW_STOP
          KillTimer( hDlg, 1 )
          state = FW_EX
          FlashWindowEx( @fw )
        Case 107
          fw.dwFlags = FLASHW_TIMERNOFG Or FLASHW_ALL
          state = FW_EX
          SetTimer( hDlg, 1, 2000, null )
      End Select

    Case WM_TIMER

      Select Case state
        Case FW_TRUE
          KillTimer( hDlg, 1 )
          FlashWindow( hDlg, true )
          state = FW_EX
        Case FW_FALSE
          KillTimer( hDlg, 1 )
          FlashWindow( hDlg, false )
          state = FW_EX
        Case FW_EX
          KillTimer( hDlg, 1 )
          FlashWindowEx( @fw )
      End Select

    Case WM_CLOSE

      EndDialog( hDlg, null )

  End Select

  Return 0

End Function

'====================================================================

Dim As LPDLGTEMPLATE lpdt

Dialog( 8, 0, 0, 125, 140, "FlashWindow Demo", lpdt, _
        WS_SYSMENU Or WS_MINIMIZEBOX Or DS_CENTER )

PushButton( 100, -1, 5, 100, 12, " FlashWindow true ", WS_TABSTOP )
PushButton( 101, -1, 20, 100, 12, " FlashWindow false", WS_TABSTOP )
PushButton( 102, -1, 35, 100, 12, "FLASHW_CAPTION", WS_TABSTOP )
PushButton( 103, -1, 50, 100, 12, "FLASHW_TRAY", WS_TABSTOP )
PushButton( 104, -1, 65, 100, 12, "FLASHW_ALL", WS_TABSTOP )
PushButton( 105, -1, 80, 100, 12, "FLASHW_TIMER", WS_TABSTOP )
PushButton( 106, -1, 95, 100, 12, "FLASHW_STOP", WS_TABSTOP )
PushButton( 107, -1, 110, 100, 12, "FLASHW_TIMERNOFG", WS_TABSTOP )

CreateModalDialog( 0, @DialogProc, 0, lpdt )

'====================================================================
 