请帮忙检查一下哪里错了
vb吧
全部回复
仅看楼主
level 1
Option ExplicitPrivate Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As LongPrivate Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As LongPrivate Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As LongPrivate Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As LongPrivate Declare Function ReleaseCapture Lib "user32" () As LongPrivate Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As LongPrivate Const WM_GETTEXT = &HDPrivate Type POINTAPIx As Longy As LongEnd TypeDim IsDragging As BooleanPrivate Sub Form_Load()On Error Resume NextIsDragging = FalseEnd SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)On Error Resume NextIf IsDragging = True Then Dim rtn As Long, curwnd As Long, tempstr As String Dim point As POINTAPI Dim strlong As Long point.x = x point.y = y '将客户坐标转化为屏幕坐标 If ClientToScreen(Me.hwnd, point) = 0 Then Exit Sub '获得鼠标所在的窗口句柄 curwnd = WindowFromPoint(point.x, point.y) '获得该窗口的类型 tempstr = Space(250) strlong = Len(tempstr) rtn = GetClassName(curwnd, tempstr, strlong) If rtn = 0 Then Exit Sub tempstr = Trim(tempstr) '向该窗口发送一个WM_GETTEXT消息,以获得该窗口的文本,并显示在文本框中 tempstr = Space(250) strlong = Len(tempstr) rtn = SendMessage(curwnd, WM_GETTEXT, strlong, tempstr) tempstr = Trim(tempstr) Text1.Text = tempstrEnd IfEnd SubPrivate Sub Form_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)On Error Resume NextIf IsDragging = True Then Screen.MousePointer = vbDefault IsDragging = False '释放鼠标消息抓取 ReleaseCaptureEnd IfEnd SubPrivate Sub Picture1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)On Error Resume NextIf IsDragging = False Then IsDragging = True Screen.MouseIcon = Picture1.Picture Screen.MousePointer = vbCustom '将以后的鼠标输入消息都发送到本程序窗口 SetCapture (Me.hwnd)End IfEnd Sub我在XP里一拖动就自动关闭,控件只有TEXTBOX和PICTUREBOX
2006年07月05日 12点07分 1
1