home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Visual Basic 6.0 Utilities / Multi-Language Add-In for Visual Basic 6.0 / MultiLang.msi / _AF3F81744EF811D5BEBE0020182C1E5C (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2001-05-24  |  16.2 KB  |  480 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         =   "SimpleEditor"
  6.    ClientHeight    =   2484
  7.    ClientLeft      =   132
  8.    ClientTop       =   708
  9.    ClientWidth     =   3744
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   2484
  12.    ScaleWidth      =   3744
  13.    StartUpPosition =   3  'Windows Default
  14.    Begin VB.TextBox Text1 
  15.       BeginProperty Font 
  16.          Name            =   "Courier New"
  17.          Size            =   10.2
  18.          Charset         =   0
  19.          Weight          =   400
  20.          Underline       =   0   'False
  21.          Italic          =   0   'False
  22.          Strikethrough   =   0   'False
  23.       EndProperty
  24.       Height          =   1452
  25.       Left            =   1200
  26.       MultiLine       =   -1  'True
  27.       ScrollBars      =   3  'Both
  28.       TabIndex        =   2
  29.       Top             =   480
  30.       Width           =   2412
  31.    End
  32.    Begin MSComctlLib.Toolbar tbToolBar 
  33.       Align           =   1  'Align Top
  34.       Height          =   336
  35.       Left            =   0
  36.       TabIndex        =   1
  37.       Top             =   0
  38.       Width           =   3744
  39.       _ExtentX        =   6604
  40.       _ExtentY        =   593
  41.       ButtonWidth     =   487
  42.       ButtonHeight    =   466
  43.       Appearance      =   1
  44.       ImageList       =   "imlToolbarIcons"
  45.       _Version        =   393216
  46.       BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628} 
  47.          NumButtons      =   7
  48.          BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  49.             Key             =   "New"
  50.             Object.ToolTipText     =   "New"
  51.             ImageKey        =   "New"
  52.          EndProperty
  53.          BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  54.             Key             =   "Open"
  55.             Object.ToolTipText     =   "Open"
  56.             ImageKey        =   "Open"
  57.          EndProperty
  58.          BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  59.             Key             =   "Save"
  60.             Object.ToolTipText     =   "Save"
  61.             ImageKey        =   "Save"
  62.          EndProperty
  63.          BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  64.             Style           =   3
  65.          EndProperty
  66.          BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  67.             Key             =   "Cut"
  68.             Object.ToolTipText     =   "Cut"
  69.             ImageKey        =   "Cut"
  70.          EndProperty
  71.          BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  72.             Key             =   "Copy"
  73.             Object.ToolTipText     =   "Copy"
  74.             ImageKey        =   "Copy"
  75.          EndProperty
  76.          BeginProperty Button7 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  77.             Key             =   "Paste"
  78.             Object.ToolTipText     =   "Paste"
  79.             ImageKey        =   "Paste"
  80.          EndProperty
  81.       EndProperty
  82.    End
  83.    Begin MSComDlg.CommonDialog dlgCommonDialog 
  84.       Left            =   120
  85.       Top             =   360
  86.       _ExtentX        =   677
  87.       _ExtentY        =   677
  88.       _Version        =   393216
  89.    End
  90.    Begin MSComctlLib.StatusBar sbStatusBar 
  91.       Align           =   2  'Align Bottom
  92.       Height          =   264
  93.       Left            =   0
  94.       TabIndex        =   0
  95.       Top             =   2220
  96.       Width           =   3744
  97.       _ExtentX        =   6604
  98.       _ExtentY        =   466
  99.       _Version        =   393216
  100.       BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
  101.          NumPanels       =   3
  102.          BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  103.             AutoSize        =   1
  104.             Text            =   "Status"
  105.             TextSave        =   "Status"
  106.          EndProperty
  107.          BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  108.             Style           =   6
  109.             AutoSize        =   2
  110.             TextSave        =   "5/23/01"
  111.          EndProperty
  112.          BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  113.             Style           =   5
  114.             AutoSize        =   2
  115.             TextSave        =   "11:04 PM"
  116.          EndProperty
  117.       EndProperty
  118.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  119.          Name            =   "MS Sans Serif"
  120.          Size            =   7.8
  121.          Charset         =   0
  122.          Weight          =   400
  123.          Underline       =   0   'False
  124.          Italic          =   0   'False
  125.          Strikethrough   =   0   'False
  126.       EndProperty
  127.    End
  128.    Begin MSComctlLib.ImageList imlToolbarIcons 
  129.       Left            =   600
  130.       Top             =   360
  131.       _ExtentX        =   804
  132.       _ExtentY        =   804
  133.       BackColor       =   -2147483643
  134.       ImageWidth      =   16
  135.       ImageHeight     =   16
  136.       MaskColor       =   12632256
  137.       _Version        =   393216
  138.       BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
  139.          NumListImages   =   6
  140.          BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  141.             Picture         =   "frmMain.frx":0000
  142.             Key             =   "New"
  143.          EndProperty
  144.          BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  145.             Picture         =   "frmMain.frx":0112
  146.             Key             =   "Open"
  147.          EndProperty
  148.          BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  149.             Picture         =   "frmMain.frx":0224
  150.             Key             =   "Save"
  151.          EndProperty
  152.          BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  153.             Picture         =   "frmMain.frx":0336
  154.             Key             =   "Cut"
  155.          EndProperty
  156.          BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  157.             Picture         =   "frmMain.frx":0448
  158.             Key             =   "Copy"
  159.          EndProperty
  160.          BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  161.             Picture         =   "frmMain.frx":055A
  162.             Key             =   "Paste"
  163.          EndProperty
  164.       EndProperty
  165.    End
  166.    Begin VB.Menu mnuFile 
  167.       Caption         =   "&File"
  168.       Begin VB.Menu mnuFileNew 
  169.          Caption         =   "&New"
  170.          Shortcut        =   ^N
  171.       End
  172.       Begin VB.Menu mnuFileOpen 
  173.          Caption         =   "&Open..."
  174.       End
  175.       Begin VB.Menu mnuFileClose 
  176.          Caption         =   "&Close"
  177.       End
  178.       Begin VB.Menu mnuFileBar0 
  179.          Caption         =   "-"
  180.       End
  181.       Begin VB.Menu mnuFileSave 
  182.          Caption         =   "&Save"
  183.       End
  184.       Begin VB.Menu mnuFileSaveAs 
  185.          Caption         =   "Save &As..."
  186.       End
  187.       Begin VB.Menu mnuFileBar1 
  188.          Caption         =   "-"
  189.       End
  190.       Begin VB.Menu mnuFileExit 
  191.          Caption         =   "E&xit"
  192.       End
  193.    End
  194.    Begin VB.Menu mnuEdit 
  195.       Caption         =   "&Edit"
  196.       Begin VB.Menu mnuEditCut 
  197.          Caption         =   "Cu&t"
  198.          Shortcut        =   ^X
  199.       End
  200.       Begin VB.Menu mnuEditCopy 
  201.          Caption         =   "&Copy"
  202.          Shortcut        =   ^C
  203.       End
  204.       Begin VB.Menu mnuEditPaste 
  205.          Caption         =   "&Paste"
  206.          Shortcut        =   ^V
  207.       End
  208.    End
  209.    Begin VB.Menu mnuView 
  210.       Caption         =   "&View"
  211.       Begin VB.Menu mnuViewToolbar 
  212.          Caption         =   "&Toolbar"
  213.          Checked         =   -1  'True
  214.       End
  215.       Begin VB.Menu mnuViewStatusBar 
  216.          Caption         =   "Status &Bar"
  217.          Checked         =   -1  'True
  218.       End
  219.    End
  220.    Begin VB.Menu mnuTools 
  221.       Caption         =   "&Tools"
  222.    End
  223.    Begin VB.Menu mnuHelp 
  224.       Caption         =   "&Help"
  225.       Begin VB.Menu mnuHelpAbout 
  226.          Caption         =   "&About "
  227.       End
  228.    End
  229. Attribute VB_Name = "frmMain"
  230. Attribute VB_GlobalNameSpace = False
  231. Attribute VB_Creatable = False
  232. Attribute VB_PredeclaredId = True
  233. Attribute VB_Exposed = False
  234. Option Explicit
  235. '-------------------------------------------------------------------------------
  236. 'API declarations
  237. '-------------------------------------------------------------------------------
  238. Private Declare Function GetModuleFileName Lib "kernel32" Alias "GetModuleFileNameA" (ByVal hModule As Long, ByVal lpFileName As String, ByVal nSize As Long) As Long
  239. Private Const SW_SHOWNORMAL = 1
  240. Private Const SW_SHOWMINIMIZED = 2
  241. Private Const SW_SHOWMAXIMIZED = 3
  242. Private Type POINTAPI
  243.         x As Long
  244.         y As Long
  245. End Type
  246. Private Type RECT
  247.         Left As Long
  248.         Top As Long
  249.         Right As Long
  250.         Bottom As Long
  251. End Type
  252. Private Type WINDOWPLACEMENT
  253.         Length As Long
  254.         flags As Long
  255.         showCmd As Long
  256.         ptMinPosition As POINTAPI
  257.         ptMaxPosition As POINTAPI
  258.         rcNormalPosition As RECT
  259. End Type
  260. Private Declare Function GetWindowPlacement Lib "user32" (ByVal hwnd As Long, lpwndpl As WINDOWPLACEMENT) As Long
  261. Private Declare Function SetWindowPlacement Lib "user32" (ByVal hwnd As Long, lpwndpl As WINDOWPLACEMENT) As Long
  262. '-------------------------------------------------------------------------------
  263. 'End of API declarations
  264. '-------------------------------------------------------------------------------
  265. Private fso As New FileSystemObject
  266. Private sFile As String
  267. Private bDirty As Boolean
  268. Private Sub Form_Load()
  269.   ml_UpdateControls
  270.   'If you want to copy anything from this program, this is the most useful feature.
  271.   'Using GetWindowPlacement and SetWindowPlacement enable you so save the normal
  272.   'position of the window correctly, even if the window is maximised.
  273.   Dim wp As WINDOWPLACEMENT
  274.   GetWindowPlacement hwnd, wp
  275.   wp.rcNormalPosition.Top = GetSetting(App.Title, "Settings", "MainTop", 100)
  276.   wp.rcNormalPosition.Left = GetSetting(App.Title, "Settings", "MainLeft", 100)
  277.   wp.rcNormalPosition.Bottom = GetSetting(App.Title, "Settings", "MainBottom", 500)
  278.   wp.rcNormalPosition.Right = GetSetting(App.Title, "Settings", "MainRight", 500)
  279.   wp.showCmd = GetSetting(App.Title, "Settings", "MainState", SW_SHOWNORMAL)
  280.   SetWindowPlacement hwnd, wp
  281.   'Extra resize, because SetWindowPlacement causes the toolbar to be too high.
  282.   'You can't win 'em all!
  283.   DoEvents
  284.   Form_Resize
  285. End Sub
  286. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  287.   'Save file if dirty flag is set
  288.   Dim Response As VbMsgBoxResult
  289.   Response = PromptIfDirty
  290.   If Response = vbCancel Then
  291.     Cancel = 1
  292.   End If
  293. End Sub
  294. Private Sub Form_Resize()
  295.   Dim ClientTop As Long
  296.   Dim ClientHeight As Long
  297.   If mnuViewToolbar.Checked Then
  298.     ClientTop = tbToolBar.Height
  299.   Else
  300.     ClientTop = 0
  301.   End If
  302.   If mnuViewStatusBar.Checked Then
  303.     ClientHeight = Me.ScaleHeight - ClientTop - sbStatusBar.Height
  304.   Else
  305.     ClientHeight = Me.ScaleHeight - ClientTop
  306.   End If
  307.   Text1.Move 0, ClientTop, Me.ScaleWidth, ClientHeight
  308. End Sub
  309. Private Sub Form_Unload(Cancel As Integer)
  310.   Dim i As Integer
  311.   'close all sub forms
  312.   For i = Forms.Count - 1 To 1 Step -1
  313.     Unload Forms(i)
  314.   Next
  315.   'Window position.
  316.   'GetWindowPlacement() get the normal position when the window is maximised.
  317.   Dim wp As WINDOWPLACEMENT
  318.   GetWindowPlacement hwnd, wp
  319.   If wp.showCmd = SW_SHOWMINIMIZED Then
  320.     wp.showCmd = SW_SHOWNORMAL
  321.   End If
  322.   SaveSetting App.Title, "Settings", "MainLeft", wp.rcNormalPosition.Left
  323.   SaveSetting App.Title, "Settings", "MainTop", wp.rcNormalPosition.Top
  324.   SaveSetting App.Title, "Settings", "MainRight", wp.rcNormalPosition.Right
  325.   SaveSetting App.Title, "Settings", "MainBottom", wp.rcNormalPosition.Bottom
  326.   SaveSetting App.Title, "Settings", "MainState", wp.showCmd
  327. End Sub
  328. Private Sub tbToolBar_ButtonClick(ByVal Button As MSComCtlLib.Button)
  329.   On Error Resume Next
  330.   Select Case Button.Key
  331.     Case "New"
  332.       mnuFileNew_Click
  333.     Case "Open"
  334.       mnuFileOpen_Click
  335.     Case "Save"
  336.       mnuFileSave_Click
  337.     Case "Cut"
  338.       mnuEditCut_Click
  339.     Case "Copy"
  340.       mnuEditCopy_Click
  341.     Case "Paste"
  342.       mnuEditPaste_Click
  343.   End Select
  344. End Sub
  345. Private Sub mnuHelpAbout_Click()
  346.   frmAbout.Show vbModal, Me
  347. End Sub
  348. Private Sub mnuViewStatusBar_Click()
  349.   mnuViewStatusBar.Checked = Not mnuViewStatusBar.Checked
  350.   sbStatusBar.Visible = mnuViewStatusBar.Checked
  351.   Form_Resize
  352. End Sub
  353. Private Sub mnuViewToolbar_Click()
  354.   mnuViewToolbar.Checked = Not mnuViewToolbar.Checked
  355.   tbToolBar.Visible = mnuViewToolbar.Checked
  356.   Form_Resize
  357. End Sub
  358. Private Sub mnuEditPaste_Click()
  359.   Text1.SelText = Clipboard.GetText()
  360. End Sub
  361. Private Sub mnuEditCopy_Click()
  362.   Clipboard.Clear
  363.   Clipboard.SetText Text1.SelText
  364. End Sub
  365. Private Sub mnuEditCut_Click()
  366.   Clipboard.Clear
  367.   Clipboard.SetText Text1.SelText
  368.   Text1.SelText = ""
  369. End Sub
  370. Private Sub mnuFileExit_Click()
  371.   'unload the form
  372.   Unload Me
  373. End Sub
  374. Private Sub mnuFileSaveAs_Click()
  375.   With dlgCommonDialog
  376.     .DialogTitle = ml_string(43, "Save")
  377.     .CancelError = False
  378.     .Filter = ml_string(44, "All Files (*.*)|*.*|Text Files (*.txt)|*.txt")
  379.     .FilterIndex = 2
  380.     .ShowSave
  381.     If Len(.FileName) = 0 Then
  382.       Exit Sub
  383.     End If
  384.     sFile = .FileName
  385.   End With
  386.   Dim txt As TextStream
  387.   Set txt = fso.CreateTextFile(sFile)
  388.   txt.Write Text1.Text
  389. End Sub
  390. Private Sub mnuFileSave_Click()
  391.   If sFile = "" Then
  392.     mnuFileSaveAs_Click
  393.   Else
  394.     Dim txt As TextStream
  395.     Set txt = fso.CreateTextFile(sFile)
  396.     txt.Write Text1.Text
  397.   End If
  398. End Sub
  399. Private Sub mnuFileClose_Click()
  400.   'Its a stupid menu item. Close and New are identical!
  401.   mnuFileNew_Click
  402. End Sub
  403. Private Sub mnuFileOpen_Click()
  404.   With dlgCommonDialog
  405.     .DialogTitle = ml_string(45, "Open")
  406.     .CancelError = False
  407.     .Filter = ml_string(44, "All Files (*.*)|*.*|Text Files (*.txt)|*.txt")
  408.     .FilterIndex = 2
  409.     .ShowOpen
  410.     If Len(.FileName) = 0 Then
  411.       Exit Sub
  412.     End If
  413.     sFile = .FileName
  414.   End With
  415.   'Put the file name in the title bar
  416.   Me.Caption = App.Title & " - " & sFile
  417.   'Read the file
  418.   Dim txt As TextStream
  419.   Set txt = fso.OpenTextFile(sFile)
  420.   Text1.Text = txt.ReadAll
  421.   'Clear the dirty flag
  422.   bDirty = False
  423. End Sub
  424. Private Sub mnuFileNew_Click()
  425.   Dim Response As VbMsgBoxResult
  426.   'Save file if dirty flag is set
  427.   Response = PromptIfDirty
  428.   If Response <> vbCancel Then
  429.     'Clear the text
  430.     Text1.Text = ""
  431.     'Clear the dirty flag
  432.     bDirty = False
  433.   End If
  434. End Sub
  435. Private Sub Text1_Change()
  436.   bDirty = True
  437. End Sub
  438. Private Function PromptIfDirty() As VbMsgBoxResult
  439.   Dim Response As VbMsgBoxResult
  440.   If bDirty Then
  441.     Response = MsgBox(ml_string(46, "Save changes?"), vbYesNoCancel, ml_string(47, "SimpleEditor"))
  442.     If Response = vbYes Then
  443.       mnuFileSave_Click
  444.       bDirty = False
  445.     End If
  446.   Else
  447.     Response = vbOK
  448.   End If
  449.   PromptIfDirty = Response
  450. End Function
  451. Private Sub ml_UpdateControls()
  452.   Me.Caption = ml_string(1)
  453.   mnuEdit.Caption = ml_string(18)
  454.   mnuEditCopy.Caption = ml_string(20)
  455.   mnuEditCut.Caption = ml_string(19)
  456.   mnuEditPaste.Caption = ml_string(21)
  457.   mnuFile.Caption = ml_string(9)
  458.   mnuFileBar0.Caption = ml_string(13)
  459.   mnuFileBar1.Caption = ml_string(16)
  460.   mnuFileClose.Caption = ml_string(12)
  461.   mnuFileExit.Caption = ml_string(17)
  462.   mnuFileNew.Caption = ml_string(10)
  463.   mnuFileOpen.Caption = ml_string(11)
  464.   mnuFileSave.Caption = ml_string(14)
  465.   mnuFileSaveAs.Caption = ml_string(15)
  466.   mnuHelp.Caption = ml_string(26)
  467.   mnuHelpAbout.Caption = ml_string(27)
  468.   mnuTools.Caption = ml_string(25)
  469.   mnuView.Caption = ml_string(22)
  470.   mnuViewStatusBar.Caption = ml_string(24)
  471.   mnuViewToolbar.Caption = ml_string(23)
  472.   sbStatusBar.Panels(1).Text = ml_string(8)
  473.   tbToolBar.Buttons(1).ToolTipText = ml_string(2)
  474.   tbToolBar.Buttons(2).ToolTipText = ml_string(3)
  475.   tbToolBar.Buttons(3).ToolTipText = ml_string(4)
  476.   tbToolBar.Buttons(5).ToolTipText = ml_string(5)
  477.   tbToolBar.Buttons(6).ToolTipText = ml_string(6)
  478.   tbToolBar.Buttons(7).ToolTipText = ml_string(7)
  479. End Sub
  480.