当前位置: 源码素材网 » VB教程 » 详情页

VB实现鼠标滑过时显示状态栏提示(代码)

  •   时间:2019-07-02
  • 概述:状态栏 文字提示

在状态栏上显示鼠标操作提示,当鼠标滑过窗体的相关按钮时,状态栏中会显示相关的提示文字,基于VB6.0的代码,一个与状态栏相关的编程例子:

VB状态栏显示时间、定义字体等代码分享:

VERSION 5.00
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "COMCTL32.OCX"
Begin VB.Form frmStatusBar
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Status Bar Sample"
   ClientHeight    =   2295
   ClientLeft      =   2400
   ClientTop       =   3480
   ClientWidth     =   6120
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   2295
   ScaleWidth      =   6120
   Begin VB.CommandButton CmdBold
      Caption         =   "加粗"
      BeginProperty Font
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   4920
      TabIndex        =   5
      Top             =   600
      Width           =   1095
   End
   Begin VB.CommandButton CmdItalic
      Caption         =   "斜体"
      BeginProperty Font
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   4920
      TabIndex        =   4
      Top             =   1080
      Width           =   1095
   End
   Begin VB.CommandButton CmdExit
      Caption         =   "退出"
      BeginProperty Font
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   4920
      TabIndex        =   3
      Top             =   1560
      Width           =   1095
   End
   Begin VB.CommandButton CmdNew
      Caption         =   "重写"
      BeginProperty Font
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   4920
      TabIndex        =   2
      Top             =   120
      Width           =   1095
   End
   Begin VB.TextBox Text1
      BeginProperty Font
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1815
      Left            =   0
      TabIndex        =   1
      Top             =   120
      Width           =   4815
   End
   Begin ComctlLib.StatusBar staSample
      Align           =   2  'Align Bottom
      Height          =   270
      Left            =   0
      TabIndex        =   0
      Top             =   2025
      Width           =   6120
      _ExtentX        =   10795
      _ExtentY        =   476
      SimpleText      =   ""
      _Version        =   327682
      BeginProperty Panels {0713E89E-850A-101B-AFC0-4210102A8DA7}
         NumPanels       =   3
         BeginProperty Panel1 {0713E89F-850A-101B-AFC0-4210102A8DA7}
            Object.Width           =   5468
            MinWidth        =   5468
            Text            =   ""
            TextSave        =   ""
            Key             =   ""
            Object.Tag             =   ""
         EndProperty
         BeginProperty Panel2 {0713E89F-850A-101B-AFC0-4210102A8DA7}
            Style           =   6
            Alignment       =   2
            Text            =   ""
            TextSave        =   "2008-12-11"
            Key             =   ""
            Object.Tag             =   ""
         EndProperty
         BeginProperty Panel3 {0713E89F-850A-101B-AFC0-4210102A8DA7}
            Style           =   5
            Alignment       =   2
            Object.Width           =   2734
            MinWidth        =   2734
            Text            =   ""
            TextSave        =   "14:30"
            Key             =   ""
            Object.Tag             =   ""
         EndProperty
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
         Name            =   "宋体"
         Size            =   9.75
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
End
Attribute VB_Name = "frmStatusBar"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'--------------------------------------
'        一个使用StatusBar的例子
'--------------------------------------
'           QQ223857666勾月
'--------------------------------------
'------名称-------------作用------------
'      CmdItalic        “斜体”按钮
'      CmdBold          “粗体”按钮
'      CmdExit          “退出”按钮
'      CmdNew           “重写”按钮
'      Text1             文本框
'      frmStatusBar      主窗体
'      staSample         状态栏
'--------------------------------------
'Option Explicit
'当“斜体”按钮按下时
Private Sub CmdItalic_Click()
'将文本框中的字体设为斜体
Text1.FontItalic = True
End Sub
'当鼠标移动到“斜体”按钮上时
Private Sub CmdItalic_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'把状态栏的第一个Panels中的Text属性设为"转化为斜体"的帮助信息
staSample.Panels(1).Text = ""
staSample.Panels(1).Text = "转化为斜体"
End Sub
'当“粗体”按钮按下时
Private Sub CmdBold_Click()
'将文本框中的字体设为粗体
Text1.FontBold = True
End Sub
'当鼠标移动到“粗体”按钮上时
Private Sub CmdBold_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'把状态栏的第一个Panels中的Text属性设为"转化为粗体"的帮助信息
staSample.Panels(1).Text = ""
staSample.Panels(1).Text = "转化为粗体"
End Sub
'当“退出”按钮按下时
Private Sub CmdExit_Click()
'退出程序
Unload Me
End Sub
'当鼠标移动到“退出”按钮上时
Private Sub CmdExit_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'把状态栏的第一个Panels中的Text属性设为"退出程序"的帮助信息
staSample.Panels(1).Text = ""
staSample.Panels(1).Text = "退出程序"
End Sub
'当“重写”按钮按下时
Private Sub CmdNew_Click()
'将文本框中的文本清空
Text1.Text = ""
Text1.FontBold = False
Text1.FontItalic = False
End Sub
'当鼠标移动到“重写”按钮上时
Private Sub CmdNew_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'把状态栏的第一个Panels中的Text属性设为"清空文本框"的帮助信息
staSample.Panels(1).Text = ""
staSample.Panels(1).Text = "清空文本框"
End Sub
Private Sub edit_Click()
frmProperties.Show vbModal
End Sub
'当鼠标移动到文本框上时
Private Sub Text1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'把状态栏的第一个Panels中的Text属性设为"输入文字"的帮助信息
staSample.Panels(1).Text = ""
staSample.Panels(1).Text = "输入文字"
End Sub

完整的VB源码包,可参考这里:VB状态栏显示时间、定义字体等

    相关声明:

      若“VB实现鼠标滑过时显示状态栏提示(代码)”有损您的权益,请告之我们删除内容。
      部分文章来源于网络,版权归原作者所有。