Private Declare Function SendMessage Lib "User32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Private Declare Sub ReleaseCapture Lib "User32" () Const WM_NCLBUTTONDOWN = &HA1 Const HTCAPTION = 2 Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) 'KPD-Team 1999 'URL: http://www.allapi.net/ 'E-Mail: [email protected] Dim lngReturnValue As Long If Button = 1 Then 'Release capture Call ReleaseCapture 'Send a 'left mouse button down on caption'-message to our form lngReturnValue = SendMessage(Me.hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&) End If End Sub Private Sub Form_Paint() Me.Print "Click on the form, hold the mouse button and drag it" End Sub以上代码2000通过
看这个 对你有没有 启发: ===============================================================Private Type POINTAPI X As Long Y As Long End Type Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function ReleaseCapture Lib "user32" () As Long Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long Dim Pt As POINTAPI Private Sub Form_Load() 'KPD-Team 1999 'URL: http://www.allapi.net/ 'E-Mail: [email protected] 'redirect all mouse input to this form SetCapture Me.hwnd End Sub Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) ReleaseCapture SetCapture Me.hwnd End Sub Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) 'Get the current cursor position GetCursorPos Pt Me.CurrentX = 0 Me.CurrentY = 0 'Clear the screen Me.Cls Me.Print "Cursor position:" 'Print the mouse co鰎dinates to the form Me.Print "X:" + Str$(Pt.X) + " Y:" + Str$(Pt.Y) Me.Print " (Press ALT-F4 to unload this form)" SetCapture Me.hwnd End Sub Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) ReleaseCapture SetCapture Me.hwnd End Sub
看这个 对你有没有 启发: ===============================================================Private Type POINTAPI X As Long Y As Long End Type Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function ReleaseCapture Lib "user32" () As Long Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long Dim Pt As POINTAPI Private Sub Form_Load() SetCapture Me.hwnd End Sub Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) ReleaseCapture SetCapture Me.hwnd End Sub Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) 'Get the current cursor position GetCursorPos Pt Me.CurrentX = 0 Me.CurrentY = 0 'Clear the screen Me.Cls Me.Print "Cursor position:" 'Print the mouse co鰎dinates to the form Me.Print "X:" + Str$(Pt.X) + " Y:" + Str$(Pt.Y) Me.Print " (Press ALT-F4 to unload this form)" SetCapture Me.hwnd End Sub Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) ReleaseCapture SetCapture Me.hwnd End Sub
Private Declare Sub ReleaseCapture Lib "User32" ()
Const WM_NCLBUTTONDOWN = &HA1
Const HTCAPTION = 2
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'KPD-Team 1999
'URL: http://www.allapi.net/
'E-Mail: [email protected]
Dim lngReturnValue As Long
If Button = 1 Then
'Release capture
Call ReleaseCapture
'Send a 'left mouse button down on caption'-message to our form
lngReturnValue = SendMessage(Me.hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&)
End If
End Sub
Private Sub Form_Paint()
Me.Print "Click on the form, hold the mouse button and drag it"
End Sub以上代码2000通过
ReleaseCapture
SendMessage Me.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
....
给分呀!!!!!!!!!!!
我在win98用的是SendMessage时通过,在win2000时却不能通过。
对了,tg123的代码,我也用过的。只是我俩写的程序是相同的,但是我那里却不能通过,哎…
===============================================================Private Type POINTAPI
X As Long
Y As Long
End Type
Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Dim Pt As POINTAPI
Private Sub Form_Load()
'KPD-Team 1999
'URL: http://www.allapi.net/
'E-Mail: [email protected]
'redirect all mouse input to this form
SetCapture Me.hwnd
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
ReleaseCapture
SetCapture Me.hwnd
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'Get the current cursor position
GetCursorPos Pt
Me.CurrentX = 0
Me.CurrentY = 0
'Clear the screen
Me.Cls
Me.Print "Cursor position:"
'Print the mouse co鰎dinates to the form
Me.Print "X:" + Str$(Pt.X) + " Y:" + Str$(Pt.Y)
Me.Print " (Press ALT-F4 to unload this form)"
SetCapture Me.hwnd
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
ReleaseCapture
SetCapture Me.hwnd
End Sub
===============================================================Private Type POINTAPI
X As Long
Y As Long
End Type
Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Dim Pt As POINTAPI
Private Sub Form_Load()
SetCapture Me.hwnd
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
ReleaseCapture
SetCapture Me.hwnd
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'Get the current cursor position
GetCursorPos Pt
Me.CurrentX = 0
Me.CurrentY = 0
'Clear the screen
Me.Cls
Me.Print "Cursor position:"
'Print the mouse co鰎dinates to the form
Me.Print "X:" + Str$(Pt.X) + " Y:" + Str$(Pt.Y)
Me.Print " (Press ALT-F4 to unload this form)"
SetCapture Me.hwnd
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
ReleaseCapture
SetCapture Me.hwnd
End Sub
win2000连bitblt都要出现问题。(不是出问题而是,方法和结果不同)。
惨哦。