vbAccelerator - Contents of code file: fTest6.frm

VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form fTest 
   Appearance      =   0  'Flat
   Caption         =   "vbAccelerator Common Dialog/Direct Tester"
   ClientHeight    =   7095
   ClientLeft      =   1215
   ClientTop       =   1095
   ClientWidth     =   8670
   Icon            =   "fTest6.frx":0000
   LinkTopic       =   "Form1"
   ScaleHeight     =   7095
   ScaleWidth      =   8670
   Begin VB.OptionButton optType 
      Caption         =   "Centre Hooked Dialogs to &Screen"
      Height          =   195
      Index           =   1
      Left            =   1620
      TabIndex        =   39
      Top             =   6840
      Width           =   6435
   End
   Begin VB.OptionButton optType 
      Caption         =   "Centre Hooked Dialogs to &Form"
      Height          =   195
      Index           =   0
      Left            =   1620
      TabIndex        =   38
      Top             =   6600
      Value           =   -1  'True
      Width           =   6435
   End
   Begin VB.PictureBox picTab 
      BorderStyle     =   0  'None
      Height          =   5955
      Index           =   3
      Left            =   1260
      ScaleHeight     =   5955
      ScaleWidth      =   8235
      TabIndex        =   0
      Top             =   180
      Width           =   8235
      Begin VB.CommandButton cmdHookSetup 
         Caption         =   "Hooked Pa&ge Setup..."
         Height          =   495
         Left            =   60
         TabIndex        =   37
         Top             =   2760
         Width           =   1335
      End
      Begin VB.CommandButton cmdPrintHook 
         Caption         =   "Hooked Print Set&up..."
         Height          =   495
         Left            =   60
         TabIndex        =   34
         Top             =   2220
         Width           =   1335
      End
      Begin VB.CommandButton cmdPageSetup 
         Caption         =   "Pa&ge Setup..."
         Height          =   495
         Left            =   60
         TabIndex        =   31
         Top             =   1200
         Width           =   1335
      End
      Begin VB.CommandButton cmdPrint 
         Caption         =   "&Print..."
         Height          =   495
         Left            =   60
         TabIndex        =   2
         Top             =   0
         Width           =   1335
      End
      Begin VB.CommandButton cmdPrintSetup 
         Caption         =   "Print Set&up..."
         Height          =   495
         Left            =   60
         TabIndex        =   1
         Top             =   600
         Width           =   1335
      End
      Begin VB.Label lblInfo 
         Caption         =   "Printer:"
         Height          =   255
         Index           =   9
         Left            =   1560
         TabIndex        =   3
         Top             =   60
         Width           =   6555
      End
   End
   Begin VB.PictureBox picTab 
      BorderStyle     =   0  'None
      Height          =   5955
      Index           =   1
      Left            =   720
      ScaleHeight     =   5955
      ScaleWidth      =   8235
      TabIndex        =   12
      Top             =   420
      Width           =   8235
      Begin VB.CommandButton cmdColorHook 
         Caption         =   "Hooked Choose Color"
         Height          =   495
         Left            =   0
         TabIndex        =   36
         Top             =   2700
         Width           =   1455
      End
      Begin VB.CommandButton cmdColor 
         Caption         =   "&Choose Color"
         Height          =   495
         Left            =   0
         TabIndex        =   18
         Top             =   0
         Width           =   1455
      End
      Begin VB.PictureBox picColor 
         Height          =   555
         Left            =   1560
         ScaleHeight     =   495
         ScaleWidth      =   6495
         TabIndex        =   17
         Top             =   240
         Width           =   6555
      End
      Begin VB.CommandButton cmdLoadColours 
         Caption         =   "&Load Custom Colours..."
         Height          =   495
         Left            =   0
         TabIndex        =   16
         Top             =   1260
         Width           =   1455
      End
      Begin VB.CommandButton cmdSave 
         Caption         =   "&SaveCustom Colours..."
         Height          =   495
         Left            =   0
         TabIndex        =   15
         Top             =   1860
         Width           =   1455
      End
      Begin VB.TextBox txtINIFile 
         Height          =   3675
         Left            =   1560
         MultiLine       =   -1  'True
         ScrollBars      =   2  'Vertical
         TabIndex        =   14
         Top             =   1260
         Width           =   6555
      End
      Begin VB.TextBox txtColorNo 
         Height          =   285
         Left            =   2280
         TabIndex        =   13
         Top             =   840
         Width           =   2595
      End
      Begin VB.Label lblInfo 
         Caption         =   "Colour:"
         Height          =   255
         Index           =   3
         Left            =   1560
         TabIndex        =   20
         Top             =   0
         Width           =   6555
      End
      Begin VB.Label lblNumber 
         Caption         =   "Number:"
         Height          =   255
         Left            =   1560
         TabIndex        =   19
         Top             =   900
         Width           =   615
      End
   End
   Begin VB.CommandButton cmdHelp 
      Caption         =   "&Help..."
      Height          =   375
      Left            =   60
      TabIndex        =   32
      Top             =   6600
      Width           =   1335
   End
   Begin VB.PictureBox picTab 
      BorderStyle     =   0  'None
      Height          =   5955
      Index           =   2
      Left            =   2700
      ScaleHeight     =   5955
      ScaleWidth      =   8235
      TabIndex        =   4
      Top             =   360
      Width           =   8235
      Begin VB.CommandButton cmdFontHooked 
         Caption         =   "Hooked Choose Font"
         Height          =   495
         Left            =   60
         TabIndex        =   35
         Top             =   960
         Width           =   1335
      End
      Begin VB.PictureBox picFontSample 
         AutoRedraw      =   -1  'True
         Height          =   1455
         Left            =   1500
         ScaleHeight     =   1395
         ScaleWidth      =   6495
         TabIndex        =   8
         Top             =   420
         Width           =   6555
      End
      Begin VB.CommandButton cmdFont 
         Caption         =   "Choose &Font"
         Height          =   495
         Left            =   60
         TabIndex        =   7
         Top             =   0
         Width           =   1335
      End
      Begin VB.TextBox txtFontMin 
         Height          =   315
         Left            =   2520
         TabIndex        =   6
         Text            =   "8"
         Top             =   1980
         Width           =   1935
      End
      Begin VB.TextBox txtFontMax 
         Height          =   315
         Left            =   2520
         TabIndex        =   5
         Text            =   "28"
         Top             =   2340
         Width           =   1935
      End
      Begin VB.Label lblInfo 
         Caption         =   "Min Size:"
         Height          =   255
         Index           =   5
         Left            =   1500
         TabIndex        =   10
         Top             =   2040
         Width           =   975
      End
      Begin VB.Label lblInfo 
         Caption         =   "Max Size:"
         Height          =   255
         Index           =   6
         Left            =   1500
         TabIndex        =   9
         Top             =   2400
         Width           =   975
      End
      Begin VB.Label lblInfo 
         Caption         =   "Font:"
         Height          =   255
         Index           =   4
         Left            =   1560
         TabIndex        =   11
         Top             =   60
         Width           =   6555
      End
   End
   Begin VB.PictureBox picTab 
      BorderStyle     =   0  'None
      Height          =   5955
      Index           =   0
      Left            =   60
      ScaleHeight     =   5955
      ScaleWidth      =   8235
      TabIndex        =   21
      Top             =   420
      Width           =   8235
      Begin VB.CommandButton cmdHookOpen 
         Caption         =   "cCommonDialog call - Hooked Open"
         Height          =   675
         Left            =   0
         TabIndex        =   33
         Top             =   2040
         Width           =   1455
      End
      Begin VB.CommandButton cmdClassSave 
         Caption         =   "cCommonDialog call - Save"
         Height          =   495
         Left            =   0
         TabIndex        =   27
         Top             =   1140
         Width           =   1455
      End
      Begin VB.TextBox txtContents 
         Height          =   4395
         Left            =   1560
         MultiLine       =   -1  'True
         ScrollBars      =   2  'Vertical
         TabIndex        =   26
         Top             =   1500
         Width           =   6555
      End
      Begin VB.TextBox txtFilter 
         Height          =   315
         Left            =   1560
         TabIndex        =   25
         Top             =   900
         Width           =   6495
      End
      Begin VB.CommandButton cmdClassOpen 
         Caption         =   "cCommonDialog call - Open"
         Height          =   555
         Left            =   0
         TabIndex        =   24
         Top             =   540
         Width           =   1455
      End
      Begin VB.CommandButton cmdGlobal 
         Caption         =   "&Global Call"
         Height          =   495
         Left            =   0
         TabIndex        =   23
         Top             =   0
         Width           =   1455
      End
      Begin VB.TextBox txtFileName 
         Height          =   315
         Left            =   1560
         TabIndex        =   22
         Top             =   240
         Width           =   6495
      End
      Begin VB.Label lblInfo 
         Caption         =   "Contents"
         Height          =   255
         Index           =   0
         Left            =   1560
         TabIndex        =   30
         Top             =   1260
         Width           =   6555
      End
      Begin VB.Label lblInfo 
         Caption         =   "Chosen Filter"
         Height          =   255
         Index           =   1
         Left            =   1560
         TabIndex        =   29
         Top             =   660
         Width           =   6555
      End
      Begin VB.Label lblInfo 
         Caption         =   "File Name"
         Height          =   255
         Index           =   2
         Left            =   1560
         TabIndex        =   28
         Top             =   0
         Width           =   6555
      End
   End
   Begin MSComctlLib.TabStrip tabContents 
      Height          =   6495
      Left            =   60
      TabIndex        =   40
      Top             =   0
      Width           =   8535
      _ExtentX        =   15055
      _ExtentY        =   11456
      _Version        =   393216
      BeginProperty Tabs {1EFB6598-857C-11D1-B16A-00C0F0283628} 
         NumTabs         =   4
         BeginProperty Tab1 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
            Caption         =   "File Dialog"
            ImageVarType    =   2
         EndProperty
         BeginProperty Tab2 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
            Caption         =   "Colour dialog"
            ImageVarType    =   2
         EndProperty
         BeginProperty Tab3 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
            Caption         =   "Font dialog"
            ImageVarType    =   2
         EndProperty
         BeginProperty Tab4 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
            Caption         =   "Print dialog"
            ImageVarType    =   2
         EndProperty
      EndProperty
   End
End
Attribute VB_Name = "fTest"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private m_sSampleText As String
Private WithEvents m_cHookDlg As cCommonDialog
Attribute m_cHookDlg.VB_VarHelpID = -1
 

Private Sub cmdHookSetup_Click()
Dim Owner As Long
Dim bDisableMargins As Boolean
Dim bDisableOrientation As Boolean
Dim bDisablePaper As Boolean
Dim bDisablePrinter As Boolean
Dim fLeftMargin As Single
Dim fMinLeftMargin As Single
Dim fRightMargin As Single
Dim fMinRightMargin As Single
Dim fTopMargin As Single
Dim fMinTopMargin As Single
Dim fBottomMargin As Single
Dim fMinBottomMargin As Single
Dim ePaperSize As ePaperSize
Dim eOrientation As eOrientation
Dim ePrintQuality As ePrintQuality
Dim eUnits As EPageSetupUnits
Dim lflags As Long

    If VBPageSetupDlg2( _
        Me.hWnd, _
        bDisableMargins, _
        bDisableOrientation, _
        bDisablePaper, _
        bDisablePrinter, _
        fLeftMargin, _
        fMinLeftMargin, _
        fRightMargin, _
        fMinRightMargin, _
        fTopMargin, _
        fMinTopMargin, _
        fBottomMargin, _
        fMinBottomMargin, _
        ePaperSize, _
        eOrientation, _
        ePrintQuality, _
        eUnits, _
        Printer, _
        0, _
        True, _
        m_cHookDlg) Then
        Debug.Print "LeftMargin:", fLeftMargin
        Debug.Print "MinLeftMargin:", fMinLeftMargin
        Debug.Print "TopMargin:", fTopMargin
        Debug.Print "MinTopMargin:", fMinTopMargin
        Debug.Print "RightMargin:", fRightMargin
        Debug.Print "MinRightMargin:", fMinRightMargin
        Debug.Print "BottomMargin:", fBottomMargin
        Debug.Print "MinBottomMargin:", fMinBottomMargin
        Debug.Print "PaperSize:", ePaperSize
        Debug.Print "Orientation:", eOrientation
        Debug.Print "PrintQuality:", ePrintQuality
        Debug.Print "Units:", eUnits
    End If
End Sub
Private Sub pShowColorNumber()
Dim sColor As String, lCLen As Long
    sColor = Hex$(picColor.BackColor)
    lCLen = Len(sColor)
    If (lCLen < 6) Then sColor = String$((6 - lCLen), "0") & sColor
    txtColorNo = "&H" & sColor

End Sub
Private Sub pRenderSampleText()
    picFontSample.Cls
    picFontSample.Print m_sSampleText
    picFontSample.Refresh
End Sub

Private Function SaveFileText(ByVal sFIle As String, ByRef sText As String)
Dim nFile As Integer
Dim bFileOpen As Boolean
    
    On Error Resume Next
    Kill sFIle
    nFile = FreeFile
    On Error GoTo SaveFileTextError
    Open sFIle For Binary Access Write Lock Read As nFile
    bFileOpen = True
    Put #nFile, , sText 'Print #nFile, sText
    Close nFile
    bFileOpen = False
    SaveFileText = 0
    Exit Function
    
SaveFileTextError:
    SaveFileText = Err.Number
    If (bFileOpen) Then
        Close #nFile
    End If
    Exit Function
End Function
Private Function GetFileText(ByVal sFIle As String) As String
Dim nFile As Integer
Dim sText As String
Dim bFileOpen As Boolean

On Error GoTo GetFileTextError
    
    nFile = FreeFile
    Open sFIle For Binary Access Read Lock Write As #nFile
    bFileOpen = True
    sText = String$(LOF(nFile), 0)
    Get #nFile, 1, sText
    Close #nFile
    bFileOpen = False
    GetFileText = sText
    Exit Function
    
GetFileTextError:
    GetFileText = Err.Number
    If (bFileOpen) Then
        Close #nFile
    End If
    Exit Function

End Function

Private Sub cmdClassSave_Click()
On Error GoTo cmdClassError
    
    Dim c As New cCommonDialog
    With c
        .DialogTitle = "Choose Text FIle"
        .CancelError = True
        .hWnd = Me.hWnd
        .flags = OFN_OVERWRITEPROMPT
        .InitDir = "C:\STEVEMAC"
        .Filter = "Internet documents (*.HTM)|*.HTM|Text files
         (*.TXT)|*.TXT|All Files (*.*)|*.*"
        .FilterIndex = 1
        .FileName = "C:\STEVEMAC\TEST.HTM"
        .ShowSave

        SaveFileText .FileName, (txtContents.Text)
        txtFileName = .FileName
        txtFilter = .Filter
        
    End With
    
    Exit Sub

cmdClassError:
    If (Err.Number <> 20001) Then
        MsgBox "Error: " & Err.Description
    End If
    
End Sub


Private Sub cmdColorHook_Click()
On Error GoTo cmdFontHookedError
    
    With m_cHookDlg
        .HookDialog = True
        .DialogTitle = "Choose a Color"
        .flags = CC_AnyColor Or CC_FullOpen
        .CancelError = True
        .hWnd = Me.hWnd
        .Color = picColor.BackColor
        .ShowColor
        picColor.BackColor = .Color
        
        pShowColorNumber
    End With
    
    Exit Sub
cmdFontHookedError:
    If (Err.Number <> 20001) Then
        MsgBox "Error: " & Err.Description
    End If
    Exit Sub
End Sub

Private Sub cmdFontHooked_Click()
On Error GoTo cmdFontHookedError
    With m_cHookDlg
        .HookDialog = True
        .Font = picFontSample.Font
        .FontColor = picFontSample.ForeColor
        .CancelError = True
        .flags = CF_EFFECTS Or CF_ScreenFonts
        .hWnd = Me.hWnd
        .Min = CLng(txtFontMin)
        .Max = CLng(txtFontMax)
        .ShowFont
    
        picFontSample.Font = .Font
        picFontSample.ForeColor = .FontColor
    End With
    pRenderSampleText

    Exit Sub
cmdFontHookedError:
    If (Err.Number <> 20001) Then
        MsgBox "Error: " & Err.Description
    End If
    Exit Sub
End Sub

Private Sub cmdGlobal_Click()
Dim lFilterIndex As Long
Dim sFileName As String
    lFilterIndex = 1
    If (VBGetOpenFileName( _
        sFileName, , True, False, , True, _
        "Internet Documents (*.HTM)|*.HTM|All Files (*.*)|*.*", lFilterIndex, _
        "C:\STEVEMAC", "Choose Text File", "TXT", Me.hWnd)) Then
        MsgBox "Success"
    Else
        If (APIReturn = 0) Then
            MsgBox "Cancelled"
        Else
            MsgBox "Extended Error: " & ExtendedError
        End If
    End If

End Sub
Private Sub cmdClassOpen_Click()
On Error GoTo cmdClassError
    Dim c As New cCommonDialog
    With c
        .DialogTitle = "Choose Text FIle"
        .CancelError = True
        .hWnd = Me.hWnd
        .flags = OFN_FILEMUSTEXIST Or OFN_PATHMUSTEXIST
        .InitDir = "C:\STEVEMAC"
        .Filter = "Internet documents (*.HTM)|*.HTM|Text files
         (*.TXT)|*.TXT|All Files (*.*)|*.*"
        .FilterIndex = 1
        .ShowOpen
        
        txtFileName = .FileName
        txtFilter = .Filter
        txtContents = GetFileText(.FileName)
        
    End With
    
    Exit Sub

cmdClassError:
    If (Err.Number <> 20001) Then
        MsgBox "Error: " & Err.Description
    End If
    
End Sub
Private Sub cmdColor_Click()
On Error GoTo cmdColorError
    Dim c As New cCommonDialog
    With c
        .DialogTitle = "Choose a Color"
        .flags = CC_AnyColor Or CC_FullOpen
        .CancelError = True
        .hWnd = Me.hWnd
        .Color = picColor.BackColor
        .ShowColor
        picColor.BackColor = .Color
        
        pShowColorNumber
    End With
    Exit Sub
cmdColorError:
    If (Err.Number <> 20001) Then
        MsgBox "Error: " & Err.Description
    End If
End Sub

Private Sub cmdHookOpen_Click()
On Error GoTo cmdHookError

    With m_cHookDlg
        .DialogTitle = "Choose Text FIle"
        .CancelError = True
        .flags = OFN_FILEMUSTEXIST Or OFN_PATHMUSTEXIST
        .InitDir = "C:\STEVEMAC"
        .Filter = "Internet documents (*.HTM)|*.HTM|Text files
         (*.TXT)|*.TXT|All Files (*.*)|*.*"
        .FilterIndex = 1
        .HookDialog = True
        .ShowOpen

        txtFileName = .FileName
        txtFilter = .Filter
        txtContents = GetFileText(.FileName)
        
    End With
    
    Exit Sub

cmdHookError:
    If (Err.Number <> 20001) Then
        MsgBox "Error: " & Err.Description
    End If

End Sub

Private Sub cmdPageSetup_Click()
Dim Owner As Long
Dim bDisableMargins As Boolean
Dim bDisableOrientation As Boolean
Dim bDisablePaper As Boolean
Dim bDisablePrinter As Boolean
Dim lLeftMargin As Long
Dim lMinLeftMargin As Long
Dim lRightMargin As Long
Dim lMinRightMargin As Long
Dim lTopMargin As Long
Dim lMinTopMargin As Long
Dim lBottomMargin As Long
Dim lMinBottomMargin As Long
Dim ePaperSize As ePaperSize
Dim eOrientation As eOrientation
Dim ePrintQuality As ePrintQuality
Dim eUnits As EPageSetupUnits
Dim lflags As Long
    VBPageSetupDlg _
        Me.hWnd, _
        bDisableMargins, _
        bDisableOrientation, _
        bDisablePaper, _
        bDisablePrinter, _
        lLeftMargin, _
        lMinLeftMargin, _
        lRightMargin, _
        lMinRightMargin, _
        lTopMargin, _
        lMinTopMargin, _
        lBottomMargin, _
        lMinBottomMargin, _
        ePaperSize, _
        eOrientation, _
        ePrintQuality, _
        eUnits, _
        Printer
    Debug.Print lLeftMargin
End Sub

Private Sub cmdPrintHook_Click()
    With m_cHookDlg
        .HookDialog = True
        .DialogTitle = "Choose Printer"
        .hWnd = Me.hWnd
        .PrinterDefault = True
        .Object = Printer
        .ShowPrinter
    End With
    
End Sub

Private Sub cmdSave_Click()
Dim lColor As OLE_COLOR
Dim i As Long
Dim sOut As String
    
On Error GoTo cmdSaveColoursError
    Dim c As New cCommonDialog
    With c
        .DialogTitle = "Choose File to Save Custom Colours to"
        .Filter = "Custom Colour Set Files (*.CSF)|*.CSF|All Files (*.*)|*.*"
        .DefaultExt = "CCSF"
        .flags = OFN_OVERWRITEPROMPT
        .FilterIndex = 1
        .CancelError = True
        .hWnd = Me.hWnd
        .ShowSave
    
        For i = 0 To 15
            sOut = sOut & CStr(c.CustomColor(i))
            If (i <> 15) Then
                sOut = sOut & vbCrLf
            End If
        Next i
        SaveFileText .FileName, sOut
        txtINIFile = sOut
    End With
    
    Exit Sub

cmdSaveColoursError:
    If (Err.Number <> 20001) Then
        MsgBox "Error occurred: " & Err.Description
    End If
    Exit Sub

End Sub
Private Sub cmdLoadColours_Click()
Dim lColor As OLE_COLOR
Dim i As Long
Dim iPos As Long
Dim iNextPos As Long
Dim sText As String
    
On Error GoTo cmdLoadColoursError
    
    Dim c As New cCommonDialog
    With c
        .DialogTitle = "Choose Custom Colours File"
        .Filter = "Custom Colour Set Files (*.CSF)|*.CSF|All Files (*.*)|*.*"
        .DefaultExt = "CCSF"
        .flags = OFN_FILEMUSTEXIST Or OFN_PATHMUSTEXIST
        .FilterIndex = 1
        .CancelError = True
        .hWnd = Me.hWnd
        .ShowOpen
    
        sText = GetFileText(.FileName)
        txtINIFile = sText
        iPos = 1
        iNextPos = InStr(sText, vbCrLf)
        Do While i < 16 And iNextPos > 0
            i = i + 1
            .CustomColor(i) = CLng(Mid$(sText, iPos, (iNextPos - iPos)))
            iPos = iNextPos + 2
            iNextPos = InStr(iPos, sText, vbCrLf)
        Loop
        
        
    End With
    
    Exit Sub
    
cmdLoadColoursError:
    If (Err.Number <> 20001) Then
        MsgBox "Error occurred: " & Err.Description
    End If
    Exit Sub
End Sub



Private Sub cmdFont_Click()
On Error GoTo cmdFontError
    Dim c As New cCommonDialog
    
    With c
        .Font = picFontSample.Font
        .FontColor = picFontSample.ForeColor
        .CancelError = True
        .flags = CF_EFFECTS Or CF_ScreenFonts
        .hWnd = Me.hWnd
        .Min = CLng(txtFontMin)
        .Max = CLng(txtFontMax)
        .ShowFont
    
        picFontSample.Font = c.Font
        picFontSample.ForeColor = .FontColor
    End With
    
    ' Note you can use fonts the old way too:
    'With picFontSample.Font
    '    .Name = c.FontName
    '    .Bold = c.FontBold
    '    .Italic = c.FontItalic
    '    .Size = c.FontSize
    '    .Strikethrough = c.FontStrikethru
    '    .Underline = c.FontUnderline
    'End With
    pRenderSampleText
    Exit Sub
cmdFontError:
    If (Err.Number <> 20001) Then
        MsgBox "Error: " & Err.Description
    End If
    Exit Sub
End Sub

Private Sub cmdPrint_Click()
    Dim c As New cCommonDialog
    With c
        .DialogTitle = "Choose Printer"
        .hWnd = Me.hWnd
        .PrinterDefault = True
        .Object = Printer
        .ShowPrinter
    End With

End Sub

Private Sub cmdPrintSetup_Click()
    Dim c As New cCommonDialog
    With c
        .DialogTitle = "Choose Printer"
        .hWnd = Me.hWnd
        .PrinterDefault = True
        .Object = Printer
        .flags = PD_PRINTSETUP
        .ShowPrinter
    End With

End Sub
Private Sub cmdHelp_Click()
    Dim c As New cCommonDialog
    c.HelpCommand = HELP_FINDER
    c.HelpFile = "C:\WINNT\HELP\WORDPAD.HLP"
    c.ShowHelp
End Sub

Private Sub Form_Load()
Dim iT As Long
    Set m_cHookDlg = New cCommonDialog
    For iT = 1 To tabContents.Tabs.Count - 1
        picTab(iT).ZOrder
        picTab(iT).Move picTab(0).Left, picTab(0).Top, picTab(0).Width,
         picTab(0).Height
    Next iT
    tabContents_Click
    m_sSampleText = "The Force is Strong"
    pRenderSampleText
    pShowColorNumber
End Sub


Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    Set m_cHookDlg = Nothing
End Sub

Private Sub m_cHookDlg_DialogClose()
    Debug.Print "DialogClosed"
End Sub

Private Sub m_cHookDlg_DialogOK(bCancel As Boolean)
    Debug.Print "DIalogOK"
    If (vbNo = MsgBox("Are you sure you want to choose this file?", vbYesNo Or
     vbQuestion)) Then
        bCancel = True
    End If
End Sub

Private Sub m_cHookDlg_FileChange(ByVal hDlg As Long)
    Debug.Print "FileChange."
End Sub

Private Sub m_cHookDlg_FolderChange(ByVal hDlg As Long)
    Debug.Print "FolderChange."
End Sub

Private Sub m_cHookDlg_InitDIalog(ByVal hDlg As Long)
    Debug.Print "INITDIALOG"
    If (optType(0).Value) Then
      m_cHookDlg.CentreDialog hDlg, Me
   Else
      m_cHookDlg.CentreDialog hDlg, Screen
   End If
End Sub

Private Sub m_cHookDlg_TypeChange(ByVal hDlg As Long)
    Debug.Print "TypeChange"
End Sub

Private Sub tabContents_Click()
Dim iTab As Long
Dim iT As Long
    iTab = tabContents.SelectedItem.Index - 1
    picTab(iTab).Visible = True
    For iT = 0 To tabContents.Tabs.Count - 1
        picTab(iT).Visible = (iT = iTab)
    Next iT
End Sub

Private Sub txtFontMax_KeyPress(KeyAscii As Integer)
    pOnlyNumeric KeyAscii
End Sub

Private Sub txtFontMin_KeyPress(KeyAscii As Integer)
    pOnlyNumeric KeyAscii
End Sub
Private Sub pOnlyNumeric(ByRef KeyAscii As Integer)
    If (KeyAscii >= Asc("0") And KeyAscii <= Asc("9")) Or KeyAscii = 8 Then
    Else
        Beep
        KeyAscii = 0
    End If

End Sub