home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / CODE_UPLOAD112141122000.psc / IniViewer / Forms / frmMain.frm (.txt) next >
Encoding:
Visual Basic Form  |  2000-11-02  |  10.2 KB  |  295 lines

  1. VERSION 5.00
  2. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
  3. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  4. Begin VB.Form frmMain 
  5.    Caption         =   "Main"
  6.    ClientHeight    =   5520
  7.    ClientLeft      =   60
  8.    ClientTop       =   720
  9.    ClientWidth     =   8865
  10.    Icon            =   "frmMain.frx":0000
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   5520
  13.    ScaleWidth      =   8865
  14.    StartUpPosition =   2  'CenterScreen
  15.    Begin VB.CommandButton cmdEdit 
  16.       Caption         =   "&Edit"
  17.       Height          =   375
  18.       Left            =   5490
  19.       TabIndex        =   2
  20.       ToolTipText     =   "Click here to edit selected Section/Key/Value"
  21.       Top             =   5130
  22.       Width           =   500
  23.    End
  24.    Begin MSComDlg.CommonDialog CommonDialog1 
  25.       Left            =   5760
  26.       Top             =   60
  27.       _ExtentX        =   847
  28.       _ExtentY        =   847
  29.       _Version        =   393216
  30.    End
  31.    Begin MSComctlLib.ImageList imgSmall 
  32.       Left            =   8100
  33.       Top             =   4680
  34.       _ExtentX        =   1005
  35.       _ExtentY        =   1005
  36.       BackColor       =   -2147483643
  37.       ImageWidth      =   16
  38.       ImageHeight     =   16
  39.       MaskColor       =   12632256
  40.       _Version        =   393216
  41.       BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
  42.          NumListImages   =   5
  43.          BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  44.             Picture         =   "frmMain.frx":0442
  45.             Key             =   ""
  46.          EndProperty
  47.          BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  48.             Picture         =   "frmMain.frx":08A2
  49.             Key             =   ""
  50.          EndProperty
  51.          BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  52.             Picture         =   "frmMain.frx":0D02
  53.             Key             =   ""
  54.          EndProperty
  55.          BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  56.             Picture         =   "frmMain.frx":1156
  57.             Key             =   ""
  58.          EndProperty
  59.          BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  60.             Picture         =   "frmMain.frx":15AA
  61.             Key             =   ""
  62.          EndProperty
  63.       EndProperty
  64.    End
  65.    Begin MSComctlLib.TreeView treMain 
  66.       Height          =   5085
  67.       Left            =   30
  68.       TabIndex        =   0
  69.       Top             =   30
  70.       Width           =   8865
  71.       _ExtentX        =   15637
  72.       _ExtentY        =   8969
  73.       _Version        =   393217
  74.       Indentation     =   18
  75.       LineStyle       =   1
  76.       Style           =   7
  77.       ImageList       =   "imgSmall"
  78.       BorderStyle     =   1
  79.       Appearance      =   1
  80.    End
  81.    Begin MSComctlLib.StatusBar stBar 
  82.       Align           =   2  'Align Bottom
  83.       Height          =   405
  84.       Left            =   0
  85.       TabIndex        =   1
  86.       Top             =   5115
  87.       Width           =   8865
  88.       _ExtentX        =   15637
  89.       _ExtentY        =   714
  90.       _Version        =   393216
  91.       BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
  92.          NumPanels       =   4
  93.          BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  94.             Picture         =   "frmMain.frx":18C6
  95.             Text            =   "IniEditor"
  96.             TextSave        =   "IniEditor"
  97.          EndProperty
  98.          BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  99.             Object.Width           =   7056
  100.             MinWidth        =   7056
  101.          EndProperty
  102.          BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  103.             Bevel           =   2
  104.             Object.Width           =   882
  105.             MinWidth        =   882
  106.             Text            =   "Edit"
  107.             TextSave        =   "Edit"
  108.             Object.ToolTipText     =   "Click Here to Edit The Selected Node"
  109.          EndProperty
  110.          BeginProperty Panel4 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  111.             Style           =   5
  112.             TextSave        =   "1:06 AM"
  113.          EndProperty
  114.       EndProperty
  115.    End
  116.    Begin VB.Menu mnuPopup 
  117.       Caption         =   "&File"
  118.       Begin VB.Menu mnuPopupOpen 
  119.          Caption         =   "&Open"
  120.       End
  121.       Begin VB.Menu mnuPopUpInsert 
  122.          Caption         =   "&Insert"
  123.       End
  124.       Begin VB.Menu mnuPopUpDelete 
  125.          Caption         =   "&Delete"
  126.       End
  127.       Begin VB.Menu mnuFileEdit 
  128.          Caption         =   "&Edit"
  129.       End
  130.       Begin VB.Menu mnuPopupSave 
  131.          Caption         =   "&Save"
  132.       End
  133.       Begin VB.Menu mnuPopupBreak 
  134.          Caption         =   "-"
  135.       End
  136.       Begin VB.Menu mnuPopupAbout 
  137.          Caption         =   "&About"
  138.       End
  139.       Begin VB.Menu mnuPopupReadme 
  140.          Caption         =   "&ReadMe"
  141.       End
  142.       Begin VB.Menu mnuPopupBreak1 
  143.          Caption         =   "-"
  144.       End
  145.       Begin VB.Menu mnuPopupExit 
  146.          Caption         =   "E&xit"
  147.       End
  148.    End
  149. Attribute VB_Name = "frmMain"
  150. Attribute VB_GlobalNameSpace = False
  151. Attribute VB_Creatable = False
  152. Attribute VB_PredeclaredId = True
  153. Attribute VB_Exposed = False
  154. Private Sub cmdEdit_Click()
  155. mnuFileEdit_Click
  156. End Sub
  157. Private Sub Form_Load()
  158. ' Get the name of the app and put it in the Caption
  159. strAppName = App.EXEName & " - v" & App.Major & "." & App.Minor & "." & App.Revision
  160. Me.Caption = strAppName
  161. 'mnuPopup.Visible = False
  162. End Sub
  163. Private Sub Form_Resize()
  164. ' Resize the objects relative to the form size
  165. If Me.WindowState = 1 Then Exit Sub
  166. treMain.Height = frmMain.Height - 1095 '915
  167. treMain.Width = frmMain.Width - 120
  168. stBar.Panels(2).Width = (frmMain.Width - (stBar.Panels(1).Width + stBar.Panels(3).Width + stBar.Panels(4).Width))
  169. 'cmdBrowse.Top = treMain.Height + 20
  170. cmdEdit.Top = treMain.Height + 20
  171. cmdEdit.Left = stBar.Panels(1).Width + stBar.Panels(2).Width + 60
  172. End Sub
  173. Private Sub Form_Unload(Cancel As Integer)
  174. ' Give resources back to user
  175. Set frmMain = Nothing
  176. Set nodRoot = Nothing
  177. Set nodSec = Nothing
  178. Set nodKey = Nothing
  179. Set nodValue = Nothing
  180. Set nodCurrentProj = Nothing
  181. End Sub
  182. Private Sub mnuFileEdit_Click()
  183. On Error GoTo EdErr
  184. treMain.StartLabelEdit
  185. EdErr:
  186. End Sub
  187. Private Sub mnuPopupAbout_Click()
  188. MsgBox strAppName & " By: Michael Heath" _
  189. & Chr(10) & "Last Build Date: 2 Nov 2000" & Chr(10) & Chr(10) & _
  190. "Description: " & App.FileDescription & Chr(10) & _
  191. "Email: " & "mheath@indy.net", vbOKOnly + vbInformation, "About IniEditor"
  192. End Sub
  193. Private Sub mnuPopUpDelete_Click()
  194. DeleteNode
  195. End Sub
  196. Private Sub mnuPopupExit_Click()
  197. Unload Me
  198. End Sub
  199. Private Sub mnuPopUpInsert_Click()
  200. InsertNode
  201. End Sub
  202. Private Sub mnuPopupOpen_Click()
  203. ' Open a Common Dialog box and look for only ini files
  204. OpenFile Me, "INI Files(*.ini) | *.ini"
  205. If NoOpen = False Then
  206.     GetIniInfo CurrentFileName
  207. End If
  208. End Sub
  209. Private Sub mnuPopupReadme_Click()
  210. vLaunch App.Path & "\readme.txt"
  211. End Sub
  212. Private Sub mnuPopupSave_Click()
  213. ' Error Handler
  214. On Error GoTo TreeErr
  215. ' If there is no file loaded raise the error number to exit the sub
  216. If CurrentFileName = "" Then Err.Raise 75
  217. ' Warn user that any additional text in file will be lost
  218. ' This editor can only deal with Sections/Keys/Values
  219. Dim ansStr As String
  220. ansStr = MsgBox("Any comments or items not associated with the current file will be lost. Are you sure you want to make these changes?" _
  221. , vbYesNo + vbCritical, "Warning")
  222. Select Case ansStr
  223.     Case vbYes
  224.         Dim intNew As Long
  225.         ' Open the ini file
  226.             Open CurrentFileName For Output As #1
  227.                 ' Cycle through all the nodes
  228.                 For intNew = 1 To treMain.Nodes.Count
  229.                     ' Check the tag of each node to see what kind of data we have
  230.                     If treMain.Nodes(intNew).Tag = "Section" Then
  231.                         If intNew = 2 Then ' First line, can't have a blank one
  232.                             Print #1, "[" & treMain.Nodes(intNew) & "]"
  233.                         Else
  234.                             Print #1, vbCrLf & "[" & treMain.Nodes(intNew) & "]"
  235.                         End If
  236.                     ElseIf treMain.Nodes(intNew).Tag = "Key" Then
  237.                         If treMain.Nodes(intNew + 1).Tag = "Value" Then
  238.                             Print #1, treMain.Nodes(intNew) & "=" & treMain.Nodes(intNew + 1)
  239.                         Else
  240.                             Print #1, treMain.Nodes(intNew) & "-"
  241.                         End If
  242.                     End If
  243.                 Next intNew
  244.             Close #1
  245.             MsgBox "Save Complete", vbOKOnly, "IniViewer & Editor"
  246.     Case vbNo
  247.         MsgBox "Save Aborted", vbOKOnly, "IniViewer & Editor"
  248. End Select
  249. Exit Sub
  250. TreeErr:
  251.     If Err.Number = 75 Then ' File Path access error
  252.         MsgBox "No file opened.", vbOKOnly + vbCritical, "File Not Found"
  253.         Exit Sub
  254.     Else
  255.         MsgBox "An error occurred - " & Err.Description & Chr(10) _
  256.         & "Program terminating", vbOKOnly + vbCritical, "Fatal Error"
  257.         Unload Me
  258.         End
  259.     End If
  260. End Sub
  261. Private Sub treMain_Click()
  262. ' If a Section Node is expanded, then we want to change the image
  263. ' I only know how to do this when the item is selected.
  264. On Error GoTo ldErr
  265. stBar.Panels(2).Text = treMain.SelectedItem.Text
  266. If treMain.SelectedItem.Tag = "Section" Then
  267.     If treMain.SelectedItem.Expanded = True Then
  268.         treMain.SelectedItem.Image = 3
  269.     Else
  270.         treMain.SelectedItem.Image = 4
  271.     End If
  272. End If
  273. ldErr:
  274.     Exit Sub
  275. End Sub
  276. Private Sub treMain_DblClick()
  277. ' If a Section Node is expanded, then we want to change the image
  278. ' I only know how to do this when the item is selected.
  279. On Error GoTo ldErr
  280. If treMain.SelectedItem.Tag = "Section" Then
  281.     If treMain.SelectedItem.Expanded = True Then
  282.         treMain.SelectedItem.Image = 3
  283.     Else
  284.         treMain.SelectedItem.Image = 4
  285.     End If
  286. End If
  287. ldErr:
  288.     Exit Sub
  289. End Sub
  290. Private Sub treMain_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  291. If Button = 2 Then
  292.     PopupMenu mnuPopup
  293. End If
  294. End Sub
  295.