我写的,你看看!
'--------Form1--------
VERSION 5.00
Begin VB.Form Form1
BorderStyle = 0 'None
Caption = "我的电脑"
ClientHeight = 2100
ClientLeft = 0
ClientTop = 0
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 2100
ScaleWidth = 4680
StartUpPosition = 3 'Windows Default
Begin VB.PictureBox Picture2
AutoSize = -1 'True
BorderStyle = 0 'None
Height = 240
Left = 30
Picture = "Form1.frx":0000
ScaleHeight = 240
ScaleWidth = 225
TabIndex = 4
Top = 20
Width = 225
End
Begin VB.PictureBox Picture1
AutoSize = -1 'True
BorderStyle = 0 'None
Height = 210
Left = 4400
Picture = "Form1.frx":0342
ScaleHeight = 210
ScaleWidth = 240
TabIndex = 3
Top = 20
Width = 240
End
Begin VB.CommandButton Command1
Caption = "Show Form2"
Height = 375
Left = 1560
TabIndex = 0
Top = 840
Width = 1695
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
BorderStyle = 1 'Fixed Single
Height = 1840
Left = 0
TabIndex = 2
Top = 240
Width = 4670
End
Begin VB.Label Label1
BackColor = &H00C00000&
Caption = " 我的电脑"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H8000000E&
Height = 270
Left = 0
TabIndex = 1
Top = 0
Width = 4695
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option ExplicitPrivate Sub Command1_Click()
Form2.Move Form1.Left, Form1.Top + Form1.Height
Connect = 1
Form2.Show
End SubPrivate Sub Label1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Label1.BackColor = vbBlue
Form2.Label1.BackColor = vbButtonShadow
Call MoveCTL_MouseDown(Button, x, y)
End SubPrivate Sub Label1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
Call MoveCTL_MouseMove(Form1, Form2, Button, x, y, False)
End SubPrivate Sub Label1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
Call MoveCTL_MouseUp(Button)
End SubPrivate Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Unload Form2
End SubPrivate Sub Picture1_Click()
Unload Form1
End Sub'-----Form2------
VERSION 5.00
Begin VB.Form Form2
BorderStyle = 0 'None
Caption = "Form2"
ClientHeight = 2115
ClientLeft = 0
ClientTop = 0
ClientWidth = 4680
LinkTopic = "Form2"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2115
ScaleWidth = 4680
ShowInTaskbar = 0 'False
StartUpPosition = 3 'Windows Default
Begin VB.PictureBox Picture1
AutoSize = -1 'True
BorderStyle = 0 'None
Height = 210
Left = 4400
Picture = "Form2.frx":0000
ScaleHeight = 210
ScaleWidth = 240
TabIndex = 1
Top = 20
Width = 240
End
Begin VB.PictureBox Picture2
AutoSize = -1 'True
BorderStyle = 0 'None
Height = 240
Left = 30
Picture = "Form2.frx":0073
ScaleHeight = 240
ScaleWidth = 225
TabIndex = 0
Top = 20
Width = 225
End
Begin VB.Label Label1
BackColor = &H80000010&
Caption = " 哈哈哈~~~``"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H8000000E&
Height = 270
Left = 0
TabIndex = 3
Top = 0
Width = 4695
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
BorderStyle = 1 'Fixed Single
Height = 1840
Left = 0
TabIndex = 2
Top = 240
Width = 4670
End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option ExplicitPrivate Sub Label1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Label1.BackColor = vbBlue
Form1.Label1.BackColor = vbButtonShadow
Call MoveCTL_MouseDown(Button, x, y)
End SubPrivate Sub Label1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
Call MoveCTL_MouseMove(Form1, Form2, Button, x, y, True)
End SubPrivate Sub Label1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
Call MoveCTL_MouseUp(Button)
End SubPrivate Sub Picture1_Click()
Unload Form2
End Sub'-----Modoul1-------
Attribute VB_Name = "Module1"
Public OldX As Integer
Public OldY As Integer
Public MouseDown As Boolean
Public Connect As Integer
'Connect=1 Form1 Buttom <-> Form2 Top
'Connect=2 Form1 Top <-> Form2 Buttom
'Connect=3 Form1 Right <-> Form2 Left
'Connect=4 Form1 Left <-> Form2 RightPublic Sub MoveCTL_MouseDown(Button As Integer, x As Single, y As Single)
If Button = 1 Then
MouseDown = True
OldX = x
OldY = y
End If
End SubPublic Sub MoveCTL_MouseMove(Form1 As Form, Form2 As Form, Button As Integer, x As Single, y As Single, Optional IsSubForm As Boolean = True)
If Not MouseDown Or Button <> 1 Then Exit Sub
If Not IsSubForm Then
Form1.Move Form1.Left + (x - OldX), Form1.Top + (y - OldY)
If Connect > 0 Then
Form2.Move Form2.Left + (x - OldX), Form2.Top + (y - OldY): Exit Sub
End If
Else
If Connect = 0 Then Form2.Move Form2.Left + (x - OldX), Form2.Top + (y - OldY)
End If
If Connect = 0 Then
If Form2.Top > Form1.Top + Form1.Height - 100 And Form2.Top <= Form1.Top + Form1.Height + 100 And Form2.Left <= Form1.Left + Form1.Width And Form1.Left <= Form2.Left + Form2.Width Then
Form2.Top = Form1.Top + Form1.Height
Connect = 1
Exit Sub
End If
If Form1.Top > Form2.Top + Form2.Height - 100 And Form1.Top <= Form2.Top + Form2.Height + 100 And Form1.Left <= Form2.Left + Form2.Width And Form2.Left <= Form1.Left + Form1.Width Then
Form2.Top = Form1.Top - Form2.Height
Connect = 2
Exit Sub
End If
If Form2.Left > Form1.Left + Form1.Width - 100 And Form2.Left <= Form1.Left + Form1.Width + 100 And Form2.Top <= Form1.Top + Form1.Height And Form2.Top + Form2.Height > Form1.Top Then
Form2.Left = Form1.Left + Form1.Width
Connect = 3
Exit Sub
End If
If Form1.Left > Form2.Left + Form2.Width - 100 And Form1.Left <= Form2.Left + Form2.Width + 100 And Form2.Top <= Form1.Top + Form1.Height And Form2.Top + Form2.Height > Form1.Top Then
Form2.Left = Form1.Left - Form2.Width
Connect = 4
Exit Sub
End If
End If
If IsSubForm Then
If Connect = 1 Or Connect = 2 Then
Form2.Move Form2.Left + (x - OldX)
If Abs(y - OldY) >= 100 Or Form2.Left > Form1.Left + Form1.Width Or Form1.Left > Form2.Left + Form2.Width Then
'Form2.Move Form2.Left + (x - OldX), Form2.Top + (y - OldY)
Connect = 0
End If
ElseIf Connect = 3 Or Connect = 4 Then
Form2.Move Form2.Left, Form2.Top + (y - OldY)
If Abs(x - OldX) >= 100 Or Form2.Top > Form1.Top + Form1.Width Or Form2.Top + Form2.Width < Form1.Top Then
'Form2.Move Form2.Left + (x - OldX), Form2.Top + (y - OldY)
Connect = 0
End If
End If
End If
End SubPublic Sub MoveCTL_MouseUp(Button As Integer)
MouseDown = False
End Sub'------The End-------
'--------Form1--------
VERSION 5.00
Begin VB.Form Form1
BorderStyle = 0 'None
Caption = "我的电脑"
ClientHeight = 2100
ClientLeft = 0
ClientTop = 0
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 2100
ScaleWidth = 4680
StartUpPosition = 3 'Windows Default
Begin VB.PictureBox Picture2
AutoSize = -1 'True
BorderStyle = 0 'None
Height = 240
Left = 30
Picture = "Form1.frx":0000
ScaleHeight = 240
ScaleWidth = 225
TabIndex = 4
Top = 20
Width = 225
End
Begin VB.PictureBox Picture1
AutoSize = -1 'True
BorderStyle = 0 'None
Height = 210
Left = 4400
Picture = "Form1.frx":0342
ScaleHeight = 210
ScaleWidth = 240
TabIndex = 3
Top = 20
Width = 240
End
Begin VB.CommandButton Command1
Caption = "Show Form2"
Height = 375
Left = 1560
TabIndex = 0
Top = 840
Width = 1695
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
BorderStyle = 1 'Fixed Single
Height = 1840
Left = 0
TabIndex = 2
Top = 240
Width = 4670
End
Begin VB.Label Label1
BackColor = &H00C00000&
Caption = " 我的电脑"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H8000000E&
Height = 270
Left = 0
TabIndex = 1
Top = 0
Width = 4695
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option ExplicitPrivate Sub Command1_Click()
Form2.Move Form1.Left, Form1.Top + Form1.Height
Connect = 1
Form2.Show
End SubPrivate Sub Label1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Label1.BackColor = vbBlue
Form2.Label1.BackColor = vbButtonShadow
Call MoveCTL_MouseDown(Button, x, y)
End SubPrivate Sub Label1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
Call MoveCTL_MouseMove(Form1, Form2, Button, x, y, False)
End SubPrivate Sub Label1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
Call MoveCTL_MouseUp(Button)
End SubPrivate Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Unload Form2
End SubPrivate Sub Picture1_Click()
Unload Form1
End Sub'-----Form2------
VERSION 5.00
Begin VB.Form Form2
BorderStyle = 0 'None
Caption = "Form2"
ClientHeight = 2115
ClientLeft = 0
ClientTop = 0
ClientWidth = 4680
LinkTopic = "Form2"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2115
ScaleWidth = 4680
ShowInTaskbar = 0 'False
StartUpPosition = 3 'Windows Default
Begin VB.PictureBox Picture1
AutoSize = -1 'True
BorderStyle = 0 'None
Height = 210
Left = 4400
Picture = "Form2.frx":0000
ScaleHeight = 210
ScaleWidth = 240
TabIndex = 1
Top = 20
Width = 240
End
Begin VB.PictureBox Picture2
AutoSize = -1 'True
BorderStyle = 0 'None
Height = 240
Left = 30
Picture = "Form2.frx":0073
ScaleHeight = 240
ScaleWidth = 225
TabIndex = 0
Top = 20
Width = 225
End
Begin VB.Label Label1
BackColor = &H80000010&
Caption = " 哈哈哈~~~``"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H8000000E&
Height = 270
Left = 0
TabIndex = 3
Top = 0
Width = 4695
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
BorderStyle = 1 'Fixed Single
Height = 1840
Left = 0
TabIndex = 2
Top = 240
Width = 4670
End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option ExplicitPrivate Sub Label1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Label1.BackColor = vbBlue
Form1.Label1.BackColor = vbButtonShadow
Call MoveCTL_MouseDown(Button, x, y)
End SubPrivate Sub Label1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
Call MoveCTL_MouseMove(Form1, Form2, Button, x, y, True)
End SubPrivate Sub Label1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
Call MoveCTL_MouseUp(Button)
End SubPrivate Sub Picture1_Click()
Unload Form2
End Sub'-----Modoul1-------
Attribute VB_Name = "Module1"
Public OldX As Integer
Public OldY As Integer
Public MouseDown As Boolean
Public Connect As Integer
'Connect=1 Form1 Buttom <-> Form2 Top
'Connect=2 Form1 Top <-> Form2 Buttom
'Connect=3 Form1 Right <-> Form2 Left
'Connect=4 Form1 Left <-> Form2 RightPublic Sub MoveCTL_MouseDown(Button As Integer, x As Single, y As Single)
If Button = 1 Then
MouseDown = True
OldX = x
OldY = y
End If
End SubPublic Sub MoveCTL_MouseMove(Form1 As Form, Form2 As Form, Button As Integer, x As Single, y As Single, Optional IsSubForm As Boolean = True)
If Not MouseDown Or Button <> 1 Then Exit Sub
If Not IsSubForm Then
Form1.Move Form1.Left + (x - OldX), Form1.Top + (y - OldY)
If Connect > 0 Then
Form2.Move Form2.Left + (x - OldX), Form2.Top + (y - OldY): Exit Sub
End If
Else
If Connect = 0 Then Form2.Move Form2.Left + (x - OldX), Form2.Top + (y - OldY)
End If
If Connect = 0 Then
If Form2.Top > Form1.Top + Form1.Height - 100 And Form2.Top <= Form1.Top + Form1.Height + 100 And Form2.Left <= Form1.Left + Form1.Width And Form1.Left <= Form2.Left + Form2.Width Then
Form2.Top = Form1.Top + Form1.Height
Connect = 1
Exit Sub
End If
If Form1.Top > Form2.Top + Form2.Height - 100 And Form1.Top <= Form2.Top + Form2.Height + 100 And Form1.Left <= Form2.Left + Form2.Width And Form2.Left <= Form1.Left + Form1.Width Then
Form2.Top = Form1.Top - Form2.Height
Connect = 2
Exit Sub
End If
If Form2.Left > Form1.Left + Form1.Width - 100 And Form2.Left <= Form1.Left + Form1.Width + 100 And Form2.Top <= Form1.Top + Form1.Height And Form2.Top + Form2.Height > Form1.Top Then
Form2.Left = Form1.Left + Form1.Width
Connect = 3
Exit Sub
End If
If Form1.Left > Form2.Left + Form2.Width - 100 And Form1.Left <= Form2.Left + Form2.Width + 100 And Form2.Top <= Form1.Top + Form1.Height And Form2.Top + Form2.Height > Form1.Top Then
Form2.Left = Form1.Left - Form2.Width
Connect = 4
Exit Sub
End If
End If
If IsSubForm Then
If Connect = 1 Or Connect = 2 Then
Form2.Move Form2.Left + (x - OldX)
If Abs(y - OldY) >= 100 Or Form2.Left > Form1.Left + Form1.Width Or Form1.Left > Form2.Left + Form2.Width Then
'Form2.Move Form2.Left + (x - OldX), Form2.Top + (y - OldY)
Connect = 0
End If
ElseIf Connect = 3 Or Connect = 4 Then
Form2.Move Form2.Left, Form2.Top + (y - OldY)
If Abs(x - OldX) >= 100 Or Form2.Top > Form1.Top + Form1.Width Or Form2.Top + Form2.Width < Form1.Top Then
'Form2.Move Form2.Left + (x - OldX), Form2.Top + (y - OldY)
Connect = 0
End If
End If
End If
End SubPublic Sub MoveCTL_MouseUp(Button As Integer)
MouseDown = False
End Sub'------The End-------
帮我个问题吧!请看:http://www.csdn.net/expert/topic/353/353422.shtm
我也要源码:[email protected]
thanks!!!
[email protected]
我也想要一份,谢谢!
[email protected]
我也要源码:[email protected]
thanks!!!
我也要源码: [email protected]
thanks!!!
[email protected]
多谢
if you are free,give me ,thank you very much, my email [email protected]