Attribute VB_Name = "modul_Calaym_SharedSM"
' Calaym - Media player GUI for sound systems
' Copyright (C) 2002-2012 Jan Vorel
'
' You can redistribute the official software packages under the terms of the
' User-friendly Open-source License Version 1.00, published by Jan Vorel
'
' You can use this software under the terms of the
' User-friendly Software 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.

Option Explicit
Option Base 0

Public Declare Function GetClientRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
Public HWndSetupDialogSSPage As Long
Private Declare Function GetNextDlgTabItem Lib "user32" (ByVal hDlg As Long, ByVal hCtl As Long, ByVal bPrevious As Long) As Long

Public xTimerEditing As Boolean

Public Function LoadResEx_Dialog_ListItemGet(ByVal HWndControl As Long, ByVal ListIndex As Long) As String
  Dim xLong1 As Long

  If Not HWndControl = 0& Then
    xLong1 = SendMessage(HWndControl, &H18A&, ListIndex, 0&)
    If Not xLong1 > ptrTempSizeX And Not (xLong1 > ptrTempSizeXW And IsUnicode) Then
      HWndControl = SendMessage(HWndControl, &H189&, ListIndex, ptrTemp)
      If Not HWndControl = -1& Then
        LoadResEx_Dialog_ListItemGet = PeekS(ptrTemp, HWndControl)
        End If
      End If
    End If
  End Function

Public Sub LoadResEx_Dialog_ListItemSet(ByVal HWndControl As Long, ByVal ListIndex As Long, ByVal NewText As String, ByVal SelectIt As Boolean)
  If Not HWndControl = 0& Then
    Call SendMessage(HWndControl, &H182, ListIndex, 0&)
    Call SendMessage_String(HWndControl, &H181, ListIndex, NewText)
    If SelectIt Then Call SendMessage(HWndControl, &H185&, 1&, ListIndex)
    End If
  End Sub

Public Sub LoadResEx_Dialog_ListItemSetData(ByVal HWndControl As Long, ByVal ListIndex As Long, ByVal NewNumber As Long, ByVal SelectIt As Boolean)
  If Not HWndControl = 0& Then
    Call SendMessage(HWndControl, &H182&, ListIndex, 0&)
    Call SendMessage(HWndControl, &H181&, ListIndex, NewNumber)
    If SelectIt Then Call SendMessage(HWndControl, &H185&, 1&, ListIndex)
    End If
  End Sub

Public Sub LoadResEx_Dialog_ManualTab(ByVal TopHWnd As Long, ByVal CurHWnd As Long)
  If IsShiftPressed Then
    CurHWnd = GetNextDlgTabItem(TopHWnd, CurHWnd, 1&)
    Else
    CurHWnd = GetNextDlgTabItem(TopHWnd, CurHWnd, 0&)
    End If
  If Not CurHWnd = 0& Then Call SetFocusAPI(CurHWnd)
  End Sub

Public Sub LoadResEx_Window_ManualTab(ByVal TopHWnd As Long, ByVal CurHWnd As Long)
  'Debug.Print "TryDlgTab"
  LoadResEx_Dialog_ManualTab TopHWnd, CurHWnd
  'Debug.Print "DoneDlgTab"
  End Sub

Public Sub DialogTimer(ByVal Init As Boolean)
  If Init Then
    IsDialoging = IsDialoging + 1&
    If IsDialoging = 1& Then
      Call SetTimer(MainHWnd, 2&, DoEventsEx_SleepPeriodical_Interval, AddressOf DialogTimerProc)
      'If InterfaceMode = interface_mode_timer Then EnableWindow TimerListMainHWnd, 0&
      End If
    Else
    IsDialoging = IsDialoging - 1&
    If IsDialoging = 0& Then
      Call KillTimer(MainHWnd, 2&)
      'If InterfaceMode = interface_mode_timer Then EnableWindow TimerListMainHWnd, 1&
      End If
    End If
  End Sub

Public Function GetShiftCode() As Long
  If (GetAsyncKeyState(&H10&) And &HFFFF0000) Then
    GetShiftCode = 1&
    Else
    GetShiftCode = 0&
    End If
  If (GetAsyncKeyState(&H11&) And &HFFFF0000) Then
    GetShiftCode = GetShiftCode + 2&
    End If
  End Function

Public Function IsShiftPressed() As Boolean
  IsShiftPressed = (GetAsyncKeyState(&H10&) And &HFFFF0000)
  End Function

Public Function IsCtrlPressed() As Boolean
  IsCtrlPressed = (GetAsyncKeyState(&H11&) And &HFFFF0000)
  End Function

Public Function IsAltPressed() As Boolean
  IsAltPressed = (GetAsyncKeyState(&H12&) And &HFFFF0000)
  End Function

