vbAccelerator - Contents of code file: frmLaunch.frm

VERSION 5.00
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "COMCTL32.OCX"
Begin VB.Form frmLaunch 
   Caption         =   "Hooked Common Dialog Tester 2"
   ClientHeight    =   5952
   ClientLeft      =   2736
   ClientTop       =   1824
   ClientWidth     =   6204
   Icon            =   "frmLaunch.frx":0000
   LinkTopic       =   "Form1"
   ScaleHeight     =   5952
   ScaleWidth      =   6204
   Begin VB.CommandButton cmdNew 
      Caption         =   "Startup &View New"
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   8.4
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   60
      TabIndex        =   0
      Top             =   60
      Width           =   1575
   End
   Begin VB.TextBox txtFile 
      BeginProperty Font 
         Name            =   "Lucida Console"
         Size            =   8.4
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   4875
      Left            =   60
      MultiLine       =   -1  'True
      ScrollBars      =   3  'Both
      TabIndex        =   1
      Text            =   "frmLaunch.frx":014A
      Top             =   720
      Width           =   6135
   End
   Begin VB.CheckBox chkToggleView 
      Caption         =   "Show start up view"
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   8.4
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   195
      Left            =   120
      TabIndex        =   2
      Top             =   5670
      Value           =   1  'Checked
      Width           =   3975
   End
   Begin VB.Label lblFile 
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   8.4
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   60
      TabIndex        =   4
      Top             =   480
      Width           =   6075
   End
   Begin ComctlLib.ImageList ilsIcons32 
      Left            =   1200
      Top             =   60
      _ExtentX        =   995
      _ExtentY        =   995
      BackColor       =   -2147483643
      ImageWidth      =   32
      ImageHeight     =   32
      MaskColor       =   12632256
      _Version        =   327682
      BeginProperty Images {0713E8C2-850A-101B-AFC0-4210102A8DA7} 
         NumListImages   =   2
         BeginProperty ListImage1 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
            Picture         =   "frmLaunch.frx":026B
            Key             =   "HTML"
         EndProperty
         BeginProperty ListImage2 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
            Picture         =   "frmLaunch.frx":0585
            Key             =   "TEXT"
         EndProperty
      EndProperty
   End
   Begin ComctlLib.ImageList ilsIcons16 
      Left            =   1800
      Top             =   60
      _ExtentX        =   995
      _ExtentY        =   995
      BackColor       =   -2147483643
      ImageWidth      =   16
      ImageHeight     =   16
      MaskColor       =   12632256
      _Version        =   327682
      BeginProperty Images {0713E8C2-850A-101B-AFC0-4210102A8DA7} 
         NumListImages   =   2
         BeginProperty ListImage1 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
            Picture         =   "frmLaunch.frx":089F
            Key             =   "HTML"
         EndProperty
         BeginProperty ListImage2 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
            Picture         =   "frmLaunch.frx":0BB9
            Key             =   "TEXT"
         EndProperty
      EndProperty
   End
   Begin VB.Label lblInfo 
      Caption         =   "Visit vbAccelerator on the web at
       http://vbaccelerator.com/"
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   8.4
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   435
      Left            =   3300
      TabIndex        =   3
      Top             =   60
      Width           =   2775
   End
End
Attribute VB_Name = "frmLaunch"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit


Private Sub cmdNew_Click()
    
   If chkToggleView.Value = Unchecked Then
      frmNew.ShowNew = 0
   Else
      frmNew.ShowNew = 1
   End If
    
   If frmNew.ShowNew Then
     frmNew.AddNewType "HTML File", "HTML"
     frmNew.AddNewType "Text File", "TEXT"
     frmNew.NewImageList = ilsIcons32
   End If
    
   frmNew.AddExistItem "Readme2.Txt", App.Path & "\", "9/21/98", "TEXT"
   frmNew.AddExistItem "Deletedfile.Txt", App.Path & "\", "9/23/98", "HTML"
   frmNew.AddExistItem "ccnews.Htm", App.Path & "\", "9/25/98", "HTML"
   frmNew.ExistingImageList = ilsIcons16
    
   Set frmNew.cD = New cCommonDialog
   frmNew.cD.InitDir = App.Path
   frmNew.cD.Filter = "Text Files (*.TXT)|*.TXT|All Files (*.*)|*.*"
   frmNew.cD.flags = OFN_FILEMUSTEXIST Or OFN_PATHMUSTEXIST
   frmNew.cD.FilterIndex = 1
   frmNew.cD.DefaultExt = "Txt"
   frmNew.cD.HookDialog = True
    
   'Make Dialog owner Me
   frmNew.cD.hWnd = Me.hWnd
   Load frmNew
    
   frmNew.cD.ShowOpen
    
   If Not frmNew.Cancelled Then
      lblFile.Caption = "New:" & frmNew.FileName
      If frmNew.IsNew Then
         If frmNew.FileName = "HTML File" Then
            txtFile.Text = "<HTML>" & vbCrLf & vbCrLf & "<HEADER" & vbCrLf &
             "</HEADER>" & vbCrLf & vbCrLf & "<BODY>" & vbCrLf & "</BODY>" &
             vbCrLf & vbCrLf & "</HTML>"
         Else
            txtFile.Text = ""
         End If
      Else
         txtFile.Text = GetFileText(frmNew.FileName)
      End If
   End If
   
   
   If frmNew.ShowNew Then
      chkToggleView.Value = 1
   Else
      chkToggleView.Value = 0
   End If
   
   Unload frmNew
   Set frmNew = Nothing
   
End Sub
Private Function GetFileText(ByVal sFile As String) As String
On Local Error GoTo GetFileTextError
Dim iFIle As Integer
Dim sBuf As String
    iFIle = FreeFile
    Open sFile For Binary Access Read As #iFIle
    sBuf = String$(LOF(iFIle), 32)
    Get #iFIle, , sBuf
    Close #iFIle
    GetFileText = sBuf
    Exit Function

GetFileTextError:
    MsgBox "The file: " & sFile & " could not be loaded." & vbCrLf & vbCrLf &
     "[" & Err.Number & ":" & Err.Description & "]", vbExclamation
    Close #iFIle
    Exit Function
End Function

Private Sub chkToggleView_Click()
   If chkToggleView.Value = Unchecked Then
      cmdNew.Caption = "Normal Run &View"
   Else
      cmdNew.Caption = "Startup &View New"
   End If
End Sub



Private Sub Form_Resize()
Dim lL As Long
On Error Resume Next
   txtFile.Move txtFile.Left, txtFile.Top, Me.ScaleWidth - txtFile.Left * 2,
    Me.ScaleHeight - txtFile.Top - chkToggleView.Height - 8 *
    Screen.TwipsPerPixelY
   chkToggleView.Top = txtFile.Top + txtFile.Height + 2 * Screen.TwipsPerPixelY
   lL = Me.ScaleWidth - lblInfo.Width - txtFile.Left
   If lL < cmdNew.Left + cmdNew.Width + 2 * Screen.TwipsPerPixelX Then
      lL = cmdNew.Left + cmdNew.Width + 2 * Screen.TwipsPerPixelX
   End If
   lblInfo.Left = lL
End Sub