frmDock.picContents.Width = picHolder.ScaleWidth
frmDock.picContents.Height = picHolder.ScaleHeight
frmDock.picContents_Resize
End Sub
Private Sub picSizer_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
Dim nSide As Integer
If picHolder.Visible Then
'// need to do this or SendMessage fails
ReleaseCapture
'// Send message to start resizing frmDocking.Picture1
Select Case picSizer.Align
Case vbAlignRight
nSide = HTLEFT
Case vbAlignLeft
nSide = HTRIGHT
Case vbAlignTop
nSide = HTBOTTOM
Case vbAlignBottom
nSide = HTTOP
End Select
SendMessage picHolder.hwnd, WM_NCLBUTTONDOWN, nSide, ByVal &O0
If picHolder.Width < 500 Then picHolder.Width = 500
If picHolder.Height < 500 Then picHolder.Height = 500
picHolder_Resize
End If
Else
End If
End Sub
Private Sub picSizer_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If picSizer.Width > picSizer.Height Then
picSizer.MousePointer = 7
Else
picSizer.MousePointer = 9
End If
End Sub
Private Sub picSizer_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
picSizer.BackColor = &H8000000A
Call frmDock.picContents_Resize
End Sub
Private Sub picTitle_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If X > frmDock.picTitle.Width Then X = frmDock.picTitle.Width \ 2
firstDown.X = X
firstDown.Y = Y
End Sub
Private Sub picTitle_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button <> 1 Then Exit Sub
'SendMessage frmDock.picTitle.hwnd, WM_LBUTTONDOWN, 0, 0
frmDock.picTitle_MouseMove 1, Shift, X, Y
End Sub
Private Sub picTitle_Paint()
picTitle.Cls
picTitle.Print "Teste"
End Sub
frmDock.picContents.Width = picHolder.ScaleWidth
frmDock.picContents.Height = picHolder.ScaleHeight
frmDock.picContents_Resize
End Sub
frmDock的Code
Public Sub Form_Resize()
picContents.Height = Me.Height - picTitle.Height - 50
picContents.Width = Width
End Sub
Public Sub picContents_Resize()
'File1.Move 0, 0, picContents.Width, picContents.Height - 200
' File1.Width = picContents.Width
' File1.Height = picContents.Height
If GetParent(picContents.hwnd) = Me.hwnd Then
File1.Width = picContents.Width - 100
File1.Height = picContents.Height
Else
File1.Width = picContents.Width
File1.Height = picContents.Height - 500
End If
End Sub
Private Sub picTitle_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
firstDown.X = X
firstDown.Y = Y
End Sub
Public Sub picTitle_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button <> 1 Then Exit Sub
Dim pp As POINTAPI
GetCursorPos pp
pp.Y = pp.Y * Screen.TwipsPerPixelY
pp.X = pp.X * Screen.TwipsPerPixelX
Me.Top = pp.Y - firstDown.Y
Me.Left = pp.X - firstDown.X
'fMainForm.picHolder.Width = Me.Width
Dim tmp
If (pp.Y > fMainForm.Top And _
pp.Y < fMainForm.Top + fMainForm.picSnap.Height And _
pp.X > fMainForm.Left And pp.X < fMainForm.Left _
+ fMainForm.Width) And (Shift <> vbCtrlMask) Then
fMainForm.picHolder.Align = vbAlignTop
' fMainForm.picHolder.Width = fMainForm.Width
fMainForm.picHolder.Height = Me.Height
'
fMainForm.picHolder.Visible = True
Me.Visible = False
If GetParent(picContents.hwnd) <> fMainForm.picHolder.hwnd Then _
SetParent picContents.hwnd, fMainForm.picHolder.hwnd
ElseIf (pp.Y > fMainForm.Top + fMainForm.Height - fMainForm.picSnap.ScaleHeight And _
pp.Y < fMainForm.Top + fMainForm.Height And _
pp.X > fMainForm.Left And pp.X < fMainForm.Left _
+ fMainForm.Width) And (Shift <> vbCtrlMask) Then
fMainForm.picHolder.Align = vbAlignBottom
' fMainForm.picHolder.Width = fMainForm.Width
fMainForm.picHolder.Height = Me.Height
'
fMainForm.picHolder.Visible = True
Me.Visible = False
If GetParent(picContents.hwnd) <> fMainForm.picHolder.hwnd Then _
SetParent picContents.hwnd, fMainForm.picHolder.hwnd
ElseIf (pp.Y > fMainForm.Top And pp.Y < fMainForm.Top + fMainForm.Height And pp.X > fMainForm.Left And pp.X < fMainForm.Left + fMainForm.picSnap.Width) And (Shift <> vbCtrlMask) Then
fMainForm.picHolder.Align = vbAlignLeft
fMainForm.picHolder.Width = Me.Width
' fMainForm.picHolder.Height = Me.Height
fMainForm.picHolder.Visible = True
Me.Visible = False
If GetParent(picContents.hwnd) <> fMainForm.picHolder.hwnd Then _
SetParent picContents.hwnd, fMainForm.picHolder.hwnd
ElseIf (pp.Y > fMainForm.Top And pp.Y < fMainForm.Top + fMainForm.Height And pp.X > fMainForm.Left + fMainForm.Width - fMainForm.picSnap.Width And pp.X < fMainForm.Left + fMainForm.Width) And (Shift <> vbCtrlMask) Then
fMainForm.picHolder.Align = vbAlignRight
fMainForm.picHolder.Width = Me.Width
' fMainForm.picHolder.Height = Me.Height
fMainForm.picHolder.Visible = True
Me.Visible = False
If GetParent(picContents.hwnd) <> fMainForm.picHolder.hwnd Then _
SetParent picContents.hwnd, fMainForm.picHolder.hwnd
Else
fMainForm.picHolder.Visible = False
Visible = True
If GetParent(picContents.hwnd) <> Me.hwnd Then _
SetParent picContents.hwnd, Me.hwnd
End If
picContents.Refresh
picTitle_Paint
fMainForm.picSizer.Align = 0
fMainForm.picSizer.Align = fMainForm.picHolder.Align
Select Case fMainForm.picSizer.Align
Case vbAlignTop, vbAlignBottom
fMainForm.picSizer.Height = 80
Case vbAlignRight, vbAlignLeft
fMainForm.picSizer.Width = 80
End Select
If GetParent(picContents.hwnd) = Me.hwnd Then
picContents.Height = Me.Height - picTitle.Height - 50
picContents.Width = Width
End If
End Sub
Private Sub picTitle_Paint()
picTitle.Cls
picTitle.Print "Teste"
End Sub
用FORM_RESIZE()事件, 实时控制子窗体的大小, 当判断到子窗体被最大化的时候, 转为正常模式, 把子窗体的Height和Width属性变化为需要的大小, 如:
Private sub Form_Resize()
if me.WindowState=vbMaximized then
me.WindowState=vbNormal
me.move 0,100,800,400 ''这个句子就是改变你的窗体为固定大小的!
endif
End Sub