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 / _AF3F81C94EF811D5BEBE0020182C1E5C (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2001-08-31  |  16.7 KB  |  494 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        =   "8/30/01"
  111.          EndProperty
  112.          BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  113.             Style           =   5
  114.             AutoSize        =   2
  115.             TextSave        =   "11:37 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.       Begin VB.Menu mnuToolsChangeLanguage 
  223.          Caption         =   "Change Language"
  224.       End
  225.    End
  226.    Begin VB.Menu mnuHelp 
  227.       Caption         =   "&Help"
  228.       Begin VB.Menu mnuHelpAbout 
  229.          Caption         =   "&About "
  230.       End
  231.    End
  232. Attribute VB_Name = "frmMain"
  233. Attribute VB_GlobalNameSpace = False
  234. Attribute VB_Creatable = False
  235. Attribute VB_PredeclaredId = True
  236. Attribute VB_Exposed = False
  237. Option Explicit
  238. '-------------------------------------------------------------------------------
  239. 'API declarations
  240. '-------------------------------------------------------------------------------
  241. Private Declare Function GetModuleFileName Lib "kernel32" Alias "GetModuleFileNameA" (ByVal hModule As Long, ByVal lpFileName As String, ByVal nSize As Long) As Long
  242. Private Const SW_SHOWNORMAL = 1
  243. Private Const SW_SHOWMINIMIZED = 2
  244. Private Const SW_SHOWMAXIMIZED = 3
  245. Private Type POINTAPI
  246.         x As Long
  247.         y As Long
  248. End Type
  249. Private Type RECT
  250.         Left As Long
  251.         Top As Long
  252.         Right As Long
  253.         Bottom As Long
  254. End Type
  255. Private Type WINDOWPLACEMENT
  256.         Length As Long
  257.         flags As Long
  258.         showCmd As Long
  259.         ptMinPosition As POINTAPI
  260.         ptMaxPosition As POINTAPI
  261.         rcNormalPosition As RECT
  262. End Type
  263. Private Declare Function GetWindowPlacement Lib "user32" (ByVal hwnd As Long, lpwndpl As WINDOWPLACEMENT) As Long
  264. Private Declare Function SetWindowPlacement Lib "user32" (ByVal hwnd As Long, lpwndpl As WINDOWPLACEMENT) As Long
  265. '-------------------------------------------------------------------------------
  266. 'End of API declarations
  267. '-------------------------------------------------------------------------------
  268. Private fso As New FileSystemObject
  269. Private sFile As String
  270. Private bDirty As Boolean
  271. Private WithEvents ml_RuntimeSupport As MLRUNTIMELib.MLSupport
  272. Attribute ml_RuntimeSupport.VB_VarHelpID = -1
  273. Private Sub Form_Load()
  274.   Set ml_RuntimeSupport = New MLSupport
  275.   ml_UpdateControls
  276.   'If you want to copy anything from this program, this is the most useful feature.
  277.   'Using GetWindowPlacement and SetWindowPlacement enable you so save the normal
  278.   'position of the window correctly, even if the window is maximised.
  279.   Dim wp As WINDOWPLACEMENT
  280.   GetWindowPlacement hwnd, wp
  281.   wp.rcNormalPosition.Top = GetSetting(App.Title, "Settings", "MainTop", 100)
  282.   wp.rcNormalPosition.Left = GetSetting(App.Title, "Settings", "MainLeft", 100)
  283.   wp.rcNormalPosition.Bottom = GetSetting(App.Title, "Settings", "MainBottom", 500)
  284.   wp.rcNormalPosition.Right = GetSetting(App.Title, "Settings", "MainRight", 500)
  285.   wp.showCmd = GetSetting(App.Title, "Settings", "MainState", SW_SHOWNORMAL)
  286.   SetWindowPlacement hwnd, wp
  287.   'Extra resize, because SetWindowPlacement causes the toolbar to be too high.
  288.   'You can't win 'em all!
  289.   DoEvents
  290.   Form_Resize
  291. End Sub
  292. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  293.   'Save file if dirty flag is set
  294.   Dim Response As VbMsgBoxResult
  295.   Response = PromptIfDirty
  296.   If Response = vbCancel Then
  297.     Cancel = 1
  298.   End If
  299. End Sub
  300. Private Sub Form_Resize()
  301.   Dim ClientTop As Long
  302.   Dim ClientHeight As Long
  303.   If mnuViewToolbar.Checked Then
  304.     ClientTop = tbToolBar.Height
  305.   Else
  306.     ClientTop = 0
  307.   End If
  308.   If mnuViewStatusBar.Checked Then
  309.     ClientHeight = Me.ScaleHeight - ClientTop - sbStatusBar.Height
  310.   Else
  311.     ClientHeight = Me.ScaleHeight - ClientTop
  312.   End If
  313.   Text1.Move 0, ClientTop, Me.ScaleWidth, ClientHeight
  314. End Sub
  315. Private Sub Form_Unload(Cancel As Integer)
  316.   Dim i As Integer
  317.   'close all sub forms
  318.   For i = Forms.Count - 1 To 1 Step -1
  319.     Unload Forms(i)
  320.   Next
  321.   'Window position.
  322.   'GetWindowPlacement() get the normal position when the window is maximised.
  323.   Dim wp As WINDOWPLACEMENT
  324.   GetWindowPlacement hwnd, wp
  325.   If wp.showCmd = SW_SHOWMINIMIZED Then
  326.     wp.showCmd = SW_SHOWNORMAL
  327.   End If
  328.   SaveSetting App.Title, "Settings", "MainLeft", wp.rcNormalPosition.Left
  329.   SaveSetting App.Title, "Settings", "MainTop", wp.rcNormalPosition.Top
  330.   SaveSetting App.Title, "Settings", "MainRight", wp.rcNormalPosition.Right
  331.   SaveSetting App.Title, "Settings", "MainBottom", wp.rcNormalPosition.Bottom
  332.   SaveSetting App.Title, "Settings", "MainState", wp.showCmd
  333. End Sub
  334. Private Sub tbToolBar_ButtonClick(ByVal Button As MSComCtlLib.Button)
  335.   On Error Resume Next
  336.   Select Case Button.Key
  337.     Case "New"
  338.       mnuFileNew_Click
  339.     Case "Open"
  340.       mnuFileOpen_Click
  341.     Case "Save"
  342.       mnuFileSave_Click
  343.     Case "Cut"
  344.       mnuEditCut_Click
  345.     Case "Copy"
  346.       mnuEditCopy_Click
  347.     Case "Paste"
  348.       mnuEditPaste_Click
  349.   End Select
  350. End Sub
  351. Private Sub mnuHelpAbout_Click()
  352.   frmAbout.Show vbModal, Me
  353. End Sub
  354. Private Sub mnuViewStatusBar_Click()
  355.   mnuViewStatusBar.Checked = Not mnuViewStatusBar.Checked
  356.   sbStatusBar.Visible = mnuViewStatusBar.Checked
  357.   Form_Resize
  358. End Sub
  359. Private Sub mnuViewToolbar_Click()
  360.   mnuViewToolbar.Checked = Not mnuViewToolbar.Checked
  361.   tbToolBar.Visible = mnuViewToolbar.Checked
  362.   Form_Resize
  363. End Sub
  364. Private Sub mnuEditPaste_Click()
  365.   Text1.SelText = Clipboard.GetText()
  366. End Sub
  367. Private Sub mnuEditCopy_Click()
  368.   Clipboard.Clear
  369.   Clipboard.SetText Text1.SelText
  370. End Sub
  371. Private Sub mnuEditCut_Click()
  372.   Clipboard.Clear
  373.   Clipboard.SetText Text1.SelText
  374.   Text1.SelText = ""
  375. End Sub
  376. Private Sub mnuFileExit_Click()
  377.   'unload the form
  378.   Unload Me
  379. End Sub
  380. Private Sub mnuFileSaveAs_Click()
  381.   With dlgCommonDialog
  382.     .DialogTitle = ml_string(43, "Save")
  383.     .CancelError = False
  384.     .Filter = ml_string(44, "All Files (*.*)|*.*|Text Files (*.txt)|*.txt")
  385.     .FilterIndex = 2
  386.     .ShowSave
  387.     If Len(.FileName) = 0 Then
  388.       Exit Sub
  389.     End If
  390.     sFile = .FileName
  391.   End With
  392.   Dim txt As TextStream
  393.   Set txt = fso.CreateTextFile(sFile)
  394.   txt.Write Text1.Text
  395. End Sub
  396. Private Sub mnuFileSave_Click()
  397.   If sFile = "" Then
  398.     mnuFileSaveAs_Click
  399.   Else
  400.     Dim txt As TextStream
  401.     Set txt = fso.CreateTextFile(sFile)
  402.     txt.Write Text1.Text
  403.   End If
  404. End Sub
  405. Private Sub mnuFileClose_Click()
  406.   'Its a stupid menu item. Close and New are identical!
  407.   mnuFileNew_Click
  408. End Sub
  409. Private Sub mnuFileOpen_Click()
  410.   With dlgCommonDialog
  411.     .DialogTitle = ml_string(45, "Open")
  412.     .CancelError = False
  413.     .Filter = ml_string(44, "All Files (*.*)|*.*|Text Files (*.txt)|*.txt")
  414.     .FilterIndex = 2
  415.     .ShowOpen
  416.     If Len(.FileName) = 0 Then
  417.       Exit Sub
  418.     End If
  419.     sFile = .FileName
  420.   End With
  421.   'Put the file name in the title bar
  422.   Me.Caption = App.Title & " - " & sFile
  423.   'Read the file
  424.   Dim txt As TextStream
  425.   Set txt = fso.OpenTextFile(sFile)
  426.   Text1.Text = txt.ReadAll
  427.   'Clear the dirty flag
  428.   bDirty = False
  429. End Sub
  430. Private Sub mnuFileNew_Click()
  431.   Dim Response As VbMsgBoxResult
  432.   'Save file if dirty flag is set
  433.   Response = PromptIfDirty
  434.   If Response <> vbCancel Then
  435.     'Clear the text
  436.     Text1.Text = ""
  437.     'Clear the dirty flag
  438.     bDirty = False
  439.   End If
  440. End Sub
  441. Private Sub Text1_Change()
  442.   bDirty = True
  443. End Sub
  444. Private Function PromptIfDirty() As VbMsgBoxResult
  445.   Dim Response As VbMsgBoxResult
  446.   If bDirty Then
  447.     Response = MsgBox(ml_string(46, "Save changes?"), vbYesNoCancel, ml_string(47, "SimpleEditor"))
  448.     If Response = vbYes Then
  449.       mnuFileSave_Click
  450.       bDirty = False
  451.     End If
  452.   Else
  453.     Response = vbOK
  454.   End If
  455.   PromptIfDirty = Response
  456. End Function
  457. Private Sub mnuToolsChangeLanguage_Click()
  458.   LanguageSelect.ShowDialog False
  459. End Sub
  460. Private Sub ml_UpdateControls()
  461.   Me.Caption = ml_string(1)
  462.   mnuEdit.Caption = ml_string(18)
  463.   mnuEditCopy.Caption = ml_string(20)
  464.   mnuEditCut.Caption = ml_string(19)
  465.   mnuEditPaste.Caption = ml_string(21)
  466.   mnuFile.Caption = ml_string(9)
  467.   mnuFileBar0.Caption = ml_string(13)
  468.   mnuFileBar1.Caption = ml_string(16)
  469.   mnuFileClose.Caption = ml_string(12)
  470.   mnuFileExit.Caption = ml_string(17)
  471.   mnuFileNew.Caption = ml_string(10)
  472.   mnuFileOpen.Caption = ml_string(11)
  473.   mnuFileSave.Caption = ml_string(14)
  474.   mnuFileSaveAs.Caption = ml_string(15)
  475.   mnuHelp.Caption = ml_string(26)
  476.   mnuHelpAbout.Caption = ml_string(27)
  477.   mnuTools.Caption = ml_string(25)
  478.   mnuToolsChangeLanguage.Caption = ml_string(51)
  479.   mnuView.Caption = ml_string(22)
  480.   mnuViewStatusBar.Caption = ml_string(24)
  481.   mnuViewToolbar.Caption = ml_string(23)
  482.   sbStatusBar.Panels(1).Text = ml_string(8)
  483.   tbToolBar.Buttons(1).ToolTipText = ml_string(2)
  484.   tbToolBar.Buttons(2).ToolTipText = ml_string(3)
  485.   tbToolBar.Buttons(3).ToolTipText = ml_string(4)
  486.   tbToolBar.Buttons(5).ToolTipText = ml_string(5)
  487.   tbToolBar.Buttons(6).ToolTipText = ml_string(6)
  488.   tbToolBar.Buttons(7).ToolTipText = ml_string(7)
  489. End Sub
  490. Private Sub ml_RuntimeSupport_LanguageChanged(ByVal LanguageID As Long, ByVal Language As String)
  491.   ml_ChangeLanguage LanguageID, Language
  492.   ml_UpdateControls
  493. End Sub
  494.