; Calaym - Media player GUI for sound systems
; Copyright (C) 2002-2015 Jan Vorel
;
; You can redistribute the official software packages under the terms of the
; User-friendly Distribution License Version 2.00, published by Jan Vorel
;
; You can use this software under the terms of the
; User-friendly Open-source License Version 1.00, published by Jan Vorel
;
; You should have received copies of the licenses along with this program. If
; not, contact the author.
;
; If you want to use or distribute this software under a different license, ask
; the author.
;
; The software is provided "as is" without warrenty of any kind. The Licensor
; cannot be held responsible for any damage caused by using, extracting or
; installing the software.

EnableExplicit

Procedure TimerListForm_LoadTimerDlg()
  Define.s xChar1
  
  xChar1 = CalaymLoadSingleFile(LoadResString(1605) + #FileFilterVBNullChar + "*.cpt", LoadResString(1600), TimerDir, MainHWnd, #False)
  If Not xChar1 = ""
    MainForm_LoadTimers(MainHWnd, xChar1, #False)
    EndIf
  EndProcedure

Procedure TimerListForm_MenuEvent(wParam.i)
  Select wParam
    Case 2608
      TimerListForm_LoadTimerDlg()
    Case 2609
      MainForm_SaveTimers(MainHWnd, "", #False)
    Case 2600 To 2604
      TimerListForm_TrySCommandEx(MainHWnd, wParam - 2600)
    Case 2699
      ToggleInterface(#Interface_Mode_None)
    EndSelect
  EndProcedure

Procedure.i TimerListForm_ListProc(hWnd.i, Message.i, wParam.i, lParam.i)
  Select Message
    Case $100
      Select wParam
        Case 46
          TimerListForm_TrySCommandEx(MainHWnd, 2)
        Case 93
          If (lParam & $40000000) = 0
            TimerListForm_MenuEvent(GetAPIPopupMenu(MainHWnd, TimerListForm_xMenu2, Interface_Control(#Interface_Control_Timer_List)))
            EndIf
        Case 9
          LoadResEx_Window_ManualTab(MainHWnd, hWnd)
        Case 27
          ToggleInterface(#Interface_Mode_None)
        EndSelect
    Case $105 ;syskeyup
      TimerListForm_TryAccel(wParam)
    Case $205 ;rightmouseup
      If Not TimerListForm_xLocked
        TimerListForm_MenuEvent(TrackListBox(xStaticIconsHWnd(#xStaticIcons_ShowIR), hWnd, HiWordS(lParam), #True, TimerListForm_xMenu2, 1))
        EndIf
    Case $203 ; l-dblclick
      If Not xTimerEvCount = 0
        TimerListForm_TrySCommandEx(MainHWnd, 1)
        EndIf
    Default
      ProcedureReturn HookedWindowProc(hWnd, Message, wParam, lParam)
    EndSelect
  ProcedureReturn 0
  EndProcedure




Procedure.i TimerListForm_ButtonProc(hWnd.i, Message.i, wParam.i, lParam.i)
  If Message = $100
    If wParam = 9
      LoadResEx_Window_ManualTab(MainHWnd, hWnd)
      ProcedureReturn 0
      ElseIf wParam = 27
      ToggleInterface(#Interface_Mode_None)
      ProcedureReturn 0
      EndIf
    ElseIf Message = $105 ;And (lParam & $40000000) = 0
    TimerListForm_TryAccel(wParam)
    EndIf
  ProcedureReturn HookedWindowProc(hWnd, Message, wParam, lParam)
  EndProcedure


Procedure TimerListForm_Interface()
  Define.i xLong1

  TimerListForm_xMenu = LoadResEx_Menu(2600)
  TimerListForm_xMenu2 = LoadResEx_Menu(2610)
  If Not TimerListForm_xMenu = 0
    SetMenu_(MainHWnd, TimerListForm_xMenu)
    DrawMenuBar_(MainHWnd)
    EndIf
  Interface_Icon = LoadResEx_ImageIconWEMF_MultiOS(#PLIconTimer_ResID, 32 * MainDPIScaleX, 32 * MainDPIScaleY)
  If Interface_Icon
    Interface_Control(#Interface_Control_Timer_Image) = CreateWindowExOC(0, #W_STATIC, "", $56000003, 0, 4, 32, 32, MainHWnd, 0, 0)
    If Interface_Control(#Interface_Control_Timer_Image) = 0
      DestroyIcon_(Interface_Icon)
      Interface_Icon = 0
      Else
      SendMessage_(Interface_Control(#Interface_Control_Timer_Image), $170, Interface_Icon, 0)
      EndIf
    EndIf

  TimerListUpdateHWnd = CreateWindowExOC(0, #W_STATIC, ReplaceString(LoadResString(2600), "$", GetTimeFormatNow()), $56000000, 4, 3, 417, 17, MainHWnd, 0, 0)
  Interface_Control(#Interface_Control_Timer_CapLabel) = TimerListUpdateHWnd


  TimerListForm_xPopupMenu2 = MakePopupMenu(TimerListForm_xMenu2)
  If xSecureMode
    EnableMenuItem_(TimerListForm_xMenu, 2601, 3)
    EndIf
  If xSecureMode
    EnableMenuItem_(TimerListForm_xMenu2, 2601, 3)
    EndIf
    
  SetWindowPos_(xStaticIconsHWnd(#xStaticIcons_Anim), 0, 0, 0, 0, 0, $213)
    
  Interface_Control(#Interface_Control_Timer_List) = CreateWindowExOC($200, #W_LISTBOX, "", $56311988, 0, 0, 409, 220, MainHWnd, 0, 0)
  
  For xLong1 = 0 To #Interface_Control_Timer_Close
    Interface_Control(xLong1) = CreateWindowExOC(0, #W_BUTTON, LoadResString(2605 + xLong1), $56010000, 8 + 80 * xLong1, 224, 80, 25, MainHWnd, 0, 0)
    If Not Interface_Control(xLong1) = 0
      SetAccel(xLong1, 2605 + xLong1)
      HookWindow(Interface_Control(xLong1), @TimerListForm_ButtonProc())
      EndIf
    Next
  SetAccel(#Interface_Control_Timer_List, 2600)


  TimerListForm_UpdateTimerListWinFontDPI(hFontGFix)
  
  If Not Interface_Control(#Interface_Control_Timer_List) = 0
    HookWindow(Interface_Control(#Interface_Control_Timer_List), @TimerListForm_ListProc())
    EndIf
  
  
  TimerListForm_ListUpdate()
  
  If Not Interface_Control(#Interface_Control_Timer_List) = 0
    SetFocus_(Interface_Control(#Interface_Control_Timer_List))
    EndIf
  EndProcedure


Procedure TimerListForm_UnInterface()
  MainForm_SetTimerImage()
  EnableWindow_(MainHWnd, 1)
  
  
  If Not Interface_Icon = 0
    SendMessage_(Interface_Control(#Interface_Control_Timer_Image), $170, 0, 0)
    DestroyIcon_(Interface_Icon)
    Interface_Icon = 0
    EndIf
  
  If TimerListForm_xMenu2
    DestroyMenu_(TimerListForm_xMenu2)
    EndIf
  If TimerListForm_xPopupMenu2
    DestroyMenu_(TimerListForm_xPopupMenu2)
    EndIf
  ;TimerListMainHWnd = 0
  TimerListUpdateHWnd = 0
  TimerListForm_xLocked = #False
  SetForegroundWindow_(MainHWnd)
  SetFocus_(MainHWnd)
  EndProcedure




Procedure TimerListForm_Resize(xRight.i, xBottom.i, xTop.i)
  Define.i xLong1
  Define.i xLong2
  
  If Interface_Icon
    xLong1 = 2 * eSPTopX + 32 * MainDPIScaleX
    TrDeferWindowPos(Interface_Control(#Interface_Control_Timer_Image), 0, eSPTopX, xTop + (xDefCtlHeight16 + xDefHeight16 - 32 * MainDPIScaleY) / 2, 32 * MainDPIScaleX, 32 * MainDPIScaleY, $215)
    EndIf
  xLong2 = xRight - xLong1
  If xLong2 < 0
    xLong2 = 0
    EndIf
  TrDeferWindowPos(Interface_Control(#Interface_Control_Timer_CapLabel), 0, xLong1, xTop, xLong2, 2 * xDefHeight16, $214)
  xTop = xTop + 2 * xDefHeight16 + eSPTopY

  xBottom = xBottom - eSPTopY - xTop - xDefButtonHeight
  If xBottom < xDefCtlHeight16 - xDefHeight16
    xBottom = xDefCtlHeight16 - xDefHeight16
    EndIf
  TrDeferWindowPos(Interface_Control(#Interface_Control_Timer_List), 0, 0, xTop, xRight, xBottom, $214)
  TrDeferWindowPos(xStaticIconsHWnd(#xStaticIcons_Anim), 0, xRight - AnimExtraPadding, xTop + 8 * MainDPIScaleY, 0, 0, $215)

  xTop = xTop + xBottom + eSPTopY
  xLong1 = (xRight - eSPTopX * 6) / 5
  If xLong1 < 0
    xLong1 = 0
    EndIf
  
  For xLong2 = 0 To 4
    TrDeferWindowPos(Interface_Control(xLong2), 0, (xLong1 + eSPTopX) * xLong2 + eSPTopX, xTop, xLong1, xDefButtonHeight, $214)
    Next
  EndProcedure

Procedure TimerListForm_ButtonEvent(hWnd.i) ;, wParam.i)
  ; -> TimerListForm_TrySCommandEx
  Define.i xLong1
  
  For xLong1 = 0 To #Interface_Control_Timer_Close
    If Interface_Control(xLong1) = hWnd
      TimerListForm_TrySCommandEx(MainHWnd, xLong1)
      Break
      EndIf
    Next
  EndProcedure

Procedure TimerListForm_DoneTimerEditing()
  Define.i xBool1
  Define.i xLong1
  
  If (xTimerEvCount < #xTimerEvMax Or (xTimerEvCount = #xTimerEvMax And Not xTimerEvIR = -1)) And Not (PlayerIsLocked Or TimerListForm_xLocked)
    xBool1 = #True
    Else
    xLong1 = 3
    EndIf
  
  EnableWindow_(Interface_Control(#Interface_Control_Timer_Add), xBool1)
  EnableMenuItem_(TimerListForm_xMenu, 2600, xLong1)
  EnableMenuItem_(TimerListForm_xMenu2, 2600, xLong1)
  If Not (xTimerEvCount = 0 Or PlayerIsLocked Or TimerListForm_xLocked)
    xBool1 = #True
    Else
    xBool1 = #False
    EndIf
  EnableWindow_(Interface_Control(#Interface_Control_Timer_Edit), xBool1)
  EnableWindow_(Interface_Control(#Interface_Control_Timer_Remove), xBool1)
  EnableWindow_(Interface_Control(#Interface_Control_Timer_RemoveAll), xBool1)
  If xBool1
    If Not xSecureMode
      EnableMenuItem_(TimerListForm_xMenu, 2609, 0)
      EnableMenuItem_(TimerListForm_xMenu2, 2609, 0)
      EndIf
    xLong1 = 0
    Else
    EnableMenuItem_(TimerListForm_xMenu, 2609, 3)
    EnableMenuItem_(TimerListForm_xMenu2, 2609, 3)
    xLong1 = 3
    EndIf
  EnableMenuItem_(TimerListForm_xMenu, 2601, xLong1)
  EnableMenuItem_(TimerListForm_xMenu2, 2601, xLong1)
  EnableMenuItem_(TimerListForm_xMenu, 2602, xLong1)
  EnableMenuItem_(TimerListForm_xMenu2, 2602, xLong1)
  EnableMenuItem_(TimerListForm_xMenu, 2603, xLong1)
  EnableMenuItem_(TimerListForm_xMenu2, 2603, xLong1)
  EndProcedure

Procedure TimerListForm_UpdateTimerListWidths(xLen.i, xLenPL.i)
  Dim xLongA1.l(2)
  If xLen = 0
    SendMessage_(Interface_Control(#Interface_Control_Timer_List), $192, 0, 0)  ;xLongA1(0))
    SendMessage_(Interface_Control(#Interface_Control_Timer_List), #LB_SETHORIZONTALEXTENT, 0, 0)
    Else
    xLongA1(0) = xTimerDisplayExtraLen * xGlobalDialogUnitsGFix ;* 4
    xLongA1(1) = (xTimerDisplayExtraLen + xLen + #xTimerDisplaySpace2) * xGlobalDialogUnitsGFix ;* 4
    If xLenPL = 0
      SendMessage_(Interface_Control(#Interface_Control_Timer_List), $192, 2, @xLongA1(0))
      SendMessage_(Interface_Control(#Interface_Control_Timer_List), #LB_SETHORIZONTALEXTENT, xLen + 4 + xTimerDisplayExtraLenT, 0)
      Else
      xLongA1(2) = (xTimerDisplayExtraLenT + xLen + #xTimerDisplaySpace2) * xGlobalDialogUnitsGFix  ;* 4
      SendMessage_(Interface_Control(#Interface_Control_Timer_List), $192, 3, @xLongA1(0))
      SendMessage_(Interface_Control(#Interface_Control_Timer_List), #LB_SETHORIZONTALEXTENT, xLen + 4 + xTimerDisplayExtraLenT + xLenPL + #xTimerDisplaySpace2, 0)
      EndIf
    EndIf
  EndProcedure

Procedure TimerListForm_TrySCommandEx(hWndOwner.i, Index.i)
  Define.i xLong1
  Define.i xLong2
  Define.i xLong3
  Define.s xChar1
  Define.s xChar2
  Define.i xLong4
  
  If Not TimerListForm_xLocked
    If IsWindowEnabled_(Interface_Control(Index))
      Select Index
        Case 0
          xTimerEvMode = -1
          ShowTimerEditor()
          TimerListForm_DoneTimerEditing()
        Case 1
          If GetListIndexMS(Interface_Control(#Interface_Control_Timer_List), @xTimerEvMode)
          ;If eList.SelCount = 1
            ;xTimerEvMode = eList.ListIndex
            ;If Not xTimerEvMode = -1 Or xTimerEvMode = xTimerEvIR
            If Not xTimerEvMode = xTimerEvIR
              ;TimerListForm_xLocked = #True
              ShowTimerEditor()
              TimerListForm_DoneTimerEditing()
              EndIf
            EndIf
        Case 2
          xTimerEditing = #True
          hWndOwner = xTimerEvCount - 1
          xTimerEvCount = 0
          ;SelectObject_(xSharedDC, hFontGSys)
          For xLong1 = 0 To hWndOwner
            If SendMessage_(Interface_Control(#Interface_Control_Timer_List), #LB_GETSEL, xTimerEvCount, 0) = 0
              If xLong1 = xTimerEvIR
                xTimerEvIR = xTimerEvCount
                EndIf
              xTimerEvTime(xTimerEvCount) = xTimerEvTime(xLong1)
              xTimerEv(xTimerEvCount) = xTimerEv(xLong1)
              
              xTimerDisplayLastParamValue = xChar2
              xChar1 = MainForm_xTimerDisplay(xLong1, 0, 0)
              xChar2 = xTimerDisplayLastParamValue
              xLong4 = GetTextOutWidth(xSharedDC, xChar1)
              If xLong4 > xLong2
                xLong2 = xLong4
                EndIf
              If Not xChar2 = ""
                xLong4 = GetTextOutWidth(xSharedDC, xChar2)
                If xLong4 > xLong3
                  xLong3 = xLong4
                  EndIf
                EndIf
              xTimerEvCount = xTimerEvCount + 1
              Else
              If xLong1 = xTimerEvIR
                xTimerEvIR = -1
                EndIf
              SendMessage_(Interface_Control(#Interface_Control_Timer_List), #LB_DELETESTRING, xTimerEvCount, 0)
              EndIf
            Next
          TimerListForm_DoneTimerEditing()
          TimerListForm_UpdateTimerListWidths(xLong2, xLong3)
          MainForm_SetTimerImage()
          xTimerEditing = #False
        Case 3
          If Not xTimerEvIR = -1
            If CalaymMessageBox(hWndOwner, LoadResString(1619), LoadResString(1618), 68) = #IDNO
              xTimerEvIR = -1
              EndIf
            EndIf
          SendMessage_(Interface_Control(#Interface_Control_Timer_List), #LB_RESETCONTENT, 0, 0)
          If xTimerEvIR = -1
            xTimerEvCount = 0
            Else
            xTimerEv(0) = xTimerEv(xTimerEvIR)
            xTimerEvTime(0) = xTimerEvTime(xTimerEvIR)
            xTimerDisplayLastParamValue = ""
            xChar1 = MainForm_xTimerDisplay(0, 1, 0)
            SendMessage_(Interface_Control(#Interface_Control_Timer_List), #LB_ADDSTRING, 0, @xChar1)
            ;eList.AddItem xChar1
            xTimerDisplayLastParamValue = xChar2
            xChar1 = MainForm_xTimerDisplay(0, 0, 0)
            xChar2 = xTimerDisplayLastParamValue
            SelectObject_(xSharedDC, hFontGFix)
            xLong1 = GetTextOutWidth(xSharedDC, xChar1)
            If xChar2 = ""
              xLong1 = 0
              Else
              xLong1 = GetTextOutWidth(xSharedDC, xChar2)
              EndIf
            xTimerEvCount = 1
            xTimerEvIR = 0
            EndIf
          TimerListForm_DoneTimerEditing()
          TimerListForm_UpdateTimerListWidths(xLong1, xLong1)
          MainForm_SetTimerImage()
        Case 4
          ToggleInterface(#Interface_Mode_None)
        EndSelect
      EndIf
    EndIf
  EndProcedure

Procedure TimerListForm_UpdateTimerListWinFontDPI(xFont.i)
  Define.i xLong1
  Define.i xLong2
  Define.i xLong3
  Define.s xChar1

  For xLong1 = 0 To #Interface_Control_Timer_LastFont
    SendMessage_(Interface_Control(xLong1), $30, xFont, 1)
    Next
  xTimerDisplayExtraLen = 0
  SelectObject_(xSharedDC, xFont)
  For xLong1 = 0 To 9
    xChar1 = Chr(48 + xLong1) + Chr(48 + xLong1) + ":" + Chr(48 + xLong1) + Chr(48 + xLong1)
    xLong2 = GetTextOutWidth(xSharedDC, xChar1) + #xTimerDisplaySpace1
    If xLong2 > xTimerDisplayExtraLen
      xTimerDisplayExtraLen = xLong2
      EndIf
    
    xChar1 = ReplaceString(LoadResString(2655), "$", xChar1)
    xLong2 = GetTextOutWidth(xSharedDC, xChar1)
    If xLong2 > xLong3
      xLong3 = xLong2
      EndIf
    Next
  xTimerDisplayExtraLenT = xTimerDisplayExtraLen + xLong3 + #xTimerDisplaySpace2
  ;debug "WidthInitial:", xTimerDisplayExtraLen, xLong3, xTimerDisplayExtraLenT

  If Interface_Icon
    xLong1 = LoadResEx_ImageIconWEMF_MultiOS(#PLIconTimer_ResID, 32 * MainDPIScaleX, 32 * MainDPIScaleY)
    If xLong1
      SendMessage_(Interface_Control(#Interface_Control_Timer_Image), $170, xLong1, 0)
      DestroyIcon_(Interface_Icon)
      Interface_Icon = xLong1
      EndIf
    EndIf

  EndProcedure

Procedure TimerListForm_ListUpdate()
  Define.i xLong1
  Define.i xLong2
  Define.i xLong3
  Define.i xLong4
  Define.i xLong5
  Define.s xChar1
  Define.s xChar2
  ;Dim xType1 As POINT
  
  If xTimerEvCount = 0
    xLong2 = -1
    Else
    GetListIndexMS(Interface_Control(#Interface_Control_Timer_List), @xLong2)
    EndIf
  
  ResortTimers()
  
  SendMessage_(Interface_Control(#Interface_Control_Timer_List), #LB_RESETCONTENT, 0, 0)
  CompilerIf #TimeTestDebug
    MainForm_ctConsoleA_AddLog("TimeDebug: Refreshing list"
    CompilerEndIf
  SelectObject_(xSharedDC, hFontGFix)
  For xLong1 = 0 To xTimerEvCount - 1
    xTimerDisplayLastParamValue = ""
    xChar1 = MainForm_xTimerDisplay(xLong1, 1, 0)
    SendMessage_(Interface_Control(#Interface_Control_Timer_List), #LB_ADDSTRING, 0, @xChar1)
    xTimerDisplayLastParamValue = xChar2
    xChar1 = MainForm_xTimerDisplay(xLong1, 0, 0)
    xChar2 = xTimerDisplayLastParamValue
    xLong5 = GetTextOutWidth(xSharedDC, xChar1)
    If xLong5 > xLong3
      xLong3 = xLong5
      EndIf
    If Not xChar2 = ""
      xLong5 = GetTextOutWidth(xSharedDC, xChar2)
      If xLong5 > xLong4
        xLong4 = xLong5
        EndIf
      EndIf
    ;If xLong3 > xLong4
      ;xLong4 = xLong3
      ;endif
    CompilerIf #TimeTestDebug
      xTimerDisplayLastParamValue = ""
      MainForm_ctConsoleA_AddLog("           " & "(" & CStr(xTimerEvTime(xLong1)) & "): " & MainForm_xTimerDisplay(xLong1, 2, 0)
      CompilerEndIf
    Next
  
  If Not xTimerEvCount = 0
    If xLong2 = -1
      xLong2 = 0
      EndIf
    SetListIndexMS(Interface_Control(#Interface_Control_Timer_List), xLong2)
    EndIf
  
  TimerListForm_DoneTimerEditing()
  GrabError()
  xTimerEvUpdateTimer = GetLocalTimeHM()
  TimerListForm_UpdateTimerListWidths(xLong3, xLong4)
  MainForm_SetTimerImage()
  EndProcedure

Procedure TimerListForm_ApplyLockState()
  Define.i xLong1
  Define.i xLong2
  Define.i xLong3

  ;If InterfaceMode = #Interface_Mode_timer
    If PlayerIsLocked Or TimerListForm_xLocked
      xLong2 = 3
      EndIf
    xLong2 = xLong2 + $400
    xLong3 = GetMenuItemCount_(TimerListForm_xMenu) - 1
    For xLong1 = 0 To xLong3
      EnableMenuItem_(TimerListForm_xMenu, xLong1, xLong2)
      Next
    DrawMenuBar_(MainHWnd)
    If PlayerIsLocked Or TimerListForm_xLocked
      For xLong1 = 0 To #Interface_Control_Timer_RemoveAll ;#Interface_Control_Timer_List
        If Not xLong1 = #Interface_Control_Timer_Close
          EnableWindow_(Interface_Control(xLong1), 0)
          EndIf
        Next
      Else
      If xTimerEvCount < #xTimerEvMax Or (xTimerEvCount = #xTimerEvMax And Not xTimerEvIR = -1)
        xLong1 = #True
        Else
        xLong1 = #False
        EndIf
      EnableWindow_(Interface_Control(#Interface_Control_Timer_Add), xLong1)
      If xTimerEvCount
        xLong2 = #True
        Else
        xLong2 = #False
        EndIf
      For xLong1 = #Interface_Control_Timer_Edit To #Interface_Control_Timer_RemoveAll
        EnableWindow_(Interface_Control(xLong1), xLong2)
        Next
      EndIf
    ;endif
  EndProcedure

Procedure TimerListForm_ReDetectWidth()
  Define.i xLong1
  Define.i xLong3
  Define.i xLong4
  Define.i xLong5
  Define.s xChar1
  Define.s xChar2
  
  SelectObject_(xSharedDC, hFontGFix)
  For xLong1 = 0 To xTimerEvCount - 1
    xTimerDisplayLastParamValue = xChar2
    xChar1 = MainForm_xTimerDisplay(xLong1, 0, 0)
    xChar2 = xTimerDisplayLastParamValue
    xLong5 = GetTextOutWidth(xSharedDC, xChar1)
    If xLong5 > xLong3
      xLong3 = xLong5
      EndIf
    If Not xChar2 = ""
      xLong5 = GetTextOutWidth(xSharedDC, xChar2)
      If xLong5 > xLong4
        xLong4 = xLong5
        EndIf
      EndIf
    Next
  
  TimerListForm_UpdateTimerListWidths(xLong3, xLong4)
  EndProcedure

Procedure TimerListForm_TryAccel(wParam.i)
  Define.i xLong1
  
  If wParam = 40 Or wParam = 38
    ShowWindow_(Interface_Control(#Interface_Control_Timer_List), 5)
    SetFocus_(Interface_Control(#Interface_Control_Timer_List))
    ElseIf wParam = 93 And Not TimerListForm_xLocked
    xLong1 = GetAPIPopupMenu(MainHWnd, TimerListForm_xMenu2, Interface_Control(#Interface_Control_Timer_List))
    If Not xLong1 = 0
      TimerListForm_ListProc(Interface_Control(#Interface_Control_Timer_List), $111, 0, xLong1)
      ;TimerListForm_TryAccel = (Not (InterfaceMode = #Interface_Mode_Timer))
      EndIf
    Else
    For xLong1 = 0 To #Interface_Control_Timer_Close
      If Interface_Control_Accel(xLong1) = wParam
        SetFocus_(Interface_Control(#Interface_Control_Timer_List))
        If Not xLong1 = #Interface_Control_Timer_List
          TimerListForm_TrySCommandEx(MainHWnd, xLong1)
          EndIf
        Break
        EndIf
      Next
    EndIf
  EndProcedure

; IDE Options = PureBasic 5.31 (Windows - x86)
; CursorPosition = 1
; Folding = ------
; EnableXP
; AddResource = res\exe64.rc