Option Explicit Dim maymove As Boolean Dim dx As Integer Dim dy As Integer Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If (Button = 1) Then dx = X dy = Y maymove = True Else Unload Me End If End Sub Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Dim mx As Integer Dim my As Integer If (maymove = True) Then mx = X - dx my = Y - dy Form1.Left = Form1.Left + mx Form1.Top = Form1.Top + my End If End Sub Private Sub Command1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) maymove = False End Sub Private Sub Form_Load() maymove = False 'Me.BorderStyle = none Form1.Height = Command1.Height Form1.Width = Command1.Width Command1.Left = 0 Command1.Top = 0 End SubPrivate Sub Timer1_Timer() Command1.Caption = Now End Sub
Private Declare Function ReleaseCapture Lib "user32" () As Long Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As LongConst HTCAPTION = 2 Const WM_NCLBUTTONDOWN = &HA1Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single) If Button = 1 Then ReleaseCapture SendMessage Picture1.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0 End If End Sub
Dim maymove As Boolean
Dim dx As Integer
Dim dy As Integer
Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If (Button = 1) Then
dx = X
dy = Y
maymove = True
Else
Unload Me
End If
End Sub
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim mx As Integer
Dim my As Integer
If (maymove = True) Then
mx = X - dx
my = Y - dy
Form1.Left = Form1.Left + mx
Form1.Top = Form1.Top + my
End If
End Sub
Private Sub Command1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
maymove = False
End Sub
Private Sub Form_Load()
maymove = False
'Me.BorderStyle = none
Form1.Height = Command1.Height
Form1.Width = Command1.Width
Command1.Left = 0
Command1.Top = 0
End SubPrivate Sub Timer1_Timer()
Command1.Caption = Now
End Sub
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As LongConst HTCAPTION = 2
Const WM_NCLBUTTONDOWN = &HA1Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
If Button = 1 Then
ReleaseCapture
SendMessage Picture1.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0
End If
End Sub