Attribute VB_Name = "modul_Calaym_SharedSM"
' Copyright (C) 2002-2011 Jan Vorel
' This program is free software; you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation; either version 2 of the License, or
' (at your option) any later version.

' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
' GNU General Public License for more details.

' You should have received a copy of the GNU General Public License
' along with this program; if not, write to the Free Software
' Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

' If you have any questions, suggestions or bug reports about this product,
' contact me: info@ctuser.net; Do not contact me about general B.A.S.I.C.
' language or A.P.I. issues



' Shared dialog stuff, stored seperately here to prevent QB from loading
' the complete dialog modul when accessing anything from it.
' May save little memory until using those dialogs.

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 eTimerEvent)
      '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

