home *** CD-ROM | disk | FTP | other *** search
Wrap
Declare Function WritePrivateProfileString Lib "Kernel" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lplFileName As String) As Integer Declare Function GetPrivateProfileString Lib "Kernel" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Integer, ByVal lpFileName As String) As Integer Declare Function GetPrivateProfileInt Lib "Kernel" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal nDefault As Integer, ByVal lpFileName As String) As Integer Function GetFilename (Prompt As String, Default As String) CenterForm frmMDI, ConnectDlg ConnectDlg.Caption = Prompt ConnectDlg.Text1 = Default ConnectDlg.Text1.SelStart = 0 ConnectDlg.Text1.SelLength = Len(ConnectDlg.Text1) 'ConnectDlg.Text1.SetFocus ConnectDlg.Show Modal GetFilename = ConnectDlg.Text1 End Function Sub LoadConfig (SessionName As String) ' query user for configuration name Dim Tmp As String * 80 If (SessionName <> "") Then FIndex = FindFreeIndex() FState(FIndex).Session = SessionName Document(FIndex).Tag = FIndex Document(FIndex).WindowState = 0 Document(FIndex).Caption = SessionName & " - loading..." Document(FIndex).VT1.BackColor = GetPrivateProfileInt(SessionName, "BackColor", frmMDI.ActiveForm.VT1.BackColor, IniFile) Document(FIndex).VT1.BoldColor = GetPrivateProfileInt(SessionName, "BoldColor", frmMDI.ActiveForm.VT1.BoldColor, IniFile) Document(FIndex).VT1.CharSet = GetPrivateProfileInt(SessionName, "CharSet", frmMDI.ActiveForm.VT1.CharSet, IniFile) Document(FIndex).VT1.Columns = GetPrivateProfileInt(SessionName, "Columns", frmMDI.ActiveForm.VT1.Columns, IniFile) Document(FIndex).VT1.CursorKeys = GetPrivateProfileInt(SessionName, "CursorKeys", frmMDI.ActiveForm.VT1.CursorKeys, IniFile) Document(FIndex).VT1.EditKeys = GetPrivateProfileInt(SessionName, "EditKeys", frmMDI.ActiveForm.VT1.EditKeys, IniFile) Document(FIndex).VT1.Emulate = GetPrivateProfileInt(SessionName, "Emulate", frmMDI.ActiveForm.VT1.Emulate, IniFile) Document(FIndex).VT1.ForeColor = GetPrivateProfileInt(SessionName, "ForeColor", frmMDI.ActiveForm.VT1.ForeColor, IniFile) 'put into form load 'Document(FIndex).Left = GetPrivateProfileInt(SessionName, "Left", frmMDI.ActiveForm.Left, IniFile) 'Document(FIndex).Height = GetPrivateProfileInt(SessionName, "Height", frmMDI.ActiveForm.Height, IniFile) 'Document(FIndex).Top = GetPrivateProfileInt(SessionName, "Top", frmMDI.ActiveForm.Top, IniFile) 'Document(FIndex).Width = GetPrivateProfileInt(SessionName, "Width", frmMDI.ActiveForm.Width, IniFile) Document(FIndex).VT1.Keypad = GetPrivateProfileInt(SessionName, "Keypad", frmMDI.ActiveForm.VT1.Keypad, IniFile) Document(FIndex).VT1.LocalEcho = GetPrivateProfileInt(SessionName, "LocalEcho", frmMDI.ActiveForm.VT1.LocalEcho, IniFile) Document(FIndex).VT1.SevenBitControls = GetPrivateProfileInt(SessionName, "SevenBitControls", frmMDI.ActiveForm.VT1.SevenBitControls, IniFile) suc = GetPrivateProfileString(SessionName, "UsernamePrompt", "ogin:", Tmp, 80, IniFile) Document(FIndex).VT1.UsernamePrompt = Tmp suc = GetPrivateProfileString(SessionName, "PasswordPrompt", "assword:", Tmp, 80, IniFile) Document(FIndex).VT1.PasswordPrompt = Tmp 'Document(FIndex).VT1.PrintMode = GetPrivateProfileInt(SessionName, "PrintMode", frmMDI.ActiveForm.VT1.PrintMode, IniFile) suc = GetPrivateProfileString(SessionName, "RemoteAddress", SessionName, Tmp, 80, IniFile) Document(FIndex).VT1.RemoteAddress = Tmp Document(FIndex).VT1.RemotePort = GetPrivateProfileInt(SessionName, "RemotePort", frmMDI.ActiveForm.VT1.RemotePort, IniFile) Document(FIndex).VT1.TermType = GetPrivateProfileInt(SessionName, "TermType", frmMDI.ActiveForm.VT1.TermType, IniFile) 'Com stuff suc = GetPrivateProfileString(SessionName, "CommSettings", frmMDI.ActiveForm.VT1.CommSettings, Tmp, 80, IniFile) Document(FIndex).VT1.CommSettings = Tmp Document(FIndex).VT1.FlowControl = GetPrivateProfileInt(SessionName, "FlowControl", frmMDI.ActiveForm.VT1.FlowControl, IniFile) Document(FIndex).VT1.Protocol = GetPrivateProfileInt(SessionName, "Protocol", frmMDI.ActiveForm.VT1.Protocol, IniFile) i = 0 Do While i < 256 suc = GetPrivateProfileString(SessionName, "KeyMap(" + Str$(i) + ")", frmMDI.ActiveForm.VT1.KeyMap(i), Tmp, 80, IniFile) If suc Then frmMDI.ActiveForm.VT1.KeyMap(i) = Tmp End If i = i + 1 Loop 'Else 'MsgBox "Session configuration not found...using defaults" End If ' set the Notepad's Session name Document(FIndex).Caption = SessionName & " - initialized" ' reset the dirty flag FState(FIndex).Dirty = False End Sub Sub SaveFileAs (SessionName As String) On Error Resume Next Dim Tmp As String ' save SessionName for next opening of a session suc = WritePrivateProfileString(AppName, "LastSessionName", SessionName, IniFile) Tmp = frmMDI.ActiveForm.VT1.RemoteAddress suc = WritePrivateProfileString(AppName, "LastRemoteAddress", Tmp, IniFile) ' save configuration suc = WritePrivateProfileString(SessionName, "BackColor", Str$(frmMDI.ActiveForm.VT1.BackColor), IniFile) suc = WritePrivateProfileString(SessionName, "BoldColor", Str$(frmMDI.ActiveForm.VT1.BoldColor), IniFile) suc = WritePrivateProfileString(SessionName, "CharSet", Str$(frmMDI.ActiveForm.VT1.CharSet), IniFile) suc = WritePrivateProfileString(SessionName, "Columns", Str$(frmMDI.ActiveForm.VT1.Columns), IniFile) suc = WritePrivateProfileString(SessionName, "CursorKeys", Str$(frmMDI.ActiveForm.VT1.CursorKeys), IniFile) suc = WritePrivateProfileString(SessionName, "EditKeys", Str$(frmMDI.ActiveForm.VT1.EditKeys), IniFile) suc = WritePrivateProfileString(SessionName, "Emulate", Str$(frmMDI.ActiveForm.VT1.Emulate), IniFile) suc = WritePrivateProfileString(SessionName, "ForeColor", Str$(frmMDI.ActiveForm.VT1.ForeColor), IniFile) suc = WritePrivateProfileString(SessionName, "Height", Str$(frmMDI.ActiveForm.Height), IniFile) suc = WritePrivateProfileString(SessionName, "Keypad", Str$(frmMDI.ActiveForm.VT1.Keypad), IniFile) suc = WritePrivateProfileString(SessionName, "Left", Str$(frmMDI.ActiveForm.Left), IniFile) suc = WritePrivateProfileString(SessionName, "LocalEcho", Str$(frmMDI.ActiveForm.VT1.LocalEcho), IniFile) suc = WritePrivateProfileString(SessionName, "SevenBitControls", Str$(frmMDI.ActiveForm.VT1.SevenBitControls), IniFile) Tmp = frmMDI.ActiveForm.VT1.UsernamePrompt suc = WritePrivateProfileString(SessionName, "UsernamePrompt", Tmp, IniFile) Tmp = frmMDI.ActiveForm.VT1.PasswordPrompt suc = WritePrivateProfileString(SessionName, "PasswordPrompt", Tmp, IniFile) 'suc = WritePrivateProfileString(SessionName, "PrintMode", Str$(frmMDI.ActiveForm.VT1.PrintMode), IniFile) Tmp = frmMDI.ActiveForm.VT1.RemoteAddress If (Tmp = "") Then Tmp = SessionName End If suc = WritePrivateProfileString(SessionName, "RemoteAddress", Tmp, IniFile) suc = WritePrivateProfileString(SessionName, "RemotePort", Str$(frmMDI.ActiveForm.VT1.RemotePort), IniFile) suc = WritePrivateProfileString(SessionName, "TermType", Str$(frmMDI.ActiveForm.VT1.TermType), IniFile) suc = WritePrivateProfileString(SessionName, "Top", Str$(frmMDI.ActiveForm.Top), IniFile) suc = WritePrivateProfileString(SessionName, "Width", Str$(frmMDI.ActiveForm.Width), IniFile) 'Com stuff Tmp = frmMDI.ActiveForm.VT1.CommSettings suc = WritePrivateProfileString(SessionName, "CommSettings", Tmp, IniFile) suc = WritePrivateProfileString(SessionName, "FlowControl", Str$(frmMDI.ActiveForm.VT1.FlowControl), IniFile) suc = WritePrivateProfileString(SessionName, "Protocol", Str$(frmMDI.ActiveForm.VT1.Protocol), IniFile) i = 0 Do While i < 256 If frmMDI.ActiveForm.VT1.KeyMap(i) <> "" Then Tmp = frmMDI.ActiveForm.VT1.KeyMap(i) suc = WritePrivateProfileString(SessionName, "KeyMap(" + Str$(i) + ")", Tmp, IniFile) End If i = i + 1 Loop ' set the Notepad's caption FState(frmMDI.ActiveForm.Tag).Session = SessionName frmMDI.ActiveForm.Caption = SessionName & " - saved" ' reset the dirty flag FState(frmMDI.ActiveForm.Tag).Dirty = False End Sub