📄 frmmain.frm
字号:
VERSION 5.00
Begin VB.Form frmMain
BackColor = &H00A0D0D0&
Caption = "LineWatcher"
ClientHeight = 2955
ClientLeft = 60
ClientTop = 630
ClientWidth = 5625
ForeColor = &H00000000&
Icon = "frmMain.frx":0000
LinkTopic = "Form1"
ScaleHeight = 2955
ScaleWidth = 5625
StartUpPosition = 2 'CenterScreen
Begin VB.ComboBox cboConnections
Height = 315
Left = 1035
Sorted = -1 'True
Style = 2 'Dropdown List
TabIndex = 1
Top = 90
Width = 3255
End
Begin VB.TextBox txtLog
ForeColor = &H000000FF&
Height = 975
Left = 45
Locked = -1 'True
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 6
Top = 945
Width = 5520
End
Begin VB.CommandButton cmdExit
BackColor = &H00C0D0D0&
Caption = "E&xit"
Height = 420
Left = 4365
Style = 1 'Graphical
TabIndex = 2
Top = 45
Width = 1185
End
Begin VB.Timer Timer1
Enabled = 0 'False
Interval = 10000
Left = 2475
Top = 2025
End
Begin VB.TextBox txtStatus
ForeColor = &H80000007&
Height = 975
Left = 45
Locked = -1 'True
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 4
Top = 1935
Width = 5520
End
Begin VB.CommandButton cmdAction
BackColor = &H0080FFFF&
Caption = "?"
Height = 405
Left = 4365
Style = 1 'Graphical
TabIndex = 3
Top = 495
Width = 1200
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "Status:"
Height = 285
Index = 1
Left = 0
TabIndex = 7
Top = 585
Width = 915
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "&Connect to:"
Height = 285
Index = 0
Left = 0
TabIndex = 0
Top = 135
Width = 915
End
Begin VB.Label lblStatus
BackColor = &H00FFFFFF&
BorderStyle = 1 'Fixed Single
Height = 285
Left = 1035
TabIndex = 5
Top = 540
Width = 3255
End
Begin VB.Menu mnuFile
Caption = "&File"
Begin VB.Menu mnuFilePref
Caption = "&Preferences..."
End
Begin VB.Menu mnuFileExit
Caption = "E&xit"
End
End
Begin VB.Menu mnuHelp
Caption = "&Help"
Begin VB.Menu mnuHelpAbout
Caption = "&About "
End
End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' RICHARD GOUTORBE ( rghome@reseau.org http://www.reseau.org/rg/ ) holds the copyright to all code in this document.
' You are granted a license to use this code under the following conditions:
' - You are free to modify the code in any way you see fit.
' - You are free to redistribute the code FOR NON-PROFIT PURPOSE provided that
' 1) appropriate credit is given to Richard Goutorbe, and
' 2) you do not charge any kind of fee for the code without the written permission of Richard Goutorbe.
' You are free to redistibute a binary compiled version of the code for any purpose, profit or non-profit.
' If you distribute the code in this form, you must give appropriate credit to Richard Goutorbe.
' PUBLISHING THE CODE ON OTHER WEB SITES, OR POSTING THE CODE ON OTHER WEB SITES FOR PUBLICATION WITHOUT THE WRITTEN PERMISSION OF RICHARD GOUTORBE, IS STRICTLY PROHIBITED.
Option Explicit
Private mInet_obj As CNetConn
Private mInitialized_bool As Boolean
Private mPref_obj As CPref
Private mChildForms_bool(1) As Boolean ' 0=frmAbout loaded, 1=frmPref
Private Enum CONN_STATUS
STATUS_UNDEF = 0
STATUS_OFFLINE = 1
STATUS_ONLINE = 2
STATUS_BUSY = 3
End Enum
Private Sub Form_Initialize()
Set mInet_obj = New CNetConn
Set mPref_obj = New CPref
mInitialized_bool = False
End Sub
Private Sub Form_Load()
Me.Caption = App.Title & " v" & App.Major & "." & App.Minor & "." & App.Revision
ConnectionStatus = STATUS_UNDEF
mPref_obj.LoadPref
WriteLog App.Title & " version " & App.Major & "." & App.Minor & "." & App.Revision & " Begin", vbLogEventTypeWarning
If (Len(mPref_obj.RASConnection) = 0) Then
MsgBox "Installation notes:" & vbCrLf _
& "1) Open the Internet Options tool in Window's control pannel," & vbCrLf _
& " select the 'Connections' tab, and click 'Never dial a connection'" & vbCrLf _
& " to allow LineWatcher to dial your ISP when your connection gets dropped." & vbCrLf _
& "2) Click the Ok button below and select your default remote access service" & vbCrLf _
& " in the 'connect to' drop-down list" & vbCrLf _
& "3) Restart this program." _
, vbInformation, App.Title
mnuFilePref_Click
Unload Me
Else
If (mPref_obj.AutoConnectDelay > 0) Then
Timer1.Enabled = True
Timer1.Interval = mPref_obj.AutoConnectDelay * 1000
Else
Timer1.Enabled = False
End If
With mInet_obj
.PingEnabled = (Len(mPref_obj.PingHost) > 0) ' disable ping if no ping host defined
If (.PingEnabled) Then
.PingHostName = mPref_obj.PingHost
WriteTrace "(ping " & .PingHostName & " every " & mPref_obj.PingDelay & " s)"
Else
WriteTrace "(ping is disabled)"
End If
End With
'get list of DUNS on the system and select active one
Load_ListRas cboConnections
End If
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If (UnloadMode = vbFormControlMenu Or UnloadMode = vbFormCode) Then
If (ConnectionStatus = STATUS_BUSY) Then
Dim answer As VbMsgBoxResult
answer = MsgBox("Warning: network operation in progress" & vbCrLf _
& "Your system may become instable if you quit now" & vbCrLf _
& "Do you really want to exit ?" _
, vbQuestion + vbYesNo, App.Title)
If (answer = vbNo) Then
Cancel = 1
End If
End If
End If
End Sub
Private Sub Form_Paint()
If (Not mInitialized_bool) Then
' first paint only
Dim connected_bool As Boolean
WriteTrace "Checking connection status..."
ConnectionStatus = STATUS_BUSY ' operation in progress...
connected_bool = mInet_obj.IsConnected()
ConnectionStatus = IIf(connected_bool, STATUS_ONLINE, STATUS_OFFLINE)
If (connected_bool) Then
WriteTrace "(already online)"
Else
WriteTrace "Offline"
If (mPref_obj.AutoConnectDelay > 0) Then
WriteTrace "Autoconnection in " & mPref_obj.AutoConnectDelay & " s"
Else
WriteTrace "Autoconnection is off; click Connect button."
End If
End If
'Timer1.Enabled = True ' timer will try to connect if we are offline
mInitialized_bool = True
End If
End Sub
Private Sub Form_Terminate()
Set mInet_obj = Nothing
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -