第一个 问题:Dim FrmW As Single '存放改变前的窗体的宽度 Dim frmH As Single '存放改变前的窗体的高度Private Sub Form_Load() If WindowState <> vbMinimized Then FrmW = Me.Width frmH = Me.Height '上面两句是初始化模块变量 End If End SubPrivate Sub Form_Resize() If FrmW = 0 Or frmH = 0 Then Exit SubDim MyCon As Control Dim sig1 As Single, sig2 As Single sig1 = Me.Width / FrmW sig2 = Me.Height / frmH For Each MyCon In Me.Controls If TypeOf MyCon Is Label Or _ TypeOf MyCon Is CommandButton Or _ TypeOf MyCon Is ListView Or _ TypeOf MyCon Is TextBox Or _ TypeOf MyCon Is Toolbar Or _ TypeOf MyCon Is SSTab Or _ TypeOf MyCon Is PictureBox Or _ TypeOf MyCon Is CheckBox Or _ TypeOf MyCon Is OptionButton Or _ TypeOf MyCon Is Frame Then
With MyCon ' MsgBox .Name .Left = Int(.Left * sig1) .Top = Int(.Top * sig2) .Width = Int(.Width * sig1) .Height = Int(.Height * sig2) End With
End If Next MyCon
For Each MyCon In Me.Controls If TypeOf MyCon Is ComboBox Then With MyCon .Left = Int(.Left * sig1) .Top = Int(.Top * sig2) .Width = Int(.Width * sig1) End With End If Next MyConFrmW = Me.Width frmH = Me.HeightEnd Sub
第一个 问题:Dim FrmW As Single '存放改变前的窗体的宽度 Dim frmH As Single '存放改变前的窗体的高度Private Sub Form_Load() If WindowState <> vbMinimized Then FrmW = Me.Width frmH = Me.Height '上面两句是初始化模块变量 End If End SubPrivate Sub Form_Resize() If FrmW = 0 Or frmH = 0 Then Exit SubDim MyCon As Control Dim sig1 As Single, sig2 As Single sig1 = Me.Width / FrmW sig2 = Me.Height / frmH For Each MyCon In Me.Controls If TypeOf MyCon Is Label Or _ TypeOf MyCon Is CommandButton Or _ TypeOf MyCon Is ListView Or _ TypeOf MyCon Is TextBox Or _ TypeOf MyCon Is Toolbar Or _ TypeOf MyCon Is SSTab Or _ TypeOf MyCon Is PictureBox Or _ TypeOf MyCon Is CheckBox Or _ TypeOf MyCon Is OptionButton Or _ TypeOf MyCon Is Frame Then
With MyCon ' MsgBox .Name .Left = Int(.Left * sig1) .Top = Int(.Top * sig2) .Width = Int(.Width * sig1) .Height = Int(.Height * sig2) End With
End If Next MyCon
For Each MyCon In Me.Controls If TypeOf MyCon Is ComboBox Then With MyCon .Left = Int(.Left * sig1) .Top = Int(.Top * sig2) .Width = Int(.Width * sig1) End With End If Next MyConFrmW = Me.Width frmH = Me.HeightEnd Sub
GANXIAOPENG(种菜的) 没有搞错吗? 不需要这么复杂。
TO :ypyao85() 我是从程序中直接拷的了!没有删除多余的东西了! SORRY!:)主要就是 TypeOf MyCon Is “控件类型” 了!
有什么编程思路吗?烦高手指点!!
2仔细观察一下别人的软件,大多数是这样做的,只需要加一个PictureBox控件,改成长条形。
在picturebox的MouseDown,MouseUp,MouseMove事件中加入一些代码,如mouseDown中加入判断,只有按下鼠标才能拖动,
mouseMove中加入判断函数,主要是鼠标的位置,
mouseUp中把PictureBox的位置放在你想要的位置,再调整TreeView,ListView的位置,大小
Dim frmH As Single '存放改变前的窗体的高度Private Sub Form_Load()
If WindowState <> vbMinimized Then
FrmW = Me.Width
frmH = Me.Height
'上面两句是初始化模块变量
End If
End SubPrivate Sub Form_Resize()
If FrmW = 0 Or frmH = 0 Then Exit SubDim MyCon As Control
Dim sig1 As Single, sig2 As Single
sig1 = Me.Width / FrmW
sig2 = Me.Height / frmH
For Each MyCon In Me.Controls
If TypeOf MyCon Is Label Or _
TypeOf MyCon Is CommandButton Or _
TypeOf MyCon Is ListView Or _
TypeOf MyCon Is TextBox Or _
TypeOf MyCon Is Toolbar Or _
TypeOf MyCon Is SSTab Or _
TypeOf MyCon Is PictureBox Or _
TypeOf MyCon Is CheckBox Or _
TypeOf MyCon Is OptionButton Or _
TypeOf MyCon Is Frame Then
With MyCon
' MsgBox .Name
.Left = Int(.Left * sig1)
.Top = Int(.Top * sig2)
.Width = Int(.Width * sig1)
.Height = Int(.Height * sig2)
End With
End If
Next MyCon
For Each MyCon In Me.Controls
If TypeOf MyCon Is ComboBox Then
With MyCon
.Left = Int(.Left * sig1)
.Top = Int(.Top * sig2)
.Width = Int(.Width * sig1)
End With
End If
Next MyConFrmW = Me.Width
frmH = Me.HeightEnd Sub
Dim frmH As Single '存放改变前的窗体的高度Private Sub Form_Load()
If WindowState <> vbMinimized Then
FrmW = Me.Width
frmH = Me.Height
'上面两句是初始化模块变量
End If
End SubPrivate Sub Form_Resize()
If FrmW = 0 Or frmH = 0 Then Exit SubDim MyCon As Control
Dim sig1 As Single, sig2 As Single
sig1 = Me.Width / FrmW
sig2 = Me.Height / frmH
For Each MyCon In Me.Controls
If TypeOf MyCon Is Label Or _
TypeOf MyCon Is CommandButton Or _
TypeOf MyCon Is ListView Or _
TypeOf MyCon Is TextBox Or _
TypeOf MyCon Is Toolbar Or _
TypeOf MyCon Is SSTab Or _
TypeOf MyCon Is PictureBox Or _
TypeOf MyCon Is CheckBox Or _
TypeOf MyCon Is OptionButton Or _
TypeOf MyCon Is Frame Then
With MyCon
' MsgBox .Name
.Left = Int(.Left * sig1)
.Top = Int(.Top * sig2)
.Width = Int(.Width * sig1)
.Height = Int(.Height * sig2)
End With
End If
Next MyCon
For Each MyCon In Me.Controls
If TypeOf MyCon Is ComboBox Then
With MyCon
.Left = Int(.Left * sig1)
.Top = Int(.Top * sig2)
.Width = Int(.Width * sig1)
End With
End If
Next MyConFrmW = Me.Width
frmH = Me.HeightEnd Sub
没有搞错吗?
不需要这么复杂。
SORRY!:)主要就是 TypeOf MyCon Is “控件类型” 了!