vbAccelerator - Contents of code file: fOptions.frm

VERSION 5.00
Begin VB.Form frmOptions 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "Goldfish Options"
   ClientHeight    =   5460
   ClientLeft      =   5400
   ClientTop       =   3120
   ClientWidth     =   6060
   BeginProperty Font 
      Name            =   "Tahoma"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   Icon            =   "fOptions.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   5460
   ScaleWidth      =   6060
   ShowInTaskbar   =   0   'False
   StartUpPosition =   1  'CenterOwner
   Begin VB.CheckBox chkAlwaysOnTop 
      Caption         =   "I want to be on &Top"
      Height          =   315
      Left            =   360
      TabIndex        =   17
      Top             =   4380
      Width           =   5355
   End
   Begin VB.ListBox lstFormats 
      Height          =   1185
      Left            =   300
      Style           =   1  'Checkbox
      TabIndex        =   16
      Top             =   1440
      Width           =   5295
   End
   Begin VB.OptionButton optStartMode 
      Caption         =   "&No thankyou, I'd rather start it when I want it
       myself."
      Height          =   255
      Index           =   1
      Left            =   300
      TabIndex        =   14
      Top             =   3540
      Width           =   5415
   End
   Begin VB.OptionButton optStartMode 
      Caption         =   "&Yes, I'd like to it get to it in the system tray."
      Height          =   255
      Index           =   0
      Left            =   300
      TabIndex        =   13
      Top             =   3300
      Value           =   -1  'True
      Width           =   5415
   End
   Begin VB.TextBox txtLines 
      Height          =   375
      Left            =   300
      MaxLength       =   3
      TabIndex        =   11
      Text            =   "10"
      Top             =   360
      Width           =   1755
   End
   Begin VB.Frame fraSep 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   75
      Left            =   -540
      TabIndex        =   9
      Top             =   4860
      Width           =   6795
   End
   Begin VB.PictureBox picOptions 
      BorderStyle     =   0  'None
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   3780
      Index           =   3
      Left            =   -20000
      ScaleHeight     =   3780
      ScaleWidth      =   5685
      TabIndex        =   5
      TabStop         =   0   'False
      Top             =   480
      Width           =   5685
      Begin VB.Frame fraSample4 
         Caption         =   "Sample 4"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   1785
         Left            =   2100
         TabIndex        =   8
         Top             =   840
         Width           =   2055
      End
   End
   Begin VB.PictureBox picOptions 
      BorderStyle     =   0  'None
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   3780
      Index           =   2
      Left            =   -20000
      ScaleHeight     =   3780
      ScaleWidth      =   5685
      TabIndex        =   4
      TabStop         =   0   'False
      Top             =   480
      Width           =   5685
      Begin VB.Frame fraSample3 
         Caption         =   "Sample 3"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   1785
         Left            =   1545
         TabIndex        =   7
         Top             =   675
         Width           =   2055
      End
   End
   Begin VB.PictureBox picOptions 
      BorderStyle     =   0  'None
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   3780
      Index           =   1
      Left            =   -20000
      ScaleHeight     =   3780
      ScaleWidth      =   5685
      TabIndex        =   3
      TabStop         =   0   'False
      Top             =   480
      Width           =   5685
      Begin VB.Frame fraSample2 
         Caption         =   "Sample 2"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   1785
         Left            =   645
         TabIndex        =   6
         Top             =   300
         Width           =   2055
      End
   End
   Begin VB.CommandButton cmdApply 
      Caption         =   "Apply"
      Height          =   360
      Left            =   4860
      TabIndex        =   2
      Top             =   5040
      Width           =   1155
   End
   Begin VB.CommandButton cmdCancel 
      Cancel          =   -1  'True
      Caption         =   "Cancel"
      Height          =   375
      Left            =   3660
      TabIndex        =   1
      Top             =   5040
      Width           =   1155
   End
   Begin VB.CommandButton cmdOK 
      Caption         =   "OK"
      Default         =   -1  'True
      Height          =   375
      Left            =   2460
      TabIndex        =   0
      Top             =   5040
      Width           =   1155
   End
   Begin VB.Label lblInfo 
      Caption         =   "You can make Goldfish float over other windows on
       your system by setting it to be always on top:"
      ForeColor       =   &H80000008&
      Height          =   435
      Index           =   3
      Left            =   120
      TabIndex        =   18
      Top             =   3960
      Width           =   5715
   End
   Begin VB.Label lblInfo 
      Caption         =   $"fOptions.frx":000C
      Height          =   495
      Index           =   2
      Left            =   120
      TabIndex        =   15
      Top             =   900
      Width           =   5835
   End
   Begin VB.Label lblInfo 
      Caption         =   $"fOptions.frx":00AC
      ForeColor       =   &H80000008&
      Height          =   435
      Index           =   1
      Left            =   120
      TabIndex        =   12
      Top             =   2880
      Width           =   5715
   End
   Begin VB.Label lblInfo 
      Caption         =   "Number of clipboard entries to keep:"
      Height          =   255
      Index           =   0
      Left            =   120
      TabIndex        =   10
      Top             =   120
      Width           =   5715
   End
End
Attribute VB_Name = "frmOptions"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private m_lLines As Long
Private m_fOwner As frmGoldfish

Private Const ES_NUMBER As Long = &H2000

Public Property Let OwnerForm(ByRef fThis As frmGoldfish)
    Set m_fOwner = fThis
End Property

Private Function pbValidate() As Boolean
Dim lLines As Long
    If IsNumeric(txtLines) Then
        lLines = CLng(txtLines)
        If (lLines < 0) Or (lLines > 512) Then
            MsgBox "The number of clipboard entries to keep must be between 1
             and 512", vbInformation
            txtLines.SetFocus
        Else
            m_lLines = lLines
            ' Ensure there is a valid selection in the format box
            ' (Text must always be selected).
            lstFormats.Selected(0) = True
            pbValidate = True
        End If
    Else
        MsgBox "Please enter a valid number of clipboard entries (1-512).",
         vbInformation
        txtLines.SetFocus
    End If
End Function
Private Sub pSetOptions()
Dim i As Long
    m_fOwner.NumberOfLines = m_lLines
    m_fOwner.InSysTray = (optStartMode(0).Value)
    For i = 0 To lstFormats.ListCount - 1
        m_fOwner.DoStoreFormat(lstFormats.ItemData(i)) = lstFormats.Selected(i)
    Next i
    m_fOwner.AlwaysOnTop = (chkAlwaysOnTop.Value = Checked)
End Sub
Private Sub cmdApply_Click()
    If (pbValidate()) Then
        pSetOptions
    End If
End Sub

Private Sub cmdCancel_Click()
   ' Ensure we reset on top flag if cancel:
   If (chkAlwaysOnTop.Tag <> "") Then
      m_fOwner.AlwaysOnTop = True
   End If
   Unload Me
End Sub

Private Sub cmdOK_Click()
    If (pbValidate()) Then
        pSetOptions
        Unload Me
    End If
End Sub

Private Sub Form_Load()
Dim lStyle As Long

   ' Ensure only numeric in the text box & set to number of lines:
   txtLines.Text = CLng(m_fOwner.NumberOfLines)
   lStyle = GetWindowLong(txtLines.hWnd, GWL_STYLE)
   SetWindowLong txtLines.hWnd, GWL_STYLE, lStyle Or ES_NUMBER
   
   ' In SysTray?
    If (m_fOwner.InSysTray) Then
        optStartMode(0).Value = True
    Else
        optStartMode(1).Value = True
    End If
    
    ' add format options:
    With lstFormats
        .AddItem "Text"
        .ItemData(.NewIndex) = m_fOwner.FormatID("Text")
        .Selected(.NewIndex) = m_fOwner.DoStoreFormat(.ItemData(.NewIndex))
        .AddItem "Rich Text Format"
        .ItemData(.NewIndex) = m_fOwner.FormatID("Rich Text Format")
        .Selected(.NewIndex) = m_fOwner.DoStoreFormat(.ItemData(.NewIndex))
        .AddItem "HTML Format"
        .ItemData(.NewIndex) = m_fOwner.FormatID("HTML Format")
        .Selected(.NewIndex) = m_fOwner.DoStoreFormat(.ItemData(.NewIndex))
        .AddItem "CSV Format"
        .ItemData(.NewIndex) = m_fOwner.FormatID("Csv")
        .Selected(.NewIndex) = m_fOwner.DoStoreFormat(.ItemData(.NewIndex))
    End With
    
    If (m_fOwner.AlwaysOnTop) Then
      chkAlwaysOnTop.Value = Checked
      chkAlwaysOnTop.Tag = "ONTOP"
      ' Turn off always on top so the options actually
      ' go to the top of the ZOrder!
      m_fOwner.AlwaysOnTop = False
   End If
        
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
   SetWindowPos Me.hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE
    Or SWP_NOZORDER
End Sub