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

📄 form1.frm

📁 LED显示屏控制卡的编程例程
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "显示屏VB样例程序"
   ClientHeight    =   2475
   ClientLeft      =   1140
   ClientTop       =   1275
   ClientWidth     =   4530
   LinkTopic       =   "Form1"
   ScaleHeight     =   2475
   ScaleWidth      =   4530
   Begin VB.CommandButton Command6 
      Caption         =   "电源状态"
      Height          =   435
      Left            =   2760
      TabIndex        =   6
      Top             =   1920
      Width           =   1095
   End
   Begin VB.CommandButton Command5 
      Caption         =   "发送数据"
      Height          =   435
      Left            =   2760
      TabIndex        =   5
      Top             =   1440
      Width           =   1095
   End
   Begin VB.CommandButton Command4 
      Caption         =   "关闭电源"
      Height          =   435
      Left            =   1560
      TabIndex        =   4
      Top             =   1920
      Width           =   1095
   End
   Begin VB.CommandButton Command3 
      Caption         =   "打开电源"
      Height          =   435
      Left            =   360
      TabIndex        =   3
      Top             =   1920
      Width           =   1095
   End
   Begin VB.Timer Timer1 
      Enabled         =   0   'False
      Interval        =   1000
      Left            =   3120
      Top             =   240
   End
   Begin VB.CommandButton Command2 
      Caption         =   "查询"
      Height          =   435
      Left            =   1560
      TabIndex        =   2
      Top             =   1440
      Width           =   1095
   End
   Begin VB.PictureBox Picture1 
      AutoSize        =   -1  'True
      BorderStyle     =   0  'None
      FillStyle       =   0  'Solid
      Height          =   960
      Left            =   1200
      Picture         =   "Form1.frx":0000
      ScaleHeight     =   64
      ScaleMode       =   3  'Pixel
      ScaleWidth      =   128
      TabIndex        =   1
      Top             =   240
      Width           =   1920
   End
   Begin VB.CommandButton Command1 
      Caption         =   "打开串口"
      Height          =   435
      Left            =   360
      TabIndex        =   0
      Top             =   1440
      Width           =   1095
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Const Address = 0
Const ComPort = 4   '用COM4作为通讯端口

Dim dev As Long

Private Sub Command1_Click()
  Dim param As TDeviceParam
  
  
'下面是串口传输方式代码
  param.devType = DEVICE_TYPE_COM
  param.ComPort = 5
  param.speed = SBR_115200
  param.FlowCon = 0
  
  
'下面是网络传输方式代码
 'Param.devType = DEV_UDP
 'Param.locPort = 8888   '本地端口号可任意指定,一般来说80为HTTP,23为FTP等等,指定大于1024的基本没有问题
 'Param.rmtPort = 6666   '远程端口必须为6666

  dev = LED_Open(param, 1, Me.hWnd, WM_LED_NOTIFY)
  If dev = -1 Then
    MsgBox ("无法打开指定端口")
  Else
    Form1.Caption = "打开串口成功"
  End If
End Sub

Private Sub Command2_Click()
  LED_Query dev, Address, "192.168.0.99", 6666
End Sub

Private Sub Command3_Click()
  LED_SetPower dev, Address, "192.168.0.99", 6666, LED_POWER_ON
End Sub

Private Sub Command4_Click()
  LED_SetPower dev, Address, "192.168.0.99", 6666, LED_POWER_OFF
End Sub

Private Sub Command5_Click()
  Dim ARect As rect
  
  Timer1.Enabled = False
  MakeRoot ROOT_PLAY, SCREEN_COLOR    '形成发送数据
  AddLeaf 1000                           '追加一个页面
  SetRect ARect, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight
  AddWindow Picture1.hDC, Picture1.ScaleWidth, ScaleHeight, ARect, 1, 1, 1  '发送一幅图片
  Me.Caption = "正在发送数据..."
  LED_SendToScreen dev, 0, "192.168.0.99", 6666
End Sub

Private Sub Command6_Click()
  LED_GetPower dev, Address, "192.168.0.99", 6666
End Sub

Private Sub Form_Load()
  Hook Me.hWnd
  'LED_Startup
End Sub

Private Sub Form_unLoad(Cancel As Integer)
  LED_Close dev
  UnHook Me.hWnd
End Sub

⌨️ 快捷键说明

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