我想做一个象资源管理器那样,可以随窗口的缩小放大重新分布控件,可以调整左右窗口大小。该窗体是个子窗体,放有4个控件,左边的treeview控件--tvwleft,分割条picdiv,右半部分:上面是frame1,下面是msflexgrid控件--mshfright。我不知道代码究竟错在哪里?'捕捉鼠标
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As LongPrivate Sub Form_Resize()
'调整TREE和LIST及frame1的大小和位置
With TvwLeft
.Left = 10
.Top = 10
.Height = Abs(Me.ScaleHeight)
End With
'调整分隔条的位置和大小
With picDiv
.BorderStyle = vbBSNone
.Left = TvwLeft.Left + TvwLeft.Width + 15
.Top = 10
.Height = TvwLeft.Height
End With
With Frame1
.Left = picDiv.Left + picDiv.Width + 15
.Top = 10
.Width = Abs(Me.ScaleWidth - TvwLeft.Width - TvwLeft.Left - picDiv.Width - 30)
End With
With MshfRight
.Left = Frame1.Left
.Top = Frame1.Top + Frame1.Height + 30
.Width = Frame1.Width
.Height = (Me.ScaleHeight - Frame1.Height - 60)
End With
End SubPrivate Sub picDiv_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then picDiv.BackColor = &H0
End SubPrivate Sub picDiv_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
If X < 0 Or Y < 0 Or X > picDiv.Width Or Y > picDiv.Height Then
ReleaseCapture
Screen.MousePointer = 0
Else
SetCapture picDiv.hwnd '当移入控件的时候,捕获鼠标
Screen.MousePointer = 9
End If
If Button = vbLeftButton Then picDiv.Left = picDiv.Left + X
End SubPrivate Sub picDiv_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
picDiv.BackColor = &H80000000
'调整TREE和LIST及frame1的大小和位置
Select Case picDiv.Left
Case Is < 1000
picDiv.Left = 1000
Case Is > Me.ScaleWidth - 1000
picDiv.Left = Me.ScaleWidth - 1000
End Select
TvwLeft.Width = picDiv.Left - 30
With MshfRight
.Left = picDiv.Left + 30
.Width = Me.ScaleWidth - picDiv.Left + 30
End With
With Frame1
.Left = MshfRight.Left
.Width = MshfRight.Width
End With
End If
End Sub
顺便,我不是很明白ScaleWidth,scalehight的概念。MSDN里说是一种度量单位哪位大侠能指点一下迷津?
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As LongPrivate Sub Form_Resize()
'调整TREE和LIST及frame1的大小和位置
With TvwLeft
.Left = 10
.Top = 10
.Height = Abs(Me.ScaleHeight)
End With
'调整分隔条的位置和大小
With picDiv
.BorderStyle = vbBSNone
.Left = TvwLeft.Left + TvwLeft.Width + 15
.Top = 10
.Height = TvwLeft.Height
End With
With Frame1
.Left = picDiv.Left + picDiv.Width + 15
.Top = 10
.Width = Abs(Me.ScaleWidth - TvwLeft.Width - TvwLeft.Left - picDiv.Width - 30)
End With
With MshfRight
.Left = Frame1.Left
.Top = Frame1.Top + Frame1.Height + 30
.Width = Frame1.Width
.Height = (Me.ScaleHeight - Frame1.Height - 60)
End With
End SubPrivate Sub picDiv_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then picDiv.BackColor = &H0
End SubPrivate Sub picDiv_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
If X < 0 Or Y < 0 Or X > picDiv.Width Or Y > picDiv.Height Then
ReleaseCapture
Screen.MousePointer = 0
Else
SetCapture picDiv.hwnd '当移入控件的时候,捕获鼠标
Screen.MousePointer = 9
End If
If Button = vbLeftButton Then picDiv.Left = picDiv.Left + X
End SubPrivate Sub picDiv_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
picDiv.BackColor = &H80000000
'调整TREE和LIST及frame1的大小和位置
Select Case picDiv.Left
Case Is < 1000
picDiv.Left = 1000
Case Is > Me.ScaleWidth - 1000
picDiv.Left = Me.ScaleWidth - 1000
End Select
TvwLeft.Width = picDiv.Left - 30
With MshfRight
.Left = picDiv.Left + 30
.Width = Me.ScaleWidth - picDiv.Left + 30
End With
With Frame1
.Left = MshfRight.Left
.Width = MshfRight.Width
End With
End If
End Sub
顺便,我不是很明白ScaleWidth,scalehight的概念。MSDN里说是一种度量单位哪位大侠能指点一下迷津?
NEW PROJECT-->VB APPLICATION WIZARD-->FROM WHAT PROFILE DO U WANT TO LOAD UR SETTINGS?(NONE)找不到任何profile...