VERSION 5.00
Begin VB.Form frmDPC_ImgSel 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "#Image Selection"
   ClientHeight    =   8730
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   14505
   ControlBox      =   0   'False
   LinkTopic       =   "Form2"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   8730
   ScaleWidth      =   14505
   ShowInTaskbar   =   0   'False
   StartUpPosition =   3  'Windows Default
   Tag             =   "frmDPC_ImgSel"
   Visible         =   0   'False
   Begin VB.Frame fra_Images 
      Height          =   8715
      Left            =   15
      TabIndex        =   6
      Tag             =   "fra_Images"
      Top             =   -30
      Width           =   7185
      Begin VB.VScrollBar vsc_Scrollbar 
         Height          =   8565
         LargeChange     =   4
         Left            =   6840
         TabIndex        =   31
         TabStop         =   0   'False
         Top             =   120
         Width           =   315
      End
      Begin VB.PictureBox pct_SelImageSmall 
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H80000005&
         ForeColor       =   &H80000008&
         Height          =   1800
         Index           =   0
         Left            =   90
         ScaleHeight     =   1770
         ScaleWidth      =   1905
         TabIndex        =   18
         Top             =   420
         Width           =   1935
      End
      Begin VB.PictureBox pct_SelImageSmall 
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H80000005&
         ForeColor       =   &H80000008&
         Height          =   1800
         Index           =   1
         Left            =   2400
         ScaleHeight     =   1770
         ScaleWidth      =   1905
         TabIndex        =   17
         Top             =   390
         Width           =   1935
      End
      Begin VB.PictureBox pct_SelImageSmall 
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H80000005&
         ForeColor       =   &H80000008&
         Height          =   1800
         Index           =   2
         Left            =   4680
         ScaleHeight     =   1770
         ScaleWidth      =   1905
         TabIndex        =   16
         Top             =   420
         Width           =   1935
      End
      Begin VB.PictureBox pct_SelImageSmall 
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H80000005&
         ForeColor       =   &H80000008&
         Height          =   1800
         Index           =   3
         Left            =   105
         ScaleHeight     =   1770
         ScaleWidth      =   1905
         TabIndex        =   15
         Top             =   2560
         Width           =   1935
      End
      Begin VB.PictureBox pct_SelImageSmall 
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H80000005&
         ForeColor       =   &H80000008&
         Height          =   1800
         Index           =   4
         Left            =   2385
         ScaleHeight     =   1770
         ScaleWidth      =   1905
         TabIndex        =   14
         Top             =   2565
         Width           =   1935
      End
      Begin VB.PictureBox pct_SelImageSmall 
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H80000005&
         ForeColor       =   &H80000008&
         Height          =   1800
         Index           =   5
         Left            =   4680
         ScaleHeight     =   1770
         ScaleWidth      =   1905
         TabIndex        =   13
         Top             =   2560
         Width           =   1935
      End
      Begin VB.PictureBox pct_SelImageSmall 
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H80000005&
         ForeColor       =   &H80000008&
         Height          =   1800
         Index           =   6
         Left            =   90
         ScaleHeight     =   1770
         ScaleWidth      =   1905
         TabIndex        =   12
         Top             =   4700
         Width           =   1935
      End
      Begin VB.PictureBox pct_SelImageSmall 
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H80000005&
         ForeColor       =   &H80000008&
         Height          =   1800
         Index           =   7
         Left            =   2385
         ScaleHeight     =   1770
         ScaleWidth      =   1905
         TabIndex        =   11
         Top             =   4700
         Width           =   1935
      End
      Begin VB.PictureBox pct_SelImageSmall 
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H80000005&
         ForeColor       =   &H80000008&
         Height          =   1800
         Index           =   8
         Left            =   4665
         ScaleHeight     =   1770
         ScaleWidth      =   1905
         TabIndex        =   10
         Top             =   4700
         Width           =   1935
      End
      Begin VB.PictureBox pct_SelImageSmall 
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H80000005&
         ForeColor       =   &H80000008&
         Height          =   1800
         Index           =   9
         Left            =   75
         ScaleHeight     =   1770
         ScaleWidth      =   1905
         TabIndex        =   9
         Top             =   6840
         Width           =   1935
      End
      Begin VB.PictureBox pct_SelImageSmall 
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H80000005&
         ForeColor       =   &H80000008&
         Height          =   1800
         Index           =   10
         Left            =   2385
         ScaleHeight     =   1770
         ScaleWidth      =   1905
         TabIndex        =   8
         Top             =   6855
         Width           =   1935
      End
      Begin VB.PictureBox pct_SelImageSmall 
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H80000005&
         ForeColor       =   &H80000008&
         Height          =   1800
         Index           =   11
         Left            =   4680
         ScaleHeight     =   1770
         ScaleWidth      =   1905
         TabIndex        =   7
         Top             =   6840
         Width           =   1935
      End
      Begin VB.Shape shp_Selected 
         BorderColor     =   &H000000FF&
         BorderStyle     =   6  'Inside Solid
         BorderWidth     =   4
         Height          =   1920
         Left            =   30
         Top             =   360
         Visible         =   0   'False
         Width           =   2055
      End
      Begin VB.Label lbl_Name 
         Caption         =   "#Name 0"
         Height          =   225
         Index           =   0
         Left            =   105
         TabIndex        =   30
         Tag             =   "_lbl_Name0"
         Top             =   150
         Width           =   1995
      End
      Begin VB.Label lbl_Name 
         Caption         =   "#Name 1"
         Height          =   225
         Index           =   1
         Left            =   2385
         TabIndex        =   29
         Tag             =   "_lbl_Name1"
         Top             =   150
         Width           =   1950
      End
      Begin VB.Label lbl_Name 
         Caption         =   "#Name 2"
         Height          =   225
         Index           =   2
         Left            =   4665
         TabIndex        =   28
         Tag             =   "_lbl_Name2"
         Top             =   150
         Width           =   1950
      End
      Begin VB.Label lbl_Name 
         Caption         =   "#Name 3"
         Height          =   225
         Index           =   3
         Left            =   90
         TabIndex        =   27
         Tag             =   "_lbl_Name3"
         Top             =   2280
         Width           =   1950
      End
      Begin VB.Label lbl_Name 
         Caption         =   "#Name 4"
         Height          =   225
         Index           =   4
         Left            =   2370
         TabIndex        =   26
         Tag             =   "_lbl_Name4"
         Top             =   2280
         Width           =   1950
      End
      Begin VB.Label lbl_Name 
         Caption         =   "#Name 5"
         Height          =   225
         Index           =   5
         Left            =   4665
         TabIndex        =   25
         Tag             =   "_lbl_Name5"
         Top             =   2280
         Width           =   1950
      End
      Begin VB.Label lbl_Name 
         Caption         =   "#Name 6"
         Height          =   225
         Index           =   6
         Left            =   90
         TabIndex        =   24
         Tag             =   "_lbl_Name6"
         Top             =   4425
         Width           =   1950
      End
      Begin VB.Label lbl_Name 
         Caption         =   "#Name 7"
         Height          =   225
         Index           =   7
         Left            =   2370
         TabIndex        =   23
         Tag             =   "_lbl_Name7"
         Top             =   4425
         Width           =   1950
      End
      Begin VB.Label lbl_Name 
         Caption         =   "#Name 8"
         Height          =   225
         Index           =   8
         Left            =   4650
         TabIndex        =   22
         Tag             =   "_lbl_Name8"
         Top             =   4425
         Width           =   1950
      End
      Begin VB.Label lbl_Name 
         Caption         =   "#Name 9"
         Height          =   225
         Index           =   9
         Left            =   105
         TabIndex        =   21
         Tag             =   "_lbl_Name9"
         Top             =   6570
         Width           =   1950
      End
      Begin VB.Label lbl_Name 
         Caption         =   "#Name 10"
         Height          =   225
         Index           =   10
         Left            =   2385
         TabIndex        =   20
         Tag             =   "_lbl_Name10"
         Top             =   6570
         Width           =   1950
      End
      Begin VB.Label lbl_Name 
         Caption         =   "#Name 11"
         Height          =   225
         Index           =   11
         Left            =   4665
         TabIndex        =   19
         Tag             =   "_lbl_Name11"
         Top             =   6570
         Width           =   1950
      End
   End
   Begin VB.CommandButton btn_Validate 
      Default         =   -1  'True
      Height          =   612
      Left            =   13035
      Style           =   1  'Graphical
      TabIndex        =   3
      Tag             =   "btn_Validate"
      Top             =   7995
      Width           =   612
   End
   Begin VB.CommandButton btn_Quit 
      Height          =   612
      Left            =   13830
      Style           =   1  'Graphical
      TabIndex        =   2
      Tag             =   "btn_Quit"
      Top             =   7980
      Width           =   612
   End
   Begin VB.Frame fra_Selection 
      Height          =   7680
      Left            =   7185
      TabIndex        =   0
      Tag             =   "fra_Selection"
      Top             =   -30
      Width           =   7215
      Begin VB.PictureBox pct_SelImageBig 
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         BackColor       =   &H80000005&
         ForeColor       =   &H80000008&
         Height          =   6390
         Left            =   60
         ScaleHeight     =   6360
         ScaleWidth      =   7020
         TabIndex        =   1
         Top             =   375
         Width           =   7050
      End
      Begin VB.Label lbl_SelName 
         Caption         =   "#Name"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   238
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   240
         Left            =   75
         TabIndex        =   5
         Tag             =   "_lbl_SelName"
         Top             =   120
         Width           =   6990
      End
      Begin VB.Label lbl_SelDesc 
         Caption         =   "#Desc"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   238
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   825
         Left            =   60
         TabIndex        =   4
         Tag             =   "_lbl_SelDesc"
         Top             =   6780
         Width           =   7050
         WordWrap        =   -1  'True
      End
   End
End
Attribute VB_Name = "frmDPC_ImgSel"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Const CL_COLOR_ENABLED As Long = &H80000005
Private Const CL_COLOR_DISABLED As Long = &H8000000F

Private Const C_ERRORRAISE As Long = 2500
Private Const SEP = "®©"
Private Const C_SEP As String = "@@"
Private Const SEP1 As String = "®"
Private Const SEP2 As String = "©"
Private Const SCREEN_NAME As String = "frmDPC_ImgSel"

Private Enum ArmErr
    DBCnxFailed = vbObjectError + 1             ' Unable to connect to the database
    CPTAlreadyInitialized = vbObjectError + 2   ' We try to initialize a component that is already initialized
    CPTNotInitialized = vbObjectError + 3       ' We try to use or free that is not initialized yet
    InvalidArgument = vbObjectError + 4
    PropertyNotSet = vbObjectError + 5
    SQLFailure = vbObjectError + 6               ' A SQL runtime error has occured : syntax wrong....
    SQLBadRowAffectedCount = vbObjectError + 7   ' A SQL request has not affected the expected rowcount (ex: one Update do nothing)
    SQLBadRowExpectedCount = vbObjectError + 8   ' A SQL request does not return the expected rowcount : select an item return nothing...
    DrivingError = vbObjectError + 9
    CompFncFailed = vbObjectError + 10           ' when component function fail
    GridLoadFailed = vbObjectError + 11          ' load function failed ... bad sql
    QuietException = vbObjectError + 12          ' do not display error message
    SQLTableReferenceConstraint = vbObjectError + 13 ' A SQL request cannot be executed : Table reference constraint
    DuplicityDetected = vbObjectError + 2301     ' detected row with same unique id
End Enum

#If ENV = LIVE Then
Private mo_Db As Object
Private mo_FSO As Object
#Else
Private mo_Db As ARMSYSCOMLib.ArmDb
Private mo_FSO As FileSystemObject
#End If

Private ms_DPCImageCachePath As String
Private ml_ColCount As Long
Private ml_RowCount As Long
Private ml_ImgCount As Long
Private ml_ItemCount As Long
Private ml_U_Code As Long
Private ms_Language_Code As String
Private mc_ScreenLabels As Long
Private mo_Tools As DPC_Tools
Private mb_InternalInit As Boolean

Public Request As String
Public SelectedIndex As Long
Public SelectedId As Variant
Public SelectedIMG_Id As Long
Public SelectedPicture As StdPicture
Public SelectedName As String
Public SelectedDesc As String
Public Result As Boolean

Private Type ImageInfo
  Id As String
  IMG_Id As Long
  Name As String
  Desc As String
  Row As Long
  Col As Long
  Picture As StdPicture
End Type

Private mt_ImageInfo() As ImageInfo

Property Let Language_Code(AString As String)
  ms_Language_Code = AString
End Property

Property Get Language_Code() As String
  Language_Code = ms_Language_Code
End Property

Public Property Set ArmDb(ByRef lo_Db As Object)
  If Not (lo_Db Is Nothing) Then
      Set mo_Db = lo_Db
  End If
End Property

Property Let U_Code(al_Code As Long)
  ml_U_Code = al_Code
End Property

Public Property Set Tools(ByRef ao_Tools As Object)
On Error GoTo ErrorHandler

  Set mo_Tools = ao_Tools
  Exit Property
ErrorHandler:
  Call ErrorHandler("Tools.Set")
End Property

Public Sub Load_A_COM()
On Error GoTo ErrHandler

Dim ll_max As Long
  
  If mo_Db Is Nothing Then
      Call Err.Raise(ArmErr.PropertyNotSet)
  End If
  If mo_Tools Is Nothing Then
      Call Err.Raise(ArmErr.PropertyNotSet)
  End If
  
  ms_DPCImageCachePath = prg.AppCache_Dir & DPC_IMAGE_CACHE
  btn_Validate.Picture = LoadResPicture(RES_OK, 1)
  btn_Quit.Picture = LoadResPicture(RES_QUIT, 1)
  Set mo_FSO = New FileSystemObject
  ml_ColCount = 3
  ml_RowCount = 4
  ml_ImgCount = ml_RowCount * ml_ColCount
  
  SelectedIndex = -1
  SelectedIMG_Id = 0
  SelectedId = 0
  SelectedName = ""
  SelectedDesc = ""
  
  Set SelectedPicture = Nothing
  lbl_SelName.Caption = ""
  lbl_SelDesc.Caption = ""
  Set pct_SelImageBig.Picture = Nothing
  pct_SelImageBig.Tag = -1
  
  Call LoadSelImageInfo
  
  vsc_Scrollbar.Value = 0
  If ml_ItemCount > ml_ImgCount Then
    vsc_Scrollbar.Visible = True
    ll_max = ml_ItemCount \ ml_ColCount
    If ml_ItemCount Mod ml_ColCount > 0 Then
      ll_max = ll_max + 1
    End If
    vsc_Scrollbar.Max = ll_max - ml_RowCount
  Else
    vsc_Scrollbar.Visible = False
  End If
  
  Call DisplayImages
    
  'Screen csts
  mc_ScreenLabels = mo_Tools.LoadLabels(mo_Db, Me.Controls, Me, SCREEN_NAME, ms_Language_Code)
  Call mo_Tools.ChangeCharset(Me.Controls, gl_CodePage, gl_CodePage, Me)
  mb_InternalInit = False
  Result = False
  Exit Sub
ErrHandler:
  Call ErrorHandler("Load_A_COM")
End Sub

Public Sub Unload_A_COM()
On Error GoTo ErrHandler

  Call mo_Tools.Unload_A_ComControls(Me.Controls)
  Call mo_Db.Close(mc_ScreenLabels)
  Set mo_Db = Nothing
  Set mo_FSO = Nothing
  Set mo_Tools = Nothing
  Exit Sub
ErrHandler:
  Call ErrorHandler("Unload_A_COM")
End Sub

Private Sub DisplayImages()
On Error GoTo ErrHandler

Dim ll_Idx As Long
Dim ll_Pos As Long

  ll_Pos = ml_ColCount * vsc_Scrollbar.Value
  For ll_Idx = 0 To ml_ImgCount - 1
    If ll_Pos + ll_Idx < ml_ItemCount Then
      Call mo_Tools.DrawDPCImage(mo_Db, mo_FSO, ms_DPCImageCachePath, mt_ImageInfo(ll_Pos + ll_Idx).IMG_Id, pct_SelImageSmall(ll_Idx))
      pct_SelImageSmall(ll_Idx).Visible = True
      lbl_Name(ll_Idx).Caption = mt_ImageInfo(ll_Pos + ll_Idx).Name
      pct_SelImageSmall(ll_Idx).ToolTipText = mt_ImageInfo(ll_Pos + ll_Idx).Desc
      pct_SelImageSmall(ll_Idx).Tag = ll_Pos + ll_Idx
    Else
      pct_SelImageSmall(ll_Idx).Visible = False
      Set pct_SelImageSmall(ll_Idx).Picture = Nothing
      lbl_Name(ll_Idx).Caption = ""
      pct_SelImageSmall(ll_Idx).ToolTipText = ""
      pct_SelImageSmall(ll_Idx).Tag = -1
    End If
  Next
  Exit Sub
ErrHandler:
  Call ErrorHandler("DisplayImages")
End Sub

Private Sub LoadSelImageInfo()
On Error GoTo ErrHandler

Dim ll_Cursor As Long
Dim ll_Idx As Long
Dim lt_ImageInfo As ImageInfo
Dim ll_Row As Long, ll_Col As Long
Dim ls_Request As String

  ls_Request = Request
  ls_Request = Replace(ls_Request, "$Language_Code$", mo_Tools.SQLStr(Language_Code), , , vbTextCompare)
  ll_Cursor = mo_Tools.OpenSQLSafe(mo_Db, ls_Request)
  ml_ItemCount = mo_Db.RowCount(ll_Cursor)
  
  If ml_ItemCount > 0 Then
    ReDim mt_ImageInfo(ml_ItemCount - 1)
  Else
    ReDim mt_ImageInfo(-1 To -1)
  End If
  ll_Row = 0
  ll_Col = 0
  ll_Idx = 0
  While Not mo_Db.EOF(ll_Cursor)
    lt_ImageInfo.Id = mo_Db.GetFields(ll_Cursor, 0)
    lt_ImageInfo.IMG_Id = mo_Db.GetFields(ll_Cursor, 1)
    lt_ImageInfo.Name = mo_Db.GetFields(ll_Cursor, 2)
    lt_ImageInfo.Desc = mo_Db.GetFields(ll_Cursor, 3)
    lt_ImageInfo.Row = ll_Row
    lt_ImageInfo.Col = ll_Col
    ll_Col = ll_Col + 1
    If ll_Col >= ml_ColCount Then
      ll_Col = 0
      ll_Row = ll_Row + 1
    End If
    mt_ImageInfo(ll_Idx) = lt_ImageInfo
    ll_Idx = ll_Idx + 1
    Call mo_Db.Next(ll_Cursor)
  Wend
  Call mo_Db.Close(ll_Cursor)
  Exit Sub
ErrHandler:
  Call ErrorHandler("LoadSelImageInfo")
End Sub

Private Sub LoadBigImage(ByVal al_ImageInfoIdx As Long)

  If al_ImageInfoIdx >= 0 Then
    lbl_SelName.Caption = mt_ImageInfo(al_ImageInfoIdx).Name
    lbl_SelDesc.Caption = mt_ImageInfo(al_ImageInfoIdx).Desc
    'Set pct_SelImageBig.Picture = mt_ImageInfo(pct_SelImageSmall(Index).Tag).Picture
    Call mo_Tools.DrawDPCImage(mo_Db, mo_FSO, ms_DPCImageCachePath, mt_ImageInfo(al_ImageInfoIdx).IMG_Id, pct_SelImageBig)
  Else
    lbl_SelName.Caption = ""
    lbl_SelDesc.Caption = ""
    Set pct_SelImageBig.Picture = Nothing
  End If
  pct_SelImageBig.Tag = al_ImageInfoIdx
  Exit Sub
ErrHandler:
  Call ErrorHandler("LoadSelImageInfo")
End Sub

Private Sub pct_SelImageSmall_Click(Index As Integer)
On Error GoTo ErrHandler
  
  If mb_InternalInit Then Exit Sub
  mb_InternalInit = True
  Call mo_Tools.LockScreen(Me, True)
  If SelectedIndex = -1 Or SelectedIndex <> pct_SelImageSmall(Index).Tag Then
    Call shp_Selected.Move(pct_SelImageSmall(Index).Left - ScaleX(shp_Selected.BorderWidth, vbPixels, vbTwips), pct_SelImageSmall(Index).Top - ScaleY(shp_Selected.BorderWidth, vbPixels, vbTwips))
    shp_Selected.Visible = True
    SelectedIndex = pct_SelImageSmall(Index).Tag
  Else
    SelectedIndex = -1
    shp_Selected.Visible = False
  End If
  Call LoadBigImage(SelectedIndex)
  Scale
  Call mo_Tools.LockScreen(Me, False)
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("pct_SelImageSmall_Click")
End Sub

Private Sub pct_SelImageSmall_DblClick(Index As Integer)
On Error GoTo ErrHandler
  
  If SelectedIndex = -1 Then
    Call pct_SelImageSmall_Click(Index)
  End If
  Call btn_Validate_Click
  Exit Sub
ErrHandler:
  Call ErrorMessage("pct_SelImageSmall_DblClick")
End Sub

Private Sub pct_SelImageSmall_MouseMove(Index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)
On Error GoTo ErrHandler
  
  If mb_InternalInit Then Exit Sub
  mb_InternalInit = True
  If SelectedIndex = -1 Then
    If (pct_SelImageSmall(Index).Tag <> pct_SelImageBig.Tag) Then
      Call mo_Tools.LockScreen(Me, True)
      Call LoadBigImage(pct_SelImageSmall(Index).Tag)
      Call mo_Tools.LockScreen(Me, False)
    End If
  End If
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("pct_SelImageSmall_MouseMove")
End Sub

Private Sub fra_Images_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
On Error GoTo ErrHandler
    
  If mb_InternalInit Then Exit Sub
  mb_InternalInit = True
  If SelectedIndex = -1 Then
    Call LoadBigImage(SelectedIndex)
  End If
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("fra_Images_MouseMove")
End Sub

Private Sub fra_Selection_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
On Error GoTo ErrHandler
    
  If mb_InternalInit Then Exit Sub
  mb_InternalInit = True
  If SelectedIndex = -1 Then
    Call LoadBigImage(SelectedIndex)
  End If
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("fra_Selection_MouseMove")
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
On Error GoTo ErrHandler
    
  If mb_InternalInit Then Exit Sub
  mb_InternalInit = True
  If SelectedIndex = -1 Then
    Call LoadBigImage(SelectedIndex)
  End If
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("Form_MouseMove")
End Sub

Private Sub lbl_Name_MouseDown(Index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)
On Error GoTo ErrHandler
    
  If mb_InternalInit Then Exit Sub
  mb_InternalInit = True
  If SelectedIndex = -1 Then
    Call LoadBigImage(SelectedIndex)
  End If
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("lbl_Name_MouseDown")
End Sub

Private Sub vsc_ScrollBar_Change()
On Error GoTo ErrHandler
  
  If mb_InternalInit Then Exit Sub
  mb_InternalInit = True
  Call mo_Tools.LockScreen(Me, True)
  Call DisplayImages
  Call mo_Tools.LockScreen(Me, False)
  mb_InternalInit = False
  Exit Sub
ErrHandler:
  Call ErrorMessage("vsc_ScrollBar_Change")
End Sub

Private Sub btn_Quit_Click()
On Error GoTo ErrHandler
    
  Result = False
  Hide
  Exit Sub
ErrHandler:
  Call ErrorMessage("btn_Quit_Click")
End Sub

Private Sub btn_Validate_Click()
On Error GoTo ErrHandler
  
  Call mo_Tools.LockScreen(Me, True)
  
  If SelectedIndex = -1 Then
    Call mo_Tools.ShowMsg(mo_Db, ms_Language_Code, 9723, "#Please select item")
    Call mo_Tools.LockScreen(Me, False)
    Exit Sub
  End If
  SelectedId = mt_ImageInfo(SelectedIndex).Id
  SelectedIMG_Id = mt_ImageInfo(SelectedIndex).IMG_Id
  Set SelectedPicture = mt_ImageInfo(SelectedIndex).Picture
  SelectedName = mt_ImageInfo(SelectedIndex).Name
  SelectedDesc = mt_ImageInfo(SelectedIndex).Desc
  
  Result = True
  Hide
  Call mo_Tools.LockScreen(Me, False)
  Exit Sub
ErrHandler:
  Call ErrorMessage("btn_Validate_Click")
End Sub

' display standard error message
Public Sub ErrorMessage(ByVal as_Fct As String)
    Dim ls_ErrSource As String
    Dim ls_errDescription As String
    Dim ls_Message As String
    
    ls_ErrSource = as_Fct & SEP1 & Err.Source
    ls_errDescription = Err.Description
    ls_Message = SCREEN_NAME & " exception. Nr:" & Err.Number & ",Desc: " & ls_errDescription & ",Src:" & ls_ErrSource & "@"
    Call mo_Tools.LogMessage(mo_Db, ml_U_Code, SCREEN_NAME, ls_Message, "E")
    Call MsgBox("Error occured, please contact IT. Application will now shutdown." & vbCrLf & ls_ErrSource & vbCrLf & "Description: " & ls_errDescription, vbCritical, App.Title & " " & App.Major & "." & App.Minor & "." & App.Revision)
    End
End Sub

' Standard error handler
Private Sub ErrorHandler(ByVal as_Fct As String)
  
    Call Err.Raise(Err.Number, Me.Name & "." & as_Fct & SEP1 & Err.Source, Err.Description)
End Sub



