Compact Framework - 在不活动一段时间后锁定 UI 的超时功能

发布于 2024-07-10 03:04:25 字数 745 浏览 9 评论 0原文

早上好,

我是一个中型 PDA 应用程序的开发人员,该应用程序将在街上使用。 PDA 将包含一些模糊敏感数据(姓名和地址等)。 移动数据库上的加密已经处理完毕,但是如果有人在登录时拿到 PDA,他们可以愉快地浏览数据,直到电池耗尽或关闭应用程序并不得不再次登录。

当用户访问 PDA 应用程序时,他们需要输入用户名和 PIN 码。 该软件的第 1 版在系统中的每个按钮中都添加了一个事件,因此当按下按钮时,它会更新一个名为 LastActionTime 的变量。 主窗体上运行一个计时器,如果 LastActionTime 超过 10 分钟,系统将再次弹出登录窗体,直到前一个用户/管理员再次登录(就像 Windows 锁定屏幕一样)。

这工作得很好...从某种意义上...问题是它只处理按钮而不处理其他控件,如ListViews、PictureBoxes 等。

有什么好的方法可以实现这一点吗? 例如,有没有一种方法可以扩展 Windows 窗体类来处理每个事件并相应地更新该变量? 或者我可以做一些类似 Windows 的事情来处理表单上的每个鼠标事件吗?

为了完全简洁,我想要实现的是,当 PDA 屏幕/按钮 10 分钟没有被触摸时,PDA 会知道这一点并允许我触发我的锁定方法。

任何想法、帮助和指导将不胜感激。

编辑:我在Windows Mobile 6.0上使用Compact Framework 2.0,但该功能需要在Windows Mobile 5.0及更高版本上运行。

Good morning,

I am the developer of a medium sized PDA application that will be used out on the streets. The PDA will contain some vaguely sensitive data (names and addresses, etc). The encryption on the mobile database is already handled, however if someone got hold of the PDA whilst it was logged in they could happily go through the data until the battery died or they closed the application and had to log in again.

When the users access the PDA application they need to enter their username and PIN number. Version 1 of this software had an event hooked into every button in the system so that when the button was pressed, it updated a variable called LastActionTime. A timer ran on the main form and if that LastActionTime was more than 10 minutes ago then the system would throw up the login form again until the previous user/admin logged back in again (just like the windows lockout screen).

This worked fine... in a sense... the problem with that is that it was only handling buttons and wasn't handling the other controls, like ListViews, PictureBoxes, etc.

Is there any good way of achieving this? For example, is there a way I could extend a Windows Form Class to handle every single event and update that variable accordingly? Or can I do something windows-esque that would handle every single mouse event on the form?

To be completely concise, what I want to achieve is that when the PDA screen/buttons have not been touched for 10 minutes, the PDA will know this and allow me to fire my lockout method.

Any thoughts, help and guidance would be much appreciated.

Edit: I am using Compact Framework 2.0 on Windows Mobile 6.0, however the function needs to work on Windows Mobile 5.0 and above.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

漫漫岁月 2024-07-17 03:04:25

一种可能的解决方案是依靠 PDA 进入电源空闲状态。 您可以使用 OpenNETCF.WindowsCE.PowerManager.PowerIdle 事件为此注册通知。 事实上,考虑电源管理因素是个好主意。 您不能期望您的 PDA 始终处于相同的状态。

另一个解决方案是监视输入驱动程序的非活动事件(请参阅此链接< /a>)。 然而,该解决方案是非常特定于设备的。

不幸的是,Windows CE 中无法注册全局鼠标事件挂钩。

以上是操作系统的解决方案。 扩展 Windows 窗体和控件类并没有简单的方法。 也许您需要扩展您将使用的所有控件。 最简单的解决方案是为所有控件和表单实现 GetFocus 方法。 你可以在那里重置你的计数器。

顺便说一句,在桌面环境中,这可以通过 GetLastInputInfo 轻松实现。

One possible solution is to rely on the PDA's entering power idle state. You can register a notification for this using OpenNETCF.WindowsCE.PowerManager.PowerIdle Event. In fact it is a good idea to take into account power management considerations. You can't expect your PDA to be in the same state all the time.

Another solution would be to monitor the inactive event of the input driver (See this link). However, this solution is very device specific.

Unfortunately there is no way in Windows CE to register a global mouse event hook.

The above were OS solutions. There is not an easy way to do it with extending Windows Form and Control classes. Probably you would need to extend all the controls you would be using. The easiest solution would be to implement the GetFocus method for all your controls and the form. You could reset your counter there.

By the way, in a desktop environment this can easily achieved with GetLastInputInfo.

白龙吟 2024-07-17 03:04:25

查看此帖子:

http://social.msdn.microsoft.com/Forums/en-US/netfxcompact/thread/906b016d-f1ee-4b3e-b3df-1e3a6fea282a/

我努力解决同样的问题,并最终使用 Application.AddMessageFilter以获得适当的结果。 该线程最终包含一个指向我编写的示例项目的链接,该项目显示了不活动计时器的工作情况,包括在必要时关闭子对话框以返回主窗口屏幕。

大卫

Check this post out:

http://social.msdn.microsoft.com/Forums/en-US/netfxcompact/thread/906b016d-f1ee-4b3e-b3df-1e3a6fea282a/

I wrestled with the same problem, and ended up using Application.AddMessageFilter to get the appropriate results. That thread eventually contains a link to a sample project I wrote showing the inactivity timer working, including shutting down subdialogs if necessary to return to a main window screen.

David

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文