以下是引用片段: 其关键代码如下: Option Explicit Dim intOldX As Integer '/****窗体移动 Dim intOldy As Integer Dim boolMouseFlag As Boolean Private Sub Button1_Click() Unload Me End Sub Private Sub FlatScrollBar1_Change() Picture2.Left = -FlatScrollBar1.Value End Sub Private Sub FlatScrollBar2_Change() Picture2.Top = -FlatScrollBar2.Value End Sub Private Sub Form_Activate() FlatScrollBar1.Max = Picture2.Width - Picture1.Width FlatScrollBar2.Max = Picture2.Height - Picture1.Height End Sub
Private Sub Form_Load() Call FormFace(Me, TopPicture, KKShape) End Sub Private Sub Form_Resize() Call TopCaption(Me.TopPicture, Me.Label2.Caption) Dim XX As Long Dim YY As Long If Picture2.Width > Picture1.Width Then XX = 0 FlatScrollBar1.Enabled = True Else XX = (Picture1.Width - Picture2.Width) / 2 FlatScrollBar1.Enabled = False End If If Picture2.Height > Picture1.Height Then YY = 0 FlatScrollBar2.Enabled = True Else YY = (Picture1.Height - Picture2.Height) / 2 FlatScrollBar2.Enabled = False End If Picture2.Move XX, YY End Sub Private Sub TopPicture_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) intOldX = X intOldy = Y boolMouseFlag = True End Sub Private Sub TopPicture_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) '存储窗提议动前的left,top Dim intLeft, intTop As Integer intLeft = Me.Left intTop = Me.Top If boolMouseFlag = True Then Me.Left = intLeft + (X - intOldX) Me.Top = intTop + (Y - intOldy) End If End Sub
Private Sub TopPicture_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) boolMouseFlag = False End Sub
Private Sub UserControl13_Click() Unload Me End Sub
|