📄 frmmain.frm
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form frmMain
Caption = "OPC DA Client by VB(by lzy)"
ClientHeight = 7545
ClientLeft = 165
ClientTop = 450
ClientWidth = 9915
Icon = "frmMain.frx":0000
LinkTopic = "Form1"
ScaleHeight = 7545
ScaleWidth = 9915
StartUpPosition = 2 '屏幕中心
Begin VB.ListBox lstProcess
Height = 1860
Left = 0
TabIndex = 2
Top = 5400
Width = 9735
End
Begin MSComctlLib.ListView lvListView
Height = 2055
Left = 120
TabIndex = 1
Top = 360
Width = 1455
_ExtentX = 2566
_ExtentY = 3625
View = 3
LabelEdit = 1
LabelWrap = -1 'True
HideSelection = -1 'True
FullRowSelect = -1 'True
HotTracking = -1 'True
_Version = 393217
ForeColor = -2147483640
BackColor = -2147483643
BorderStyle = 1
Appearance = 1
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
NumItems = 5
BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628}
Text = "Name"
Object.Width = 3881
EndProperty
BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 1
Text = "Value"
Object.Width = 3351
EndProperty
BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 2
Text = "Quality"
Object.Width = 3351
EndProperty
BeginProperty ColumnHeader(4) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 3
Text = "TimeStamp"
Object.Width = 3351
EndProperty
BeginProperty ColumnHeader(5) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 4
Object.Width = 2540
EndProperty
End
Begin MSComctlLib.StatusBar sbStatusBar
Align = 2 'Align Bottom
Height = 270
Left = 0
TabIndex = 0
Top = 7275
Width = 9915
_ExtentX = 17489
_ExtentY = 476
_Version = 393216
BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628}
NumPanels = 3
BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628}
AutoSize = 1
Object.Width = 11853
Text = "Status"
TextSave = "Status"
EndProperty
BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628}
Style = 6
AutoSize = 2
TextSave = "2007-8-18"
EndProperty
BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628}
Style = 5
AutoSize = 2
TextSave = "15:37"
EndProperty
EndProperty
End
Begin MSComDlg.CommonDialog dlgCommonDialog
Left = 1740
Top = 1320
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.Menu mnuFile
Caption = "&File"
Begin VB.Menu menuOpen
Caption = "Open..."
End
Begin VB.Menu menuSaveAs
Caption = "SaveAs..."
Enabled = 0 'False
End
Begin VB.Menu menuSetup
Caption = "Setup..."
End
Begin VB.Menu mnuExit
Caption = "Exit"
End
End
Begin VB.Menu mnuOpc
Caption = "&OPC"
Begin VB.Menu mnuConnect
Caption = "&Connect"
End
Begin VB.Menu mnuDisconnect
Caption = "&Disconnect"
Enabled = 0 'False
End
Begin VB.Menu mnuServerStatus
Caption = "Server Status"
Enabled = 0 'False
End
Begin VB.Menu mnuSplit2
Caption = "-"
End
Begin VB.Menu mnuGroupStatus
Caption = "Group Stat"
Enabled = 0 'False
End
Begin VB.Menu mnuGroupRefresh
Caption = "Refresh Data"
Enabled = 0 'False
End
Begin VB.Menu mnuSplit
Caption = "-"
End
Begin VB.Menu mnuAddItem
Caption = "&Add Item"
Enabled = 0 'False
End
Begin VB.Menu mnuRemoveItem
Caption = "&Remove Item"
Enabled = 0 'False
End
Begin VB.Menu mnuReadItem
Caption = "R&ead Item"
Enabled = 0 'False
End
Begin VB.Menu mnuWriteItem
Caption = "&Write Item"
Enabled = 0 'False
End
Begin VB.Menu mnuItemStatus
Caption = "Item Properties"
Enabled = 0 'False
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
Option Explicit
Dim ComputerName As String, ServerClassID As String
Public Sub Disconnect()
On Error GoTo out1
ItemIndex = 0
If ServerHandle = 0 Then Exit Sub
If GroupHandle > 0 Then
lvListView.ListItems.Clear
Dim ret As Boolean
ret = OPC_RemoveGroup(ServerHandle, GroupHandle)
GroupHandle = 0
' OPC_RemoveGroup ServerHandle, GroupHandle
End If
If OPC_Disconnect(ServerHandle) Then
ServerHandle = 0
GroupHandle = 0
mnuConnect.Enabled = True
mnuDisconnect.Enabled = False
mnuServerStatus.Enabled = False
mnuGroupStatus.Enabled = False
mnuGroupRefresh.Enabled = False
mnuAddItem.Enabled = False
mnuAddItem.Enabled = False
mnuRemoveItem.Enabled = False
mnuReadItem.Enabled = False
mnuWriteItem.Enabled = False
mnuItemStatus.Enabled = False
End If
Exit Sub
out1:
MsgBox Err.Description
End Sub
Private Sub Form_Load()
ServerHandle = 0
GroupHandle = 0
ItemIndex = 0
GroupName = "GROUP1"
'序列号用户使用
'AS_ActiveCode "", ""
Call OPC_Init
OPC_SetProcessTiggerProc AddressOf AddProcess
End Sub
Private Sub Form_Unload(Cancel As Integer)
If ServerHandle > -1 Then
OPC_Disconnect ServerHandle
End If
OPC_Uninit
End Sub
Private Sub Form_Resize()
On Error Resume Next
If Me.Width < 3000 Then Me.Width = 3000
lvListView.Top = 0
lvListView.Left = 10
lvListView.Width = Me.Width - 120
lvListView.Height = Me.ScaleHeight - sbStatusBar.Height - lstProcess.Height
lstProcess.Top = lvListView.Height + 20
lstProcess.Width = lvListView.Width
End Sub
Private Sub lvListView_ItemClick(ByVal Item As MSComctlLib.listItem)
If lvListView.SelectedItem Is Nothing Then Exit Sub
mnuReadItem.Enabled = True
mnuWriteItem.Enabled = True
mnuItemStatus.Enabled = True
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -