玩酷之家

 找回密码
 立即注册
查看: 67|回复: 0

VB 鼠标移到窗口边缘时不会出现双向前头

[复制链接]
发表于 2021-1-8 16:42:59 | 显示全部楼层 |阅读模式
  1. '------------下面是模块代码---------------------------------------

  2. Option Explicit

  3. Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
  4. Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
  5. Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

  6. Public Const GWL_WNDPROC = (-4)
  7. Public Const WM_ENDSESSION = &H16
  8. Public Const WM_QUERYENDSESSION = &H11

  9. Public preWinProc As Long

  10. Public Function Wndproc(ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  11.     Wndproc = CallWindowProc(preWinProc, hwnd, Msg, wParam, lParam)
  12.     If (Msg = 132) Then
  13.         Select Case Wndproc
  14.             Case 10, 11, 12, 13, 14, 15, 16, 17:
  15.             Wndproc = 0
  16.             Exit Function
  17.         End Select
  18.     End If
  19. End Function


  20. '------------下面是窗体代码---------------------------------------
  21. Option Explicit

  22. Private Sub Form_Load()
  23.     Dim ret As Long
  24.     '记录原来的Window Procedure的位址
  25.     preWinProc = GetWindowLong(Me.hwnd, GWL_WNDPROC)
  26.     '设定form的window Procedure到wndproc
  27.     ret = SetWindowLong(Me.hwnd, GWL_WNDPROC, AddressOf Wndproc)
  28. End Sub

  29. Private Sub Form_Unload2(Cancel As Integer)
  30.     Dim ret As Long
  31.     '取消Message的截取,而使之又只送往原来的Window Procedure
  32.     ret = SetWindowLong(Me.hwnd, GWL_WNDPROC, preWinProc)
  33. End Sub
复制代码


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|玩酷之家 ( 鄂ICP备14012049号 )

GMT+8, 2021-1-25 19:39 , Processed in 1.092002 second(s), 17 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表