一个简单的办法,你可以通过VB应用程序向导来自动生成,方法:
1.新建工程,然后选"VB应用程序向导"。
2.按照向导走,当选界面类型时,选择"资源管理器样式",其它的你就自己选吧。
生成代码后,你就可以在此基础上添加自己的功能了,如果不想要它的代码,自己也可以分析借签一下。
1.新建工程,然后选"VB应用程序向导"。
2.按照向导走,当选界面类型时,选择"资源管理器样式",其它的你就自己选吧。
生成代码后,你就可以在此基础上添加自己的功能了,如果不想要它的代码,自己也可以分析借签一下。
解决方案 »
- 基础问题
- 手填mshflexgrid,一万条记录要20多秒才能填完,正常吗?太慢了,(求帮我改下代码吧)
- 刚发现一整套XP控件,太棒了,与大家共享!
- 关于函数中的参数传递!谢谢了!
- 请教:用findwindow成功抓到另一程序窗体句柄,但我想获取窗体的下一及的一个frame控件的名称却不能实现
- 急!一个API的问题
- 学习vb给点建议!!!
- 请问哪儿有水晶报表的详细介绍?
- zyl910(910) langzhi(方舟) yechat(沙尘)
- ★★★★★★怎样用文本框实现货币数据输入★★★★★★
- 怎样用SQL生成行号
- 怎么将ADO Recordset 数据绑定到DataBoundGird中?谁做过?
Sub SizeControls(X As Single)
On Error Resume Next
'set the width
If X < 1500 Then X = 1500
If X > (Me.Width - 1500) Then X = Me.Width - 1500
msgList.Width = X
imgSplitter.Left = X
msgViewer.Left = X + 70
msgViewer.Width = Me.Width - (msgList.Width + 200)
'set the top
msgViewer.Top = Me.ScaleTop + 450
msgList.Top = Me.ScaleTop + 450
'set the height
msgList.Height = Me.ScaleHeight - 500
msgViewer.Height = msgList.Height
imgSplitter.Top = msgList.Top
imgSplitter.Height = msgList.Height
picSplitter.Top = msgList.Top
picSplitter.Height = msgList.Height
End Sub
Private Sub Form_Resize()
On Error Resume Next
If Me.Width < 3000 Then Me.Width = 3000
SizeControls imgSplitter.Left
End SubPrivate Sub imgSplitter_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
With imgSplitter
picSplitter.Move .Left, .Top, .Width \ 2, .Height - 20
End With
picSplitter.Visible = True
mbMoving = True
End Sub
Private Sub imgSplitter_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim sglPos As Single
If mbMoving Then
sglPos = X + imgSplitter.Left
If sglPos < sglSplitLimit Then
picSplitter.Left = sglSplitLimit
ElseIf sglPos > Me.Width - sglSplitLimit Then
picSplitter.Left = Me.Width - sglSplitLimit
Else
picSplitter.Left = sglPos
End If
End If
End Sub
Private Sub imgSplitter_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
SizeControls picSplitter.Left
picSplitter.Visible = False
mbMoving = False
End Sub
在FORM上加入一个IMAGEBOX一个PICTUREBOX并改名为imgSplitter和picSplitter
加入一个list控件,一个RichText控件并改名为msgList和msgViewer主要思路:通过对imgSplitter的拖动的响应,修改窗口中的控件大小。
http://microinfo.top263.net/Txt/EasyView.txt
例程下载:
http://microinfo.top263.net/Txt/EasyView.txt
'set the startup variablesCTRL_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 = &H7FFFFFFFListLeft.AddItem "Left list Item 1"
ListLeft.AddItem "Left list Item 2"
ListLeft.AddItem "Left list Item 3"
ListLeft.AddItem "Left list Item 4"
ListLeft.AddItem "Left list Item 5"'note: VB3 users will need to substitute Chr$(13) & chr$(10) for the VB4 constant vbCrLf in the sentence below.TextRight = "This code demonstrates how to implement a spliiter bar in a Visual Basic Project." & vbCrLf & vbCrLf & "It's actions are controlled through the MouseDown, MouseMove and MouseUp subs of the Splitter Picturebox, and the Resize event of the form."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 IntegerOn Error Resume Next'set the height of the controlsheight1 = ScaleHeight - (CTRL_OFFSET * 2)
x1 = CTRL_OFFSET
width1 = ListLeft.Widthx2 = 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, height1End SubPrivate 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 IfEnd 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 IfEnd IfEnd 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 widthIf Splitter.Left > 60 And Splitter.Left < (ScaleWidth - 60) ThenListLeft.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 IfEnd Sub