设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

12
返回列表 发新帖
楼主: fannky
打印 上一主题 下一主题

[Access本身] [求助][求助]如何自动关闭Access

[复制链接]
11#
 楼主| 发表于 2006-5-22 22:19:00 | 只看该作者
楼上的可否说的详细点?

怎样捕获事件?
12#
 楼主| 发表于 2006-5-23 18:35:00 | 只看该作者
我实在不中意灌水,但是看这贴子要沉了,而且还是没有得到答案,不甘心啊

再挺起来……
13#
发表于 2006-5-23 21:17:00 | 只看该作者
以下是引用fannky在2006-5-22 8:30:00的发言:



至于实现如何困难都是题外话,我想知道可行性与方法,3Q





OK,如果你实在感兴趣的话,推荐你查找一下关于API钩子的文章,监控鼠标键盘动作,一般都是通过将自己的程序钩入系统,当鼠标键盘有任何操作时,你的代码将被调用,然后在你的代码中记录最后的操作时间,并判断是否已经超时。如果超时可以通过API直接关闭应用程序。

其实这个可行性没什么好怀疑的,Windows应用程序本身就建立在API的基础上,这是整个Windows编程的基础。



14#
发表于 2006-5-23 21:21:00 | 只看该作者
这里有一段zhuyiwen版主提供的禁用鼠标滚轮的代码,供你参考借鉴API钩入的方法。



Option Compare Database
Option Explicit
Public dk As Boolean
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
    (ByVal hwnd As Long, _
    ByVal nIndex As Long, _
    ByVal dwNewLong As Long) As Long

Public 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


Public Const GWL_WNDPROC = -4
Public Const WM_MouseWheel = &H20A
Public lpPrevWndProc As Long
Public CMouse As CMouseWheel

Public Function WindowProc(ByVal hwnd As Long, _
    ByVal uMsg As Long, _
    ByVal wParam As Long, _
    ByVal lParam As Long) As Long

    'Look at the message passed to the window. If it is
    'a mouse wheel message, call the FireMouseWheel procedure
    'in the CMouseWheel class, which in turn raises the MouseWheel
    'event. If the Cancel argument in the form event procedure is
    'set to False, then we process the message normally, otherwise
    'we ignore it.  If the message is something other than the mouse
    'wheel, then process it normally
    Select Case uMsg
        Case WM_MouseWheel
            CMouse.FireMouseWheel
            If CMouse.MouseWheelCancel = False Then
                WindowProc = CallWindowProc(lpPrevWndProc, hwnd, uMsg, wParam, lParam)
            End If


        Case Else
           WindowProc = CallWindowProc(lpPrevWndProc, hwnd, uMsg, wParam, lParam)
    End Select
End Function


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

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-5-24 05:49 , Processed in 0.084921 second(s), 26 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

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