下载频道> 资源分类> 编程语言> VB源码> 实现可以用鼠标切分的窗体VB源码程序

标题:实现可以用鼠标切分的窗体VB源码程序
分享到:

所属分类: VB源码 资源类型: 文件大小: 3.44 KB 上传时间: 2016-01-20 23:23:38 下载次数: 8 资源积分:1分 提 供 者: vb源码代做 20160120112321230
内容:
实现可以用鼠标切分的窗体VB源码程序,程序员在编程的过程中可以参考学习使用,希望对IT程序员有用,此源码程序简单易懂、方便阅读,有很好的学习价值!
部分代码如下:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "实现可以用鼠标切分的窗体"
   ClientHeight    =   4140
   ClientLeft      =   1140
   ClientTop       =   1515
   ClientWidth     =   5670
   LinkTopic       =   "Form1"
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   4140
   ScaleWidth      =   5670
   Begin VB.PictureBox Splitter 
      Height          =   2895
      Left            =   2400
      MousePointer    =   9  'Size W E
      ScaleHeight     =   2835
      ScaleWidth      =   435
      TabIndex        =   2
      Top             =   600
      Width           =   495
   End
   Begin VB.TextBox TextRight 
      Height          =   2925
      Left            =   3480
      MultiLine       =   -1  'True
      TabIndex        =   1
      Text            =   "Vsplit.frx":0000
      Top             =   600
      Width           =   1935
   End
   Begin VB.ListBox ListLeft 
      Height          =   2940
      Left            =   120
      TabIndex        =   0
      Top             =   600
      Width           =   1935
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
 
'variable to hold the width of the spltter bar
Private Const SPLT_WDTH As Integer = 3
 
'variable to hold the last-sized postion
Private currSplitPosX As Long
 
'variable to hold the horizontal and vertical offsets of the 2 controls
Dim CTRL_OFFSET As Integer
 
'variable to hold the Splitter bar colour
Dim SPLT_COLOUR As Long
Private Sub Form_Load()
'set the startup variables
 
CTRL_OFFSET = 5
SPLT_COLOUR = &H808080
 
'set the current splitter bar position to an arbitrary value that will always be outside
'the possibe range. This allows us to check for movement of the spltter bar in subsequent
'mousexxx subs.
 
currSplitPosX = &H7FFFFFFF
 
ListLeft.AddItem "列表项 1"
ListLeft.AddItem "列表项 2"
ListLeft.AddItem "列表项 3"
ListLeft.AddItem "列表项 4"
ListLeft.AddItem "列表项 5"
 
'note: VB3 users will need to substitute Chr$(13) & chr$(10) for the VB4 constant vbCrLf in the sentence below.
 
TextRight = "在一些流行的应用程序中,经常见到窗体上有二个相邻的列表框,可以用鼠标任意拉动中间分割条,改变列表框大小。"
 
End Sub
 
 
Private Sub Form_Resize()
 
Dim x1 As Integer
Dim x2 As Integer
Dim height1 As Integer
Dim width1 As Integer
Dim width2 As Integer
 
On Error Resume Next
 
'set the height of the controls
 
height1 = ScaleHeight - (CTRL_OFFSET * 2)
x1 = CTRL_OFFSET
width1 = ListLeft.Width
 
x2 = x1 + ListLeft.Width + SPLT_WDTH - 1
width2 = ScaleWidth - x2 - CTRL_OFFSET
 
'move the left list
ListLeft.Move x1% - 1, CTRL_OFFSET, width1, height1
 
'move the right list
TextRight.Move x2, CTRL_OFFSET, width2 + 1, height1
 
'move the splitter bar
Splitter.Move x1 + ListLeft.Width - 1, CTRL_OFFSET, SPLT_WDTH, height1
 
End Sub
 
Private Sub Splitter_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
 
If Button = vbLeftButton Then
    'change the splitter colour
    Splitter.BackColor = SPLT_COLOUR
    
    'set the current position to x
    currSplitPosX = CLng(X)
Else
    'not the left button, so... if the current position <> default, cause a mouseup
    If currSplitPosX <> &H7FFFFFFF Then Splitter_MouseUp Button, Shift, X, Y
    
    'set the current position to the default value
    currSplitPosX = &H7FFFFFFF
End If
 
End Sub
 
 
Private Sub Splitter_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
 
 
'if the splitter has been moved...
If currSplitPosX& <> &H7FFFFFFF Then
 
'if the current position <> default, reposition the splitter and set this as the current value
If CLng(X) <> currSplitPosX Then
Splitter.Move Splitter.Left + X, CTRL_OFFSET, SPLT_WDTH, ScaleHeight - (CTRL_OFFSET * 2)
currSplitPosX = CLng(X)
 
End If
 
End If
 
End Sub
 
 
Private Sub Splitter_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
 
'if the splitter has been moved...
If currSplitPosX <> &H7FFFFFFF Then
'if the current postition <> the last position do a final move of the splitter
If CLng(X) <> currSplitPosX Then
    Splitter.Move Splitter.Left + X, CTRL_OFFSET, SPLT_WDTH, ScaleHeight - (CTRL_OFFSET * 2)
End If
 
'call this the default position
currSplitPosX = &H7FFFFFFF
 
'restore the normal splitter colour
Splitter.BackColor = &H8000000F
 
'and check for valid sizings.
'Either enforce the default minimum & maximum widths for the left list, or, if within range, set the width
 
If Splitter.Left > 60 And Splitter.Left < (ScaleWidth - 60) Then
 
ListLeft.Width = Splitter.Left - ListLeft.Left 'the pane is within range
 
 
ElseIf Splitter.Left < 60 Then 'the pane is too small
    ListLeft.Width = 60
Else
    ListLeft.Width = ScaleWidth - 60 'the pane is too wide
End If
    'reposition both lists, and the splitter bar
    Form_Resize
End If
 
End Sub
 
 

文件列表(点击上边下载按钮,如果是垃圾文件请在下面评价差评或者投诉):

实现可以用鼠标切分的窗体VB源码程序/
实现可以用鼠标切分的窗体VB源码程序/MSSCCPRJ.SCC
实现可以用鼠标切分的窗体VB源码程序/Vsplit.frm
实现可以用鼠标切分的窗体VB源码程序/Vsplit.frx
实现可以用鼠标切分的窗体VB源码程序/工程1.vbp
实现可以用鼠标切分的窗体VB源码程序/工程1.vbw

关键词: 窗体 源码 鼠标

编程语言下载排行

Top_arrow
回到顶部
联系方式| 版权声明| 招聘信息| 广告服务| 银行汇款| 法律顾问| 兼职技术| 付款方式| 关于我们|
网站客服网站客服 程序员兼职招聘 程序员兼职招聘
沪ICP备19040327号-3
公安备案号:沪公网安备 31011802003874号
库纳格流体控制系统(上海)有限公司 版权所有
Copyright © 1999-2014, GUSUCODE.COM, All Rights Reserved