[121038一行代码经典系列]一行代码把鼠标限制在窗口里(有趣但也有漏洞)
先在窗口中拖一个PictureBox
然后写代码(API声明不算,事件代码不算,真正限制鼠标的只有一行代码)
Private Declare Function PostMessageByNum& Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long)
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
PostMessageByNum Picture1.hwnd, 274, 61450, 0
End Sub
虽然还有些缺陷,但是,还是挺有趣的