⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1

📁 用VB编写的接收卫星接收机的是数据
💻
📖 第 1 页 / 共 3 页
字号:
      End
      Begin VB.Menu mitemReloadFirmware 
         Caption         =   "重新加载代码到芯片(&L)"
         Enabled         =   0   'False
      End
      Begin VB.Menu mitemReloadOther 
         Caption         =   "加载其他代码(&R)..."
         Enabled         =   0   'False
      End
   End
   Begin VB.Menu menuHelp 
      Caption         =   "帮助(&H)"
      Begin VB.Menu mitemAbout 
         Caption         =   "关于(&A)..."
      End
   End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public ezlibObj As New EZlib1        ' EZlib Object that controls the Hardware
Public ezLngDataAddr As Long         ' Data buffer's Address
Public fmBdrObj As New FileMapPro    ' MapX file Save and Paint Object
Public ezLngDogFood As Long          ' Gate Dog's Food Variable

Public ezTransCtrl As New TransCtrl  ' EZlib 's iso Transfer Control Struct
Public ezCurEdIndex As Long  ' index of Endpoint to Transfer datas
Public ezCurIfIndex As Long  ' index of Data Transfer Endpoint's Parent Interface

Public strDatafilePath As String          ' File to Save datas
Public strFirmwarePath As String          ' Firmware to Setup the Device
Public blIsTransCtrlSet As Boolean        ' Marked weather TransferCtrl Struct was Filled
Public ezlngTotalRead As Long             ' Total Packeages Count





Private Sub Form_load()
' Make Only Instance Run
'Call procInstanceStart(Me.Caption)
'-----------------------------------------
blIsTransCtrlSet = False
timerStateCtrl.Interval = 200

' 0.Regist Components
If procRegistCOMs = 1 Then
  MsgBox "组件注册失败,无法注册以下模块:" + vbCrLf + vbCrLf + _
         "1.开发板控制组件     EZlib.dll" + vbCrLf + _
         "2.帧解码与绘图组件 FileMapBuilder.dll" + vbCrLf + vbCrLf + _
         "可能是在程序所在目录找不到上述两个文件" + vbCrLf + _
         "或组件无法正确注册"
  regBlRegistFailed = True
  Unload frmMain
  End
End If

' 1.Create Table Fields
Call procInitMsInfo

' 2.Load Options from file
If procLoadOptions = 1 Then MsgBox "读取配置信息失败,程序将使用默认的配置信息"

'// debug
Call procOptionsDebug
Load frmOption
'Load frmDeviceSetup
Call procOpenDevice
Call procTransferSetup

Load frmParamSetup
frmParamSetup.Hide
frmMain.Toolbar1.Buttons("StartTransfer").Enabled = True
'frmParamSetup.Show vbModal, frmMain
'Call procStart
End Sub

'Private Sub Command1_Click()
'End Sub

Private Sub cmdFile_Click()

g_blBtnClicked = True

cmmdlgFirmware.Filter = "*.* (数据文件)|*.*"
cmmdlgFirmware.FileName = ""
cmmdlgFirmware.ShowSave

If Len(Trim(cmmdlgFirmware.FileName)) <> 0 Then
   txtFile.Text = Trim(cmmdlgFirmware.FileName)
End If

txtFile.SetFocus
End Sub
Private Sub Form_Resize()
frameRight.Width = Abs(Me.ScaleWidth - frameRight.Left - 50)
frameRight.Height = Abs(Me.ScaleHeight - Toolbar1.Height - statusBar.Height)
frameLeft.Height = frameRight.Height
splitter.Height = frameLeft.Height

msfInfo.Height = Abs(frameLeft.Height - msfInfo.Top - toolBarTransfer.Height - 1000)
If msfInfo.Height > 6000 Then msfInfo.Height = 6000
Call SetParent(picEdit.hwnd, Me.hwnd)
picEdit.Visible = False

toolBarTransfer.Top = msfInfo.Top + msfInfo.Height

picBanner.Left = Me.ScaleWidth - picBanner.Width - picBanner.Width / 2
If picBanner.Left < 2500 Then picBanner.Left = 2500

picNiceBanner.Height = Toolbar1.Height
picNiceBanner.Left = Me.Width - picNiceBanner.Width
lblCurEdpoint.Top = Abs(picNiceBanner.Height - lblCurEdpoint.Height) / 2
End Sub

Private Sub Form_Unload(Cancel As Integer)
Dim result As VbMsgBoxResult

'// if Component was registed Successfully in frmMain.Load Event then
If regBlRegistFailed = False Then

    result = MsgBox("是否决定关闭设备并退出该应用", vbYesNo)

    If result = vbNo Then
         Cancel = 1
         Exit Sub
    End If

    ' 1. Stop Transfer if It's Processing
    If Toolbar1.Buttons("StopTransfer").Enabled = True Then
    ' if transfer not stopped then stop it
       Call procStop
    End If

    ' 2. Close Device
    If Len(Trim(ezlibObj.CurrentDeviceName)) <> 0 Then
        ezlibObj.CloseDevice
    End If

    ' 3.Stop State Control Timer
    timerStateCtrl.Interval = 0

End If ' // End if Component was registed Successfully in frmMain.Load Event

    ' 4.Unregist COM Dlls
    Call procUnregistCOMS

    ' Make Only One Instance Run
    'Call procInstanceEnd

End
End Sub



Private Sub mitemAbout_Click()
frmAbout.Show vbModal, frmMain
End Sub

Private Sub mitemOpenDevice_Click()
 Call procOpenDevice
End Sub

Private Sub mitemOption_Click()
If g_blWorking <> True Then

  g_blWorking = True
  Load frmOption
  g_blWorking = False
  
  frmOption.Show vbModal, frmMain

End If
End Sub

Private Sub mitemQuit_Click()
Unload Me
End Sub

' Reload Firmware if it was specified
Private Sub mitemReloadFirmware_Click()
If g_blWorking <> True Then
  g_blWorking = True
  
If procDownload(Me.strFirmwarePath) <> 0 Then
   MsgBox "重新加载固件代码并配置设备失败" + vbCrLf + vbCrLf + _
          "可能的原因是:" + vbCrLf + _
          "1. 当前打开的设备在执行该操作时掉线" + vbCrLf + _
          "2. 芯片在执行该操作时正在运行" + vbCrLf + _
          "3. 加载代码到缓存失败" + vbCrLf + vbCrLf + _
          "为了安全起见操作状态将回到设备打开以前"
   
   ezlibObj.CloseDevice
End If

  g_blWorking = False
End If
End Sub
' Reload Firmware from File
Private Sub mitemReloadOther_Click()
If g_blWorking <> True Then
  g_blWorking = True

cmmdlgFirmware.Filter = "*.hex (十六进制8051固件代码)|*.hex"
cmmdlgFirmware.FileName = ""
cmmdlgFirmware.ShowOpen
If Len(Trim(cmmdlgFirmware.FileName)) <> 0 Then
  Me.strFirmwarePath = Trim(cmmdlgFirmware.FileName)

  If procDownload(Me.strFirmwarePath) <> 0 Then
   MsgBox "重新加载固件代码并配置设备失败" + vbCrLf + vbCrLf + _
          "可能的原因是:" + vbCrLf + _
          "1. 当前打开的设备在执行该操作时掉线" + vbCrLf + _
          "2. 芯片在执行该操作时正在运行" + vbCrLf + _
          "3. 加载代码到缓存失败" + vbCrLf + vbCrLf + _
          "为了安全起见操作状态将回到设备打开以前"
   
   ezlibObj.CloseDevice
  End If
End If
  
  g_blWorking = False '// end if g_blWorking <> True Then
End If
End Sub

Private Sub mitemSelectEndpoint_Click()
Call procTransferSetup
End Sub

Private Sub mitemStartTransfer_Click()
Call procStart
End Sub

Private Sub mitemStopTransfer_Click()
Call procStop
End Sub

Private Sub mitemTopMost_Click()



End Sub

Private Sub msfInfo_Click()
' Show txtEdit
If Len(Trim(ezlibObj.CurrentDeviceName)) <> 0 And _
   Toolbar1.Buttons("StopTransfer").Enabled = False And _
   (blIsTransCtrlSet = True _
    Or toolBarTransfer.Buttons("applySettings").Enabled = True) Then
   
 If msfInfo.Col = 1 And _
   msfInfo.Row >= 3 And msfInfo.Row <= 6 Then
   
   Call SetParent(txtEdit.hwnd, msfInfo.hwnd)
   txtEdit.Left = msfInfo.CellLeft - 20
   txtEdit.Top = msfInfo.CellTop - 40
   txtEdit.FontSize = 8
   txtEdit.Height = msfInfo.CellHeight
   txtEdit.Width = msfInfo.CellWidth
   txtEdit.Visible = True
   txtEdit.SetFocus
   txtEdit.Text = msfInfo.Text
   txtEdit.SelStart = 0
   txtEdit.SelLength = Len(txtEdit.Text)
 End If
 
 ' Show picEdit
 If (msfInfo.Col = 0 Or msfInfo.Col = 1) And _
    msfInfo.Row = 24 Then
    Call SetParent(picEdit.hwnd, msfInfo.hwnd)
    picEdit.Left = msfInfo.CellLeft - 20
    picEdit.Top = msfInfo.CellTop - 40
    txtFile.FontSize = 9
    picEdit.Height = msfInfo.CellHeight + 30
    picEdit.Width = msfInfo.CellWidth
    
    picEdit.Visible = True
    txtFile.SetFocus
    txtFile.Text = msfInfo.Text
 End If
 
End If
End Sub

Private Sub msfInfo_GotFocus()
msfInfo.AllowUserResizing = flexResizeColumns
msfInfo.ColWidth(0) = (msfInfo.Width - 300) / 2 ' 300 is width of Scroll Bar
msfInfo.ColWidth(1) = Abs((msfInfo.Width - 300) - msfInfo.ColWidth(0))
splitter.Top = 360
msfInfo.AllowUserResizing = flexResizeNone
End Sub

'Private Sub msfInfo_Scroll()
  'Call SetParent(txtEdit.hwnd, Me.hwnd)
  'Call SetParent(picEdit.hwnd, Me.hwnd)
  
  'txtEdit.Visible = False
  'picEdit.Visible = False
  
  'msfInfo.Refresh
'End Sub

Private Sub picEdit_Resize()
cmdFile.Height = picEdit.Height
cmdFile.Width = picEdit.Height

txtFile.Height = picEdit.Height
txtFile.Width = picEdit.Width - cmdFile.Width

cmdFile.Top = 0
txtFile.Top = 0

txtFile.Left = 0
cmdFile.Left = txtFile.Width
End Sub

Private Sub splitter_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim Res As Long
splitter.BackColor = vbBlack
DoEvents
ReleaseCapture
On Error Resume Next
Res = SendMessage(splitter.hwnd, WM_SYSCOMMAND, 61458, 0)
splitter.BackColor = &HC0C0C0
If splitter.Left > 9180 Then splitter.Left = 9000
If splitter.Left < 1675 Then splitter.Left = 1700


frameLeft.Width = splitter.Left - 100
toolBarTransfer.Left = splitter.Left - toolBarTransfer.Width - 100

frameRight.Width = Me.ScaleWidth - (splitter.Left + 90 + splitter.Width)
frameRight.Left = splitter.Left + 100

msfInfo.Width = frameLeft.Width - msfInfo.Left
msfInfo.AllowUserResizing = flexResizeColumns
msfInfo.ColWidth(0) = (msfInfo.Width - 300) / 2 ' 300 is width of Scroll Bar
msfInfo.ColWidth(1) = Abs((msfInfo.Width - 300) - msfInfo.ColWidth(0))
splitter.Top = 360
msfInfo.AllowUserResizing = flexResizeNone

End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -