可以参考一下:Option ExplicitPrivate Declare Function DrawEdge Lib "user32" (ByVal hdc As Long, qrc As RECT, ByVal edge As Long, ByVal grfFlags As Long) As Long Private Declare Function GetClientRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long Private Declare Function SetCapture Lib "user32" (ByVal hWnd As Long) As Long Private Declare Function ReleaseCapture Lib "user32" () As LongPrivate Const BF_TOP = &H2 Private Const BF_LEFT = &H1 Private Const BF_RIGHT = &H4 Private Const BF_BOTTOM = &H8 Private Const BF_RECT = (BF_LEFT Or BF_TOP Or BF_RIGHT Or BF_BOTTOM)Private Const BDR_RAISEDINNER = &H4 Private Const BDR_SUNKENOUTER = &H2Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End TypePrivate rc As RECTPrivate Sub Form_Load() Picture1.AutoRedraw = True End SubPrivate Sub Picture1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single) GetClientRect Picture1.hWnd, rc If x > 0 And x < Picture1.ScaleWidth And y > 0 And y < Picture1.ScaleHeight Then DrawEdge Picture1.hdc, rc, BDR_RAISEDINNER, BF_RECT Picture1.Refresh SetCapture Picture1.hWnd Else Picture1.Cls ReleaseCapture End If End SubPrivate Sub Picture1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) DrawEdge Picture1.hdc, rc, BDR_SUNKENOUTER, BF_RECT Picture1.Refresh End SubPrivate Sub Picture1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single) DrawEdge Picture1.hdc, rc, BDR_RAISEDINNER, BF_RECT Picture1.Refresh End Sub
Private Declare Function GetClientRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
Private Declare Function SetCapture Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As LongPrivate Const BF_TOP = &H2
Private Const BF_LEFT = &H1
Private Const BF_RIGHT = &H4
Private Const BF_BOTTOM = &H8
Private Const BF_RECT = (BF_LEFT Or BF_TOP Or BF_RIGHT Or BF_BOTTOM)Private Const BDR_RAISEDINNER = &H4
Private Const BDR_SUNKENOUTER = &H2Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End TypePrivate rc As RECTPrivate Sub Form_Load()
Picture1.AutoRedraw = True
End SubPrivate Sub Picture1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
GetClientRect Picture1.hWnd, rc
If x > 0 And x < Picture1.ScaleWidth And y > 0 And y < Picture1.ScaleHeight Then
DrawEdge Picture1.hdc, rc, BDR_RAISEDINNER, BF_RECT
Picture1.Refresh
SetCapture Picture1.hWnd
Else
Picture1.Cls
ReleaseCapture
End If
End SubPrivate Sub Picture1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
DrawEdge Picture1.hdc, rc, BDR_SUNKENOUTER, BF_RECT
Picture1.Refresh
End SubPrivate Sub Picture1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
DrawEdge Picture1.hdc, rc, BDR_RAISEDINNER, BF_RECT
Picture1.Refresh
End Sub